diff --git a/amoro-ams/src/test/java/org/apache/amoro/server/RestCatalogServiceTestBase.java b/amoro-ams/src/test/java/org/apache/amoro/server/RestCatalogServiceTestBase.java index 5a3c4aa82d..9bf32f904f 100644 --- a/amoro-ams/src/test/java/org/apache/amoro/server/RestCatalogServiceTestBase.java +++ b/amoro-ams/src/test/java/org/apache/amoro/server/RestCatalogServiceTestBase.java @@ -43,13 +43,16 @@ import java.io.IOException; import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; public abstract class RestCatalogServiceTestBase { static AmsEnvironment ams = AmsEnvironment.getIntegrationInstances(); static String restCatalogUri = RestCatalogService.ICEBERG_REST_API_PREFIX; - protected final String database = "test_ns"; + private static final AtomicLong TEST_INSTANCE_COUNTER = new AtomicLong(); + + protected final String database = "test_ns_" + TEST_INSTANCE_COUNTER.incrementAndGet(); protected final String table = "test_iceberg_tbl"; protected final TableIdentifier tableIdentifier = TableIdentifier.of(catalogName(), database, table); diff --git a/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalIcebergCatalogService.java b/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalIcebergCatalogService.java index 19d4ace8a7..3a5ea9e1c0 100644 --- a/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalIcebergCatalogService.java +++ b/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalIcebergCatalogService.java @@ -104,12 +104,18 @@ public void testCatalogProperties() { public class NamespaceTests { @Test public void testNamespaceOperations() throws IOException { - Assertions.assertTrue(nsCatalog.listNamespaces().isEmpty()); - nsCatalog.createNamespace(Namespace.of(database)); - Assertions.assertEquals(1, nsCatalog.listNamespaces().size()); - Assertions.assertEquals(0, nsCatalog.listNamespaces(Namespace.of(database)).size()); - nsCatalog.dropNamespace(Namespace.of(database)); - Assertions.assertTrue(nsCatalog.listNamespaces().isEmpty()); + Namespace dbNamespace = Namespace.of(database); + int initialNamespaceCount = nsCatalog.listNamespaces().size(); + Assertions.assertFalse(nsCatalog.listNamespaces().contains(dbNamespace)); + + nsCatalog.createNamespace(dbNamespace); + Assertions.assertEquals(initialNamespaceCount + 1, nsCatalog.listNamespaces().size()); + Assertions.assertTrue(nsCatalog.listNamespaces().contains(dbNamespace)); + Assertions.assertEquals(0, nsCatalog.listNamespaces(dbNamespace).size()); + + nsCatalog.dropNamespace(dbNamespace); + Assertions.assertEquals(initialNamespaceCount, nsCatalog.listNamespaces().size()); + Assertions.assertFalse(nsCatalog.listNamespaces().contains(dbNamespace)); } } diff --git a/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalMixedCatalogService.java b/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalMixedCatalogService.java index 3e24e42b61..65e8d387bd 100644 --- a/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalMixedCatalogService.java +++ b/amoro-ams/src/test/java/org/apache/amoro/server/TestInternalMixedCatalogService.java @@ -165,16 +165,20 @@ public void test() { MixedFormatCatalog catalog = loadMixedIcebergCatalog(); Assertions.assertEquals( InternalMixedIcebergCatalog.class.getName(), catalog.getClass().getName()); - Assertions.assertTrue(catalog.listDatabases().isEmpty()); + int initialDatabaseCount = catalog.listDatabases().size(); + int initialNamespaceCount = nsCatalog.listNamespaces(Namespace.of()).size(); + Assertions.assertFalse(catalog.listDatabases().contains(database)); catalog.createDatabase(database); - Assertions.assertEquals(1, catalog.listDatabases().size()); + Assertions.assertEquals(initialDatabaseCount + 1, catalog.listDatabases().size()); Assertions.assertTrue(catalog.listDatabases().contains(database)); - Assertions.assertEquals(1, nsCatalog.listNamespaces(Namespace.of()).size()); + Assertions.assertEquals( + initialNamespaceCount + 1, nsCatalog.listNamespaces(Namespace.of()).size()); catalog.dropDatabase(database); - Assertions.assertTrue(catalog.listDatabases().isEmpty()); - Assertions.assertTrue(nsCatalog.listNamespaces().isEmpty()); + Assertions.assertEquals(initialDatabaseCount, catalog.listDatabases().size()); + Assertions.assertFalse(catalog.listDatabases().contains(database)); + Assertions.assertEquals(initialNamespaceCount, nsCatalog.listNamespaces().size()); } }