Skip to content

Commit

Permalink
Migrate Iceberg Catalog tests to JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Oct 25, 2023
1 parent 2771775 commit 76abea2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.iceberg.Table;
import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.types.Types;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import io.trino.plugin.iceberg.catalog.TrinoCatalog;
import io.trino.plugin.iceberg.catalog.hms.TrinoHiveCatalog;
import io.trino.spi.type.TestingTypeManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;

import java.io.File;
import java.io.IOException;
Expand All @@ -35,14 +36,16 @@
import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_FACTORY;
import static io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.memoizeMetastore;
import static io.trino.plugin.hive.metastore.file.TestingFileHiveMetastore.createTestingFileHiveMetastore;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;

@TestInstance(PER_CLASS)
public class TestTrinoHiveCatalogWithFileMetastore
extends BaseTrinoCatalogTest
{
private HiveMetastore metastore;
private Path tempDir;

@BeforeClass
@BeforeAll
public void setUp()
throws Exception
{
Expand All @@ -51,7 +54,7 @@ public void setUp()
metastore = createTestingFileHiveMetastore(metastoreDir);
}

@AfterClass(alwaysRun = true)
@AfterAll
public void tearDown()
throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.trino.spi.security.PrincipalType;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.spi.type.TestingTypeManager;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
import io.trino.plugin.iceberg.catalog.TrinoCatalog;
import io.trino.spi.security.ConnectorIdentity;
import io.trino.spi.type.TestingTypeManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;

import java.util.Map;
import java.util.Optional;
Expand All @@ -53,7 +54,9 @@
import static io.trino.testing.containers.Minio.MINIO_ACCESS_KEY;
import static io.trino.testing.containers.Minio.MINIO_SECRET_KEY;
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;

@TestInstance(PER_CLASS)
public class TestTrinoHiveCatalogWithHiveMetastore
extends BaseTrinoCatalogTest
{
Expand All @@ -62,14 +65,14 @@ public class TestTrinoHiveCatalogWithHiveMetastore
// Use MinIO for storage, since HDFS is hard to get working in a unit test
private HiveMinioDataLake dataLake;

@BeforeClass
@BeforeAll
public void setUp()
{
dataLake = new HiveMinioDataLake(bucketName, HIVE3_IMAGE);
dataLake.start();
}

@AfterClass(alwaysRun = true)
@AfterAll
public void tearDown()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
import io.trino.spi.security.TrinoPrincipal;
import io.trino.spi.type.TestingTypeManager;
import org.apache.iceberg.nessie.NessieIcebergClient;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.http.HttpClientBuilder;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
Expand All @@ -54,20 +55,22 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;

@TestInstance(PER_CLASS)
public class TestTrinoNessieCatalog
extends BaseTrinoCatalogTest
{
private NessieContainer nessieContainer;

@BeforeClass
@BeforeAll
public void setupServer()
{
nessieContainer = NessieContainer.builder().build();
nessieContainer.start();
}

@AfterClass(alwaysRun = true)
@AfterAll
public void teardownServer()
{
if (nessieContainer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.iceberg.rest.DelegatingRestSessionCatalog;
import org.apache.iceberg.rest.RESTSessionCatalog;
import org.assertj.core.util.Files;
import org.junit.jupiter.api.Test;

import java.io.File;

Expand Down Expand Up @@ -61,13 +62,15 @@ protected TrinoCatalog createTrinoCatalog(boolean useUniqueTableLocations)
return new TrinoRestCatalog(restSessionCatalog, new CatalogName(catalogName), NONE, "test", useUniqueTableLocations);
}

@Test
@Override
public void testView()
{
assertThatThrownBy(super::testView)
.hasMessageContaining("createView is not supported for Iceberg REST catalog");
}

@Test
@Override
public void testNonLowercaseNamespace()
{
Expand Down

0 comments on commit 76abea2

Please sign in to comment.