From b7f4e344971f30f28663e68a6b70aedac8ef5f6c Mon Sep 17 00:00:00 2001 From: Qi Yu Date: Wed, 16 Oct 2024 18:54:38 +0800 Subject: [PATCH] [#4951] improvement(test): Reduce fields shares between different IT to make AbstractIT more independent. (#4996) ### What changes were proposed in this pull request? Remove static fields of `AbstractIT` to make it more robust. ### Why are the changes needed? To make it more robut. Fix: #4951 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? The existing test. --- .../integration/test/RangerHiveE2EIT.java | 15 +++-- .../integration/test/HadoopCatalogIT.java | 14 ++-- .../test/HadoopUserAuthenticationIT.java | 22 +++---- .../test/HadoopUserImpersonationIT.java | 8 +-- .../hive/integration/test/CatalogHiveIT.java | 8 +-- .../test/HiveUserAuthenticationIT.java | 26 ++++---- .../integration/test/ProxyCatalogHiveIT.java | 24 +++---- .../integration/test/CatalogDorisIT.java | 15 ++--- .../integration/test/AuditCatalogMysqlIT.java | 14 ++-- .../integration/test/CatalogMysqlIT.java | 4 +- .../integration/test/CatalogPostgreSqlIT.java | 4 +- .../test/TestMultipleJDBCLoad.java | 6 +- .../integration/test/CatalogKafkaIT.java | 10 +-- .../integration/test/HudiCatalogHMSIT.java | 6 +- .../test/CatalogIcebergBaseIT.java | 14 ++-- .../test/CatalogIcebergHiveIT.java | 2 - .../test/CatalogIcebergKerberosHiveIT.java | 26 ++++---- .../test/CatalogIcebergRestIT.java | 2 - .../test/TestMultipleJDBCLoad.java | 6 +- .../integration/test/CatalogPaimonBaseIT.java | 4 +- .../test/CatalogPaimonFileSystemIT.java | 2 - .../CatalogPaimonKerberosFilesystemIT.java | 28 ++++---- .../integration/test/CatalogPaimonS3IT.java | 2 - .../client/integration/test/AuditIT.java | 8 +-- .../client/integration/test/CatalogIT.java | 8 +-- .../client/integration/test/MetalakeIT.java | 4 +- .../client/integration/test/TagIT.java | 8 +-- .../integration/test/VersionOperationsIT.java | 4 +- .../test/authorization/AccessControlIT.java | 8 +-- .../AccessControlNotAllowIT.java | 4 +- .../authorization/CheckCurrentUserIT.java | 10 +-- .../authorization/KerberosOperationsIT.java | 16 +++-- .../authorization/MultiAuthOperationsIT.java | 17 +++-- .../authorization/OAuth2OperationsIT.java | 8 +-- .../test/authorization/OwnerIT.java | 10 +-- .../test/GravitinoVirtualFileSystemIT.java | 8 +-- .../gravitino/storage/TestEntityStorage.java | 7 +- .../integration/test/FlinkEnvIT.java | 10 +-- .../test/hive/FlinkHiveCatalogIT.java | 2 - .../util/{AbstractIT.java => BaseIT.java} | 64 +++++++++---------- .../test/util/CloseContainerExtension.java | 2 +- .../integration/test/SparkEnvIT.java | 17 +++-- .../test/hive/SparkHiveCatalogIT.java | 2 - .../SparkIcebergCatalogHiveBackendIT.java | 2 - .../SparkIcebergCatalogRestBackendIT.java | 2 - .../test/sql/SparkQueryRunner.java | 12 ++-- .../test/sql/SparkSQLRegressionTest.java | 2 - .../integration/test/util/SparkUtilIT.java | 4 +- .../connector/utils/TestConnectorUtil.java | 2 - .../integration/test/TrinoConnectorIT.java | 8 +-- .../integration/test/TrinoQueryIT.java | 9 ++- .../integration/test/TrinoQueryITBase.java | 25 ++++---- .../integration/test/TrinoQueryTestTool.java | 2 +- .../test/web/ui/CatalogsPageDorisTest.java | 18 +++--- .../test/web/ui/CatalogsPageKafkaTest.java | 18 +++--- .../test/web/ui/CatalogsPageTest.java | 20 +++--- .../test/web/ui/MetalakePageTest.java | 12 +++- .../test/web/ui/pages/CatalogsPage.java | 8 ++- .../test/web/ui/pages/MetalakePage.java | 8 ++- .../{AbstractWebIT.java => BaseWebIT.java} | 14 ++-- .../test/web/ui/utils/WebDriverManager.java | 4 +- 61 files changed, 324 insertions(+), 325 deletions(-) rename integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/{AbstractIT.java => BaseIT.java} (90%) rename web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/{AbstractWebIT.java => BaseWebIT.java} (92%) diff --git a/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java b/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java index 2769d2fbc8a..28f9228e893 100644 --- a/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java +++ b/authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java @@ -54,7 +54,7 @@ import org.apache.gravitino.connector.AuthorizationPropertiesMeta; import org.apache.gravitino.integration.test.container.HiveContainer; import org.apache.gravitino.integration.test.container.RangerContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.meta.AuditInfo; import org.apache.gravitino.meta.RoleEntity; @@ -71,7 +71,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class RangerHiveE2EIT extends AbstractIT { +public class RangerHiveE2EIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(RangerHiveE2EIT.class); private static RangerAuthorizationPlugin rangerAuthPlugin; @@ -99,7 +99,7 @@ public class RangerHiveE2EIT extends AbstractIT { private static String RANGER_ADMIN_URL = null; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { // Enable Gravitino Authorization mode Map configs = Maps.newHashMap(); configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(true)); @@ -107,7 +107,7 @@ public static void startIntegrationTest() throws Exception { configs.put(Configs.AUTHENTICATORS.getKey(), AuthenticatorType.SIMPLE.name().toLowerCase()); configs.put("SimpleAuthUserName", TEST_USER_NAME); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); RangerITEnv.setup(); RangerITEnv.startHiveRangerContainer(); @@ -180,7 +180,8 @@ private static void generateRangerSparkSecurityXML() throws IOException { } @AfterAll - public static void stop() throws IOException { + public void stop() throws IOException { + client = null; if (client != null) { Arrays.stream(catalog.asSchemas().listSchemas()) .filter(schema -> !schema.equals("default")) @@ -204,7 +205,7 @@ public static void stop() throws IOException { LOG.error("Failed to close CloseableGroup", e); } - AbstractIT.client = null; + client = null; } @Test @@ -267,7 +268,7 @@ void testAllowUseSchemaPrivilege() throws InterruptedException { 1, rows2.stream().filter(row -> row.getString(0).equals(schemaName)).count()); } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); diff --git a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java index 20f9a1eeab8..644b98cb9f0 100644 --- a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java +++ b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java @@ -43,7 +43,7 @@ import org.apache.gravitino.file.FilesetChange; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class HadoopCatalogIT extends AbstractIT { +public class HadoopCatalogIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(HadoopCatalogIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -74,7 +74,7 @@ public class HadoopCatalogIT extends AbstractIT { private static String defaultBaseLocation; @BeforeAll - public static void setup() throws IOException { + public void setup() throws IOException { containerSuite.startHiveContainer(); Configuration conf = new Configuration(); conf.set("fs.defaultFS", defaultBaseLocation()); @@ -86,7 +86,7 @@ public static void setup() throws IOException { } @AfterAll - public static void stop() throws IOException { + public void stop() throws IOException { Catalog catalog = metalake.loadCatalog(catalogName); catalog.asSchemas().dropSchema(schemaName, true); metalake.dropCatalog(catalogName); @@ -102,7 +102,7 @@ public static void stop() throws IOException { } } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); @@ -114,14 +114,14 @@ private static void createMetalake() { metalake = loadMetalake; } - private static void createCatalog() { + private void createCatalog() { metalake.createCatalog( catalogName, Catalog.Type.FILESET, provider, "comment", ImmutableMap.of()); catalog = metalake.loadCatalog(catalogName); } - private static void createSchema() { + private void createSchema() { Map properties = Maps.newHashMap(); properties.put("key1", "val1"); properties.put("key2", "val2"); diff --git a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java index 7a56f8503a3..0a23ea7d326 100644 --- a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java +++ b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java @@ -46,7 +46,7 @@ import org.apache.gravitino.file.Fileset; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.hadoop.security.UserGroupInformation; import org.junit.jupiter.api.AfterAll; @@ -60,7 +60,7 @@ import sun.security.krb5.KrbException; @Tag("gravitino-docker-test") -public class HadoopUserAuthenticationIT extends AbstractIT { +public class HadoopUserAuthenticationIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(HadoopUserAuthenticationIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -104,7 +104,7 @@ public class HadoopUserAuthenticationIT extends AbstractIT { private static final String TABLE_NAME = "test_table"; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { containerSuite.startKerberosHiveContainer(); kerberosHiveContainer = containerSuite.getKerberosHiveContainer(); @@ -122,7 +122,7 @@ public static void startIntegrationTest() throws Exception { addKerberosConfig(); // Start Gravitino server - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } @AfterAll @@ -222,14 +222,12 @@ private static void createKeyTableForSchemaAndFileset() throws IOException { .copyFileFromContainer(HADOOP_FILESET_KEYTAB, TMP_DIR + HADOOP_FILESET_KEYTAB); } - private static void addKerberosConfig() { - AbstractIT.customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); + private void addKerberosConfig() { + customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); + customConfigs.put("gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); + customConfigs.put("gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); + customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); + customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); } @Test diff --git a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java index 248b8d54ffb..9515b45b5dd 100644 --- a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java +++ b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java @@ -45,7 +45,7 @@ import org.apache.gravitino.exceptions.FilesetAlreadyExistsException; import org.apache.gravitino.exceptions.IllegalNameIdentifierException; import org.apache.gravitino.file.Fileset; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.hadoop.conf.Configuration; @@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class HadoopUserImpersonationIT extends AbstractIT { +public class HadoopUserImpersonationIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(HadoopCatalogIT.class); public static final String metalakeName = @@ -111,7 +111,7 @@ private static void refreshKerberosConfig() { } @BeforeAll - public static void setup() throws Exception { + public void setup() throws Exception { if (!isEmbedded()) { return; } @@ -254,7 +254,7 @@ void testListFileSystem() throws Exception { }); } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); diff --git a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/CatalogHiveIT.java b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/CatalogHiveIT.java index 081aad480da..1233870b0b1 100644 --- a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/CatalogHiveIT.java +++ b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/CatalogHiveIT.java @@ -70,7 +70,7 @@ import org.apache.gravitino.hive.HiveClientPool; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -108,13 +108,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class CatalogHiveIT extends AbstractIT { +public class CatalogHiveIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CatalogHiveIT.class); public static final String metalakeName = GravitinoITUtils.genRandomName("CatalogHiveIT_metalake"); @@ -253,7 +251,7 @@ public void stop() throws IOException { LOG.error("Failed to close CloseableGroup", e); } - AbstractIT.client = null; + client = null; } @AfterEach diff --git a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/HiveUserAuthenticationIT.java b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/HiveUserAuthenticationIT.java index a4d982e30b8..d6330b0d819 100644 --- a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/HiveUserAuthenticationIT.java +++ b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/HiveUserAuthenticationIT.java @@ -43,7 +43,7 @@ import org.apache.gravitino.client.KerberosTokenProvider; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.TableChange; @@ -63,7 +63,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class HiveUserAuthenticationIT extends AbstractIT { +public class HiveUserAuthenticationIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(HiveUserAuthenticationIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -98,7 +98,7 @@ public class HiveUserAuthenticationIT extends AbstractIT { private static final String HIVE_COL_NAME3 = "col3"; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { containerSuite.startKerberosHiveContainer(); kerberosHiveContainer = containerSuite.getKerberosHiveContainer(); @@ -119,11 +119,11 @@ public static void startIntegrationTest() throws Exception { addKerberosConfig(); // Start Gravitino server - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } @AfterAll - public static void stop() { + public void stop() { // Reset the UGI UserGroupInformation.reset(); @@ -132,7 +132,7 @@ public static void stop() { System.clearProperty("java.security.krb5.conf"); System.clearProperty("sun.security.krb5.debug"); - AbstractIT.client = null; + client = null; } private static void prepareKerberosConfig() throws Exception { @@ -188,14 +188,12 @@ private static void refreshKerberosConfig() { } } - private static void addKerberosConfig() { - AbstractIT.customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); + private void addKerberosConfig() { + customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); + customConfigs.put("gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); + customConfigs.put("gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); + customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); + customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); } @Test diff --git a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java index 24c3c2cf443..d328a44dc64 100644 --- a/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java +++ b/catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java @@ -39,7 +39,7 @@ import org.apache.gravitino.hive.HiveClientPool; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -64,7 +64,7 @@ import org.junit.jupiter.api.Test; @Tag("gravitino-docker-test") -public class ProxyCatalogHiveIT extends AbstractIT { +public class ProxyCatalogHiveIT extends BaseIT { public static final String METALAKE_NAME = GravitinoITUtils.genRandomName("ProxyCatalogHiveIT_metalake"); @@ -88,10 +88,10 @@ public class ProxyCatalogHiveIT extends AbstractIT { private static GravitinoAdminClient anotherClientWithNotExistingName; private static Catalog anotherCatalog; private static Catalog anotherCatalogWithUsername; - private static Catalog anotherCatatlogWithNotExistingName; + private static Catalog anotherCatalogWithNotExistingName; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { originHadoopUser = System.getenv(HADOOP_USER_NAME); setEnv(HADOOP_USER_NAME, null); @@ -100,7 +100,7 @@ public static void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.AUTHENTICATORS.getKey(), AuthenticatorType.SIMPLE.name().toLowerCase()); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); containerSuite.startHiveContainer(); HIVE_METASTORE_URIS = String.format( @@ -137,13 +137,13 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void stop() { + public void stop() { setEnv(HADOOP_USER_NAME, originHadoopUser); anotherClient.close(); anotherClientWithUsername.close(); anotherClientWithNotExistingName.close(); - AbstractIT.client = null; + client = null; } @Test @@ -195,7 +195,7 @@ public void testOperateSchema() throws Exception { Assertions.assertThrows( RuntimeException.class, () -> - anotherCatatlogWithNotExistingName + anotherCatalogWithNotExistingName .asSchemas() .createSchema("new_schema", comment, properties)); Assertions.assertTrue(e.getMessage().contains("AccessControlException Permission denied")); @@ -256,7 +256,7 @@ public void testOperateTable() throws Exception { Assertions.assertThrows( RuntimeException.class, () -> { - anotherCatatlogWithNotExistingName + anotherCatalogWithNotExistingName .asTableCatalog() .createTable( anotherIdentWithNotExisting, @@ -370,7 +370,7 @@ public void testOperatePartition() throws Exception { Assertions.assertThrows( RuntimeException.class, () -> - anotherCatatlogWithNotExistingName + anotherCatalogWithNotExistingName .asTableCatalog() .loadTable(nameIdentifier) .supportPartitions() @@ -385,7 +385,7 @@ private Column[] createColumns() { return new Column[] {col1, col2, col3}; } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); @@ -421,7 +421,7 @@ private static void loadCatalogWithAnotherClient() { anotherCatalogWithUsername = anotherClientWithUsername.loadMetalake(METALAKE_NAME).loadCatalog(CATALOG_NAME); - anotherCatatlogWithNotExistingName = + anotherCatalogWithNotExistingName = anotherClientWithNotExistingName.loadMetalake(METALAKE_NAME).loadCatalog(CATALOG_NAME); } diff --git a/catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/integration/test/CatalogDorisIT.java b/catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/integration/test/CatalogDorisIT.java index d50020c8156..a6059a56e74 100644 --- a/catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/integration/test/CatalogDorisIT.java +++ b/catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/integration/test/CatalogDorisIT.java @@ -47,7 +47,7 @@ import org.apache.gravitino.exceptions.SchemaAlreadyExistsException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.DorisContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.gravitino.rel.Column; @@ -78,13 +78,10 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; import org.testcontainers.shaded.org.awaitility.Awaitility; @Tag("gravitino-docker-test") -@TestInstance(Lifecycle.PER_CLASS) -public class CatalogDorisIT extends AbstractIT { +public class CatalogDorisIT extends BaseIT { private static final String provider = "jdbc-doris"; @@ -129,7 +126,7 @@ public void startup() throws IOException { public void stop() { clearTableAndSchema(); metalake.dropCatalog(catalogName); - AbstractIT.client.dropMetalake(metalakeName); + client.dropMetalake(metalakeName); } @AfterEach @@ -143,12 +140,12 @@ private void clearTableAndSchema() { } private void createMetalake() { - GravitinoMetalake[] gravitinoMetaLakes = AbstractIT.client.listMetalakes(); + GravitinoMetalake[] gravitinoMetaLakes = client.listMetalakes(); assertEquals(0, gravitinoMetaLakes.length); GravitinoMetalake createdMetalake = - AbstractIT.client.createMetalake(metalakeName, "comment", Collections.emptyMap()); - GravitinoMetalake loadMetalake = AbstractIT.client.loadMetalake(metalakeName); + client.createMetalake(metalakeName, "comment", Collections.emptyMap()); + GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName); assertEquals(createdMetalake, loadMetalake); metalake = loadMetalake; diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java index b2cf571475f..a70b7007050 100644 --- a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java +++ b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java @@ -36,7 +36,7 @@ import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.MySQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.TestDatabaseName; import org.apache.gravitino.rel.Column; @@ -50,7 +50,7 @@ import org.junit.jupiter.api.Test; @Tag("gravitino-docker-test") -public class AuditCatalogMysqlIT extends AbstractIT { +public class AuditCatalogMysqlIT extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); public static final String metalakeName = GravitinoITUtils.genRandomName("audit_mysql_metalake"); private static final String expectUser = System.getProperty("user.name"); @@ -62,11 +62,11 @@ public class AuditCatalogMysqlIT extends AbstractIT { private static GravitinoMetalake metalake; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.AUTHENTICATORS.getKey(), AuthenticatorType.SIMPLE.name().toLowerCase()); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); containerSuite.startMySQLContainer(TestDatabaseName.MYSQL_AUDIT_CATALOG_MYSQL_IT); MYSQL_CONTAINER = containerSuite.getMySQLContainer(); @@ -76,10 +76,10 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void stopIntegrationTest() throws IOException, InterruptedException { + public void stopIntegrationTest() throws IOException, InterruptedException { client.dropMetalake(metalakeName); mysqlService.close(); - AbstractIT.stopIntegrationTest(); + super.stopIntegrationTest(); } @Test @@ -165,7 +165,7 @@ private static Catalog createCatalog(String catalogName) throws SQLException { catalogName, Catalog.Type.RELATIONAL, provider, "comment", catalogProperties); } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java index 71003720522..fe43538e3b5 100644 --- a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java +++ b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java @@ -50,7 +50,7 @@ import org.apache.gravitino.exceptions.SchemaAlreadyExistsException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.MySQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.gravitino.integration.test.util.TestDatabaseName; @@ -84,7 +84,7 @@ @Tag("gravitino-docker-test") @TestInstance(Lifecycle.PER_CLASS) -public class CatalogMysqlIT extends AbstractIT { +public class CatalogMysqlIT extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); private static final String provider = "jdbc-mysql"; diff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java index 5b7ec298f89..c657b04ca74 100644 --- a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java +++ b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java @@ -49,7 +49,7 @@ import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.PGImageName; import org.apache.gravitino.integration.test.container.PostgreSQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.gravitino.integration.test.util.TestDatabaseName; @@ -82,7 +82,7 @@ @Tag("gravitino-docker-test") @TestInstance(Lifecycle.PER_CLASS) -public class CatalogPostgreSqlIT extends AbstractIT { +public class CatalogPostgreSqlIT extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); public static final PGImageName DEFAULT_POSTGRES_IMAGE = PGImageName.VERSION_13; diff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java index 8dc4466eff5..be16ee79485 100644 --- a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java +++ b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java @@ -32,7 +32,7 @@ import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.MySQLContainer; import org.apache.gravitino.integration.test.container.PostgreSQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.TestDatabaseName; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.types.Types; @@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test; @Tag("gravitino-docker-test") -public class TestMultipleJDBCLoad extends AbstractIT { +public class TestMultipleJDBCLoad extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); private static final TestDatabaseName TEST_DB_NAME = TestDatabaseName.PG_TEST_PG_CATALOG_MULTIPLE_JDBC_LOAD; @@ -52,7 +52,7 @@ public class TestMultipleJDBCLoad extends AbstractIT { private static PostgreSQLContainer postgreSQLContainer; @BeforeAll - public static void startup() throws IOException { + public void startup() throws IOException { containerSuite.startMySQLContainer(TEST_DB_NAME); mySQLContainer = containerSuite.getMySQLContainer(); containerSuite.startPostgreSQLContainer(TEST_DB_NAME); diff --git a/catalogs/catalog-kafka/src/test/java/org/apache/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java b/catalogs/catalog-kafka/src/test/java/org/apache/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java index b73a6c1b86a..baa83619873 100644 --- a/catalogs/catalog-kafka/src/test/java/org/apache/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java +++ b/catalogs/catalog-kafka/src/test/java/org/apache/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java @@ -41,7 +41,7 @@ import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.exceptions.NoSuchCatalogException; import org.apache.gravitino.integration.test.container.ContainerSuite; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.messaging.Topic; import org.apache.gravitino.messaging.TopicChange; @@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class CatalogKafkaIT extends AbstractIT { +public class CatalogKafkaIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CatalogKafkaIT.class); private static final ContainerSuite CONTAINER_SUITE = ContainerSuite.getInstance(); private static final String METALAKE_NAME = @@ -87,7 +87,7 @@ public class CatalogKafkaIT extends AbstractIT { private static AdminClient adminClient; @BeforeAll - public static void startUp() throws ExecutionException, InterruptedException { + public void startUp() throws ExecutionException, InterruptedException { CONTAINER_SUITE.startKafkaContainer(); kafkaBootstrapServers = String.format( @@ -112,7 +112,7 @@ public static void startUp() throws ExecutionException, InterruptedException { } @AfterAll - public static void shutdown() { + public void shutdown() { Catalog catalog = metalake.loadCatalog(CATALOG_NAME); Arrays.stream(catalog.asSchemas().listSchemas()) .filter(ident -> !ident.equals("default")) @@ -552,7 +552,7 @@ private TopicDescription getTopicDesc(String topicName) .get(); } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake createdMetalake = client.createMetalake(METALAKE_NAME, "comment", Collections.emptyMap()); GravitinoMetalake loadMetalake = client.loadMetalake(METALAKE_NAME); diff --git a/catalogs/catalog-lakehouse-hudi/src/test/java/org/apache/gravitino/catalog/lakehouse/hudi/integration/test/HudiCatalogHMSIT.java b/catalogs/catalog-lakehouse-hudi/src/test/java/org/apache/gravitino/catalog/lakehouse/hudi/integration/test/HudiCatalogHMSIT.java index 034670fcfed..a3d07125f3b 100644 --- a/catalogs/catalog-lakehouse-hudi/src/test/java/org/apache/gravitino/catalog/lakehouse/hudi/integration/test/HudiCatalogHMSIT.java +++ b/catalogs/catalog-lakehouse-hudi/src/test/java/org/apache/gravitino/catalog/lakehouse/hudi/integration/test/HudiCatalogHMSIT.java @@ -37,7 +37,7 @@ import org.apache.gravitino.dto.rel.ColumnDTO; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; import org.apache.gravitino.rel.TableCatalog; @@ -56,7 +56,7 @@ import org.junit.jupiter.api.Test; @Tag("gravitino-docker-test") -public class HudiCatalogHMSIT extends AbstractIT { +public class HudiCatalogHMSIT extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); private static String hmsURI; @@ -72,7 +72,7 @@ public class HudiCatalogHMSIT extends AbstractIT { private static final String MOR_TABLE = RandomNameUtils.genRandomName("hudi_mor_table"); @BeforeAll - public static void prepare() { + public void prepare() { containerSuite.startHiveContainer(); hmsURI = String.format( diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java index 4a829b3bc9c..1c60e04b4c9 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java @@ -59,7 +59,7 @@ import org.apache.gravitino.iceberg.common.IcebergConfig; import org.apache.gravitino.iceberg.common.utils.IcebergCatalogUtil; import org.apache.gravitino.integration.test.container.ContainerSuite; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -94,7 +94,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public abstract class CatalogIcebergBaseIT extends AbstractIT { +public abstract class CatalogIcebergBaseIT extends BaseIT { protected static final ContainerSuite containerSuite = ContainerSuite.getInstance(); protected String WAREHOUSE; @@ -125,7 +125,7 @@ public abstract class CatalogIcebergBaseIT extends AbstractIT { @BeforeAll public void startup() throws Exception { ignoreIcebergRestService = false; - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); containerSuite.startHiveContainer(); initIcebergCatalogProperties(); createMetalake(); @@ -144,12 +144,12 @@ public void stop() throws Exception { if (spark != null) { spark.close(); } - AbstractIT.stopIntegrationTest(); + super.stopIntegrationTest(); } } @AfterEach - private void resetSchema() { + public void resetSchema() { clearTableAndSchema(); createSchema(); } @@ -158,10 +158,10 @@ private void resetSchema() { // if startIntegrationTest() is auto invoked by Junit. So here we override // startIntegrationTest() to disable the auto invoke by junit. @BeforeAll - public static void startIntegrationTest() {} + public void startIntegrationTest() {} @AfterAll - public static void stopIntegrationTest() {} + public void stopIntegrationTest() {} protected abstract void initIcebergCatalogProperties(); diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergHiveIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergHiveIT.java index 5ec9de6dd98..a9ca1a1108c 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergHiveIT.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergHiveIT.java @@ -28,10 +28,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class CatalogIcebergHiveIT extends CatalogIcebergBaseIT { @Override diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergKerberosHiveIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergKerberosHiveIT.java index ebd8737f550..0f899463203 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergKerberosHiveIT.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergKerberosHiveIT.java @@ -43,7 +43,7 @@ import org.apache.gravitino.iceberg.common.IcebergConfig; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.TableChange; @@ -63,7 +63,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class CatalogIcebergKerberosHiveIT extends AbstractIT { +public class CatalogIcebergKerberosHiveIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CatalogIcebergKerberosHiveIT.class); @@ -101,7 +101,7 @@ public class CatalogIcebergKerberosHiveIT extends AbstractIT { private static final String HIVE_COL_NAME3 = "col3"; @BeforeAll - public static void startIntegrationTest() { + public void startIntegrationTest() { containerSuite.startKerberosHiveContainer(); kerberosHiveContainer = containerSuite.getKerberosHiveContainer(); @@ -129,14 +129,14 @@ public static void startIntegrationTest() { ignoreIcebergRestService = false; // Start Gravitino server - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } catch (Exception e) { throw new RuntimeException(e); } } @AfterAll - public static void stop() { + public void stop() { // Reset the UGI UserGroupInformation.reset(); @@ -145,7 +145,7 @@ public static void stop() { System.clearProperty("java.security.krb5.conf"); System.clearProperty("sun.security.krb5.debug"); - AbstractIT.client = null; + client = null; } private static void prepareKerberosConfig() throws Exception { @@ -201,14 +201,12 @@ private static void refreshKerberosConfig() { } } - private static void addKerberosConfig() { - AbstractIT.customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); + private void addKerberosConfig() { + customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); + customConfigs.put("gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); + customConfigs.put("gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); + customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); + customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); } @Test diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergRestIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergRestIT.java index 808da5cfc1f..f992821a8d4 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergRestIT.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergRestIT.java @@ -24,10 +24,8 @@ import org.apache.gravitino.integration.test.container.HiveContainer; import org.apache.gravitino.server.web.JettyServerConfig; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.TestInstance; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class CatalogIcebergRestIT extends CatalogIcebergBaseIT { @Override diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java index 5f78ab57377..4b1edae827c 100644 --- a/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java +++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java @@ -34,7 +34,7 @@ import org.apache.gravitino.iceberg.common.IcebergConfig; import org.apache.gravitino.integration.test.container.MySQLContainer; import org.apache.gravitino.integration.test.container.PostgreSQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.TestDatabaseName; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.types.Types; @@ -45,7 +45,7 @@ import org.junit.jupiter.api.Test; @Tag("gravitino-docker-test") -public class TestMultipleJDBCLoad extends AbstractIT { +public class TestMultipleJDBCLoad extends BaseIT { private static final TestDatabaseName TEST_DB_NAME = TestDatabaseName.PG_TEST_ICEBERG_CATALOG_MULTIPLE_JDBC_LOAD; @@ -55,7 +55,7 @@ public class TestMultipleJDBCLoad extends AbstractIT { public static final String DEFAULT_POSTGRES_IMAGE = "postgres:13"; @BeforeAll - public static void startup() throws IOException { + public void startup() throws IOException { containerSuite.startMySQLContainer(TEST_DB_NAME); mySQLContainer = containerSuite.getMySQLContainer(); containerSuite.startPostgreSQLContainer(TEST_DB_NAME); diff --git a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonBaseIT.java b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonBaseIT.java index 5cb04e6a3f5..45cd2464058 100644 --- a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonBaseIT.java +++ b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonBaseIT.java @@ -52,7 +52,7 @@ import org.apache.gravitino.exceptions.TableAlreadyExistsException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.MySQLContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.integration.test.util.TestDatabaseName; import org.apache.gravitino.rel.Column; @@ -86,7 +86,7 @@ import org.junit.jupiter.api.Test; import org.junit.platform.commons.util.StringUtils; -public abstract class CatalogPaimonBaseIT extends AbstractIT { +public abstract class CatalogPaimonBaseIT extends BaseIT { protected static final ContainerSuite containerSuite = ContainerSuite.getInstance(); protected static final TestDatabaseName TEST_DB_NAME = diff --git a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonFileSystemIT.java b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonFileSystemIT.java index 5c7c67acc27..442fe331b84 100644 --- a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonFileSystemIT.java +++ b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonFileSystemIT.java @@ -30,10 +30,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class CatalogPaimonFileSystemIT extends CatalogPaimonBaseIT { @Override diff --git a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonKerberosFilesystemIT.java b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonKerberosFilesystemIT.java index f9f31ceadfe..cf00cf5ffdb 100644 --- a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonKerberosFilesystemIT.java +++ b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonKerberosFilesystemIT.java @@ -40,7 +40,7 @@ import org.apache.gravitino.client.KerberosTokenProvider; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -56,13 +56,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class CatalogPaimonKerberosFilesystemIT extends AbstractIT { +public class CatalogPaimonKerberosFilesystemIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CatalogPaimonKerberosFilesystemIT.class); @@ -99,7 +97,7 @@ public class CatalogPaimonKerberosFilesystemIT extends AbstractIT { private static final String FILESYSTEM_COL_NAME3 = "col3"; @BeforeAll - public static void startIntegrationTest() { + public void startIntegrationTest() { containerSuite.startKerberosHiveContainer(); kerberosHiveContainer = containerSuite.getKerberosHiveContainer(); @@ -122,14 +120,14 @@ public static void startIntegrationTest() { addKerberosConfig(); // Start Gravitino server - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } catch (Exception e) { throw new RuntimeException(e); } } @AfterAll - public static void stop() { + public void stop() { // Reset the UGI UserGroupInformation.reset(); @@ -138,7 +136,7 @@ public static void stop() { System.clearProperty("java.security.krb5.conf"); System.clearProperty("sun.security.krb5.debug"); - AbstractIT.client = null; + client = null; } private static void prepareKerberosConfig() throws Exception { @@ -194,14 +192,12 @@ private static void refreshKerberosConfig() { } } - private static void addKerberosConfig() { - AbstractIT.customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); - AbstractIT.customConfigs.put( - "gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); - AbstractIT.customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); + private void addKerberosConfig() { + customConfigs.put(Configs.AUTHENTICATORS.getKey(), "kerberos"); + customConfigs.put("gravitino.authenticator.kerberos.principal", GRAVITINO_SERVER_PRINCIPAL); + customConfigs.put("gravitino.authenticator.kerberos.keytab", TMP_DIR + GRAVITINO_SERVER_KEYTAB); + customConfigs.put(SDK_KERBEROS_KEYTAB_KEY, TMP_DIR + GRAVITINO_CLIENT_KEYTAB); + customConfigs.put(SDK_KERBEROS_PRINCIPAL_KEY, GRAVITINO_CLIENT_PRINCIPAL); } @Test diff --git a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonS3IT.java b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonS3IT.java index f3786b391ef..a435de4b573 100644 --- a/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonS3IT.java +++ b/catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonS3IT.java @@ -29,12 +29,10 @@ import org.apache.gravitino.storage.S3Properties; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.TestInstance; import org.testcontainers.containers.Container; import org.testcontainers.shaded.org.awaitility.Awaitility; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class CatalogPaimonS3IT extends CatalogPaimonBaseIT { private static final String S3_BUCKET_NAME = "my-test-bucket"; diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/AuditIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/AuditIT.java index a7ab09033d9..c438e0fca1e 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/AuditIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/AuditIT.java @@ -26,22 +26,22 @@ import org.apache.gravitino.MetalakeChange; import org.apache.gravitino.auth.AuthenticatorType; import org.apache.gravitino.client.GravitinoMetalake; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.utils.RandomNameUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class AuditIT extends AbstractIT { +public class AuditIT extends BaseIT { private static final String expectUser = System.getProperty("user.name"); @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.AUTHENTICATORS.getKey(), AuthenticatorType.SIMPLE.name().toLowerCase()); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } @Test diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java index 35783173b5c..609a1b4612f 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/CatalogIT.java @@ -31,7 +31,7 @@ import org.apache.gravitino.exceptions.CatalogAlreadyExistsException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class CatalogIT extends AbstractIT { +public class CatalogIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CatalogIT.class); @@ -56,7 +56,7 @@ public class CatalogIT extends AbstractIT { private static String hmsUri; @BeforeAll - public static void startUp() { + public void startUp() { containerSuite.startHiveContainer(); hmsUri = String.format( @@ -70,7 +70,7 @@ public static void startUp() { } @AfterAll - public static void tearDown() { + public void tearDown() { client.dropMetalake(metalakeName); if (client != null) { diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/MetalakeIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/MetalakeIT.java index 7f6ed7f236e..fb9efd2ca7f 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/MetalakeIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/MetalakeIT.java @@ -33,7 +33,7 @@ import org.apache.gravitino.exceptions.IllegalNameIdentifierException; import org.apache.gravitino.exceptions.MetalakeAlreadyExistsException; import org.apache.gravitino.exceptions.NoSuchMetalakeException; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.utils.RandomNameUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -43,7 +43,7 @@ import org.junit.jupiter.api.TestMethodOrder; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class MetalakeIT extends AbstractIT { +public class MetalakeIT extends BaseIT { public static String metalakeNameA = RandomNameUtils.genRandomName("metalakeA"); public static String metalakeNameB = RandomNameUtils.genRandomName("metalakeB"); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java index 8d91c369d81..0cb1f9313bf 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/TagIT.java @@ -35,7 +35,7 @@ import org.apache.gravitino.exceptions.TagAlreadyExistsException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -49,7 +49,7 @@ import org.junit.jupiter.api.Test; @org.junit.jupiter.api.Tag("gravitino-docker-test") -public class TagIT extends AbstractIT { +public class TagIT extends BaseIT { private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -61,7 +61,7 @@ public class TagIT extends AbstractIT { private static Table table; @BeforeAll - public static void setUp() { + public void setUp() { containerSuite.startHiveContainer(); String hmsUri = String.format( @@ -108,7 +108,7 @@ public static void setUp() { } @AfterAll - public static void tearDown() { + public void tearDown() { relationalCatalog.asTableCatalog().dropTable(NameIdentifier.of(schema.name(), table.name())); relationalCatalog.asSchemas().dropSchema(schema.name(), true); metalake.dropCatalog(relationalCatalog.name()); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/VersionOperationsIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/VersionOperationsIT.java index 9a50d4dd293..61b1869cc4d 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/VersionOperationsIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/VersionOperationsIT.java @@ -19,12 +19,12 @@ package org.apache.gravitino.client.integration.test; import org.apache.gravitino.client.GravitinoVersion; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.ITUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class VersionOperationsIT extends AbstractIT { +public class VersionOperationsIT extends BaseIT { @Test public void testGetVersion() { GravitinoVersion gravitinoVersion = client.serverVersion(); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java index e62cebcfdbd..685f465970b 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java @@ -49,24 +49,24 @@ import org.apache.gravitino.exceptions.NoSuchUserException; import org.apache.gravitino.exceptions.UserAlreadyExistsException; import org.apache.gravitino.file.Fileset; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.utils.RandomNameUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class AccessControlIT extends AbstractIT { +public class AccessControlIT extends BaseIT { private static String metalakeName = RandomNameUtils.genRandomName("metalake"); private static GravitinoMetalake metalake; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(true)); configs.put(Configs.SERVICE_ADMINS.getKey(), AuthConstants.ANONYMOUS_USER); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); metalake = client.createMetalake(metalakeName, "metalake comment", Collections.emptyMap()); Catalog filesetCatalog = diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlNotAllowIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlNotAllowIT.java index 22986458ba6..a6817b27418 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlNotAllowIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlNotAllowIT.java @@ -26,12 +26,12 @@ import org.apache.gravitino.authorization.Privileges; import org.apache.gravitino.authorization.SecurableObjects; import org.apache.gravitino.client.GravitinoMetalake; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.utils.RandomNameUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class AccessControlNotAllowIT extends AbstractIT { +public class AccessControlNotAllowIT extends BaseIT { public static String metalakeTestName = RandomNameUtils.genRandomName("test"); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/CheckCurrentUserIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/CheckCurrentUserIT.java index 2f80a310231..0b87eab8dbe 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/CheckCurrentUserIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/CheckCurrentUserIT.java @@ -38,7 +38,7 @@ import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; import org.apache.gravitino.integration.test.container.KafkaContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.types.Types; import org.apache.gravitino.server.web.JettyServerConfig; @@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class CheckCurrentUserIT extends AbstractIT { +public class CheckCurrentUserIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(CheckCurrentUserIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -63,12 +63,12 @@ public class CheckCurrentUserIT extends AbstractIT { private static String metalakeName = RandomNameUtils.genRandomName("metalake"); @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(true)); configs.put(Configs.SERVICE_ADMINS.getKey(), AuthConstants.ANONYMOUS_USER); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); containerSuite.startHiveContainer(); hmsUri = @@ -96,7 +96,7 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void tearDown() { + public void tearDown() { if (client != null) { client.dropMetalake(metalakeName); client.close(); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/KerberosOperationsIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/KerberosOperationsIT.java index 3ba68e1803c..2cf313925ce 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/KerberosOperationsIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/KerberosOperationsIT.java @@ -34,7 +34,7 @@ import org.apache.gravitino.client.GravitinoAdminClient; import org.apache.gravitino.client.GravitinoVersion; import org.apache.gravitino.client.KerberosTokenProvider; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.hadoop.minikdc.KerberosSecurityTestcase; import org.junit.jupiter.api.AfterAll; @@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test; import org.testcontainers.shaded.com.google.common.util.concurrent.Uninterruptibles; -public class KerberosOperationsIT extends AbstractIT { +public class KerberosOperationsIT extends BaseIT { private static final KerberosSecurityTestcase kdc = new KerberosSecurityTestcase() { @@ -64,8 +64,12 @@ public void createMiniKdcConf() { private static final String clientPrincipal = "client@EXAMPLE.COM"; + public void setGravitinoAdminClient(GravitinoAdminClient client) { + this.client = client; + } + @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { kdc.startMiniKdc(); initKeyTab(); @@ -78,7 +82,7 @@ public static void startIntegrationTest() throws Exception { registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); client = GravitinoAdminClient.builder(serverUri) @@ -91,8 +95,8 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void stopIntegrationTest() throws IOException, InterruptedException { - AbstractIT.stopIntegrationTest(); + public void stopIntegrationTest() throws IOException, InterruptedException { + super.stopIntegrationTest(); kdc.stopMiniKdc(); } diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/MultiAuthOperationsIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/MultiAuthOperationsIT.java index f0df92b6303..01628d95d19 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/MultiAuthOperationsIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/MultiAuthOperationsIT.java @@ -41,7 +41,7 @@ import org.apache.gravitino.client.GravitinoAdminClient; import org.apache.gravitino.client.GravitinoVersion; import org.apache.gravitino.client.KerberosTokenProvider; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.gravitino.integration.test.util.OAuthMockDataProvider; import org.apache.gravitino.server.authentication.OAuthConfig; @@ -55,7 +55,7 @@ import org.testcontainers.shaded.com.google.common.util.concurrent.Uninterruptibles; @Tag("gravitino-docker-test") -public class MultiAuthOperationsIT extends AbstractIT { +public class MultiAuthOperationsIT extends BaseIT { private static final KerberosSecurityTestcase kdc = new KerberosSecurityTestcase() { @Override @@ -73,7 +73,7 @@ public void createMiniKdcConf() { private static GravitinoAdminClient kerberosClient; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put( Configs.AUTHENTICATORS.getKey(), @@ -86,7 +86,7 @@ public static void startIntegrationTest() throws Exception { configKerberos(configs); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); oauthClient = GravitinoAdminClient.builder(serverUri) @@ -107,8 +107,8 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void stopIntegrationTest() throws IOException, InterruptedException { - AbstractIT.stopIntegrationTest(); + public void stopIntegrationTest() throws IOException, InterruptedException { + super.stopIntegrationTest(); kdc.stopMiniKdc(); } @@ -121,7 +121,10 @@ public void testMultiAuthenticationSuccess() throws Exception { final String gitCommitId = readGitCommitIdFromGitFile(); Assertions.assertEquals(gitCommitId, gravitinoVersion1.gitCommit()); } - new KerberosOperationsIT().testAuthenticationApi(); + + KerberosOperationsIT kerberosOperationsIT = new KerberosOperationsIT(); + kerberosOperationsIT.setGravitinoAdminClient(client); + kerberosOperationsIT.testAuthenticationApi(); GravitinoVersion gravitinoVersion2 = kerberosClient.serverVersion(); Assertions.assertEquals(System.getenv("PROJECT_VERSION"), gravitinoVersion2.version()); diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OAuth2OperationsIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OAuth2OperationsIT.java index d78586fa0a0..b8e769547d8 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OAuth2OperationsIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OAuth2OperationsIT.java @@ -30,7 +30,7 @@ import org.apache.gravitino.Configs; import org.apache.gravitino.auth.AuthenticatorType; import org.apache.gravitino.client.GravitinoVersion; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.ITUtils; import org.apache.gravitino.integration.test.util.OAuthMockDataProvider; import org.apache.gravitino.server.authentication.OAuthConfig; @@ -38,7 +38,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class OAuth2OperationsIT extends AbstractIT { +public class OAuth2OperationsIT extends BaseIT { private static final KeyPair keyPair = Keys.keyPairFor(SignatureAlgorithm.RS256); private static final String publicKey = @@ -49,7 +49,7 @@ public class OAuth2OperationsIT extends AbstractIT { @SuppressWarnings("JavaUtilDate") @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); token = Jwts.builder() @@ -68,7 +68,7 @@ public static void startIntegrationTest() throws Exception { registerCustomConfigs(configs); OAuthMockDataProvider mockDataProvider = OAuthMockDataProvider.getInstance(); mockDataProvider.setTokenData(token.getBytes(StandardCharsets.UTF_8)); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); } @Test diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OwnerIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OwnerIT.java index ca9d96b8b10..877d891737f 100644 --- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OwnerIT.java +++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/OwnerIT.java @@ -39,7 +39,7 @@ import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; import org.apache.gravitino.integration.test.container.KafkaContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.types.Types; import org.apache.gravitino.utils.RandomNameUtils; @@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class OwnerIT extends AbstractIT { +public class OwnerIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(OwnerIT.class); @@ -61,12 +61,12 @@ public class OwnerIT extends AbstractIT { private static String kafkaBootstrapServers; @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { Map configs = Maps.newHashMap(); configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(true)); configs.put(Configs.SERVICE_ADMINS.getKey(), AuthConstants.ANONYMOUS_USER); registerCustomConfigs(configs); - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); containerSuite.startHiveContainer(); hmsUri = @@ -84,7 +84,7 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void tearDown() { + public void tearDown() { if (client != null) { client.close(); client = null; diff --git a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemIT.java b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemIT.java index fae41264cbb..9b6334e092b 100644 --- a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemIT.java +++ b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemIT.java @@ -37,7 +37,7 @@ import org.apache.gravitino.file.Fileset; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; @@ -54,7 +54,7 @@ import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") -public class GravitinoVirtualFileSystemIT extends AbstractIT { +public class GravitinoVirtualFileSystemIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(GravitinoVirtualFileSystemIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); private static final String metalakeName = GravitinoITUtils.genRandomName("gvfs_it_metalake"); @@ -64,7 +64,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT { private static Configuration conf = new Configuration(); @BeforeAll - public static void startUp() { + public void startUp() { containerSuite.startHiveContainer(); Assertions.assertFalse(client.metalakeExists(metalakeName)); metalake = client.createMetalake(metalakeName, "metalake comment", Collections.emptyMap()); @@ -87,7 +87,7 @@ public static void startUp() { } @AfterAll - public static void tearDown() throws IOException { + public void tearDown() throws IOException { Catalog catalog = metalake.loadCatalog(catalogName); catalog.asSchemas().dropSchema(schemaName, true); metalake.dropCatalog(catalogName); diff --git a/core/src/test/java/org/apache/gravitino/storage/TestEntityStorage.java b/core/src/test/java/org/apache/gravitino/storage/TestEntityStorage.java index e1993828596..6502b6931ea 100644 --- a/core/src/test/java/org/apache/gravitino/storage/TestEntityStorage.java +++ b/core/src/test/java/org/apache/gravitino/storage/TestEntityStorage.java @@ -66,7 +66,7 @@ import org.apache.gravitino.exceptions.NonEmptyEntityException; import org.apache.gravitino.file.Fileset; import org.apache.gravitino.integration.test.container.ContainerSuite; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.meta.AuditInfo; import org.apache.gravitino.meta.BaseMetalake; import org.apache.gravitino.meta.CatalogEntity; @@ -130,6 +130,7 @@ private void init(String type, Config config) { Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_PATH)).thenReturn(DB_DIR); Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L); Mockito.when(config.get(VERSION_RETENTION_COUNT)).thenReturn(1L); + BaseIT baseIT = new BaseIT(); try { if (type.equalsIgnoreCase("h2")) { @@ -146,7 +147,7 @@ private void init(String type, Config config) { SQLExceptionConverterFactory.class, "converter", new H2ExceptionConverter(), true); } else if (type.equalsIgnoreCase("mysql")) { - String mysqlJdbcUrl = AbstractIT.startAndInitMySQLBackend(); + String mysqlJdbcUrl = baseIT.startAndInitMySQLBackend(); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_URL)).thenReturn(mysqlJdbcUrl); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_USER)).thenReturn("root"); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_PASSWORD)).thenReturn("root"); @@ -157,7 +158,7 @@ private void init(String type, Config config) { SQLExceptionConverterFactory.class, "converter", new MySQLExceptionConverter(), true); } else if (type.equalsIgnoreCase("postgresql")) { - String postgreSQLJdbcUrl = AbstractIT.startAndInitPGBackend(); + String postgreSQLJdbcUrl = baseIT.startAndInitPGBackend(); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_URL)).thenReturn(postgreSQLJdbcUrl); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_USER)).thenReturn("root"); Mockito.when(config.get(ENTITY_RELATIONAL_JDBC_BACKEND_PASSWORD)).thenReturn("root"); diff --git a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java index 4d61b3ad489..5ae8847c6c1 100644 --- a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java +++ b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkEnvIT.java @@ -36,14 +36,14 @@ import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOptions; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.hadoop.fs.FileSystem; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class FlinkEnvIT extends AbstractIT { +public abstract class FlinkEnvIT extends BaseIT { private static final Logger LOG = LoggerFactory.getLogger(FlinkEnvIT.class); private static final ContainerSuite CONTAINER_SUITE = ContainerSuite.getInstance(); protected static final String GRAVITINO_METALAKE = "flink"; @@ -61,7 +61,7 @@ public abstract class FlinkEnvIT extends AbstractIT { private static String gravitinoUri = "http://127.0.0.1:8090"; @BeforeAll - static void startUp() { + void startUp() { // Start Gravitino server initGravitinoEnv(); initMetalake(); @@ -82,13 +82,13 @@ protected String flinkByPass(String key) { return PropertiesConverter.FLINK_PROPERTY_PREFIX + key; } - private static void initGravitinoEnv() { + private void initGravitinoEnv() { // Gravitino server is already started by AbstractIT, just construct gravitinoUrl int gravitinoPort = getGravitinoServerPort(); gravitinoUri = String.format("http://127.0.0.1:%d", gravitinoPort); } - private static void initMetalake() { + private void initMetalake() { metalake = client.createMetalake(GRAVITINO_METALAKE, "", Collections.emptyMap()); } diff --git a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/hive/FlinkHiveCatalogIT.java b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/hive/FlinkHiveCatalogIT.java index 0da3820d978..9cdac8be7db 100644 --- a/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/hive/FlinkHiveCatalogIT.java +++ b/flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/hive/FlinkHiveCatalogIT.java @@ -64,10 +64,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class FlinkHiveCatalogIT extends FlinkCommonIT { private static final String DEFAULT_HIVE_CATALOG = "test_flink_hive_schema_catalog"; diff --git a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/AbstractIT.java b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java similarity index 90% rename from integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/AbstractIT.java rename to integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java index ede6b7be28e..e8f688f96ea 100644 --- a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/AbstractIT.java +++ b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/BaseIT.java @@ -58,35 +58,42 @@ import org.apache.gravitino.server.web.JettyServerConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.shaded.org.awaitility.Awaitility; +/** + * BaseIT can be used as a base class for integration tests. It will automatically start a Gravitino + * server and stop it after all tests are finished. + * + *

Another use case is to start a MySQL or PostgreSQL docker instance and create a database for + * testing or just start the Gravitino server manually. + */ @ExtendWith({PrintFuncNameExtension.class, CloseContainerExtension.class}) -public class AbstractIT { +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class BaseIT { protected static final ContainerSuite containerSuite = ContainerSuite.getInstance(); - private static final Logger LOG = LoggerFactory.getLogger(AbstractIT.class); + private static final Logger LOG = LoggerFactory.getLogger(BaseIT.class); private static final Splitter COMMA = Splitter.on(",").omitEmptyStrings().trimResults(); - protected static GravitinoAdminClient client; + protected GravitinoAdminClient client; private static final OAuthMockDataProvider mockDataProvider = OAuthMockDataProvider.getInstance(); protected static final CloseableGroup closer = CloseableGroup.create(); - private static MiniGravitino miniGravitino; + private MiniGravitino miniGravitino; - protected static Config serverConfig; + protected Config serverConfig; - public static String testMode = ""; + public String testMode = ""; - protected static Map customConfigs = new HashMap<>(); + protected Map customConfigs = new HashMap<>(); - protected static boolean ignoreIcebergRestService = true; + protected boolean ignoreIcebergRestService = true; public static final String DOWNLOAD_MYSQL_JDBC_DRIVER_URL = "https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.26/mysql-connector-java-8.0.26.jar"; @@ -94,25 +101,25 @@ public class AbstractIT { public static final String DOWNLOAD_POSTGRESQL_JDBC_DRIVER_URL = "https://jdbc.postgresql.org/download/postgresql-42.7.0.jar"; - private static TestDatabaseName META_DATA; - private static MySQLContainer MYSQL_CONTAINER; - private static PostgreSQLContainer POSTGRESQL_CONTAINER; + private TestDatabaseName META_DATA; + private MySQLContainer MYSQL_CONTAINER; + private PostgreSQLContainer POSTGRESQL_CONTAINER; - protected static String serverUri; + protected String serverUri; - protected static String originConfig; + protected String originConfig; - public static int getGravitinoServerPort() { + public int getGravitinoServerPort() { JettyServerConfig jettyServerConfig = JettyServerConfig.fromConfig(serverConfig, WEBSERVER_CONF_PREFIX); return jettyServerConfig.getHttpPort(); } - public static void registerCustomConfigs(Map configs) { + public void registerCustomConfigs(Map configs) { customConfigs.putAll(configs); } - private static void rewriteGravitinoServerConfig() throws IOException { + private void rewriteGravitinoServerConfig() throws IOException { String gravitinoHome = System.getenv("GRAVITINO_HOME"); Path configPath = Paths.get(gravitinoHome, "conf", GravitinoServer.CONF_FILE); if (originConfig == null) { @@ -129,7 +136,7 @@ private static void rewriteGravitinoServerConfig() throws IOException { ITUtils.rewriteConfigFile(tmpPath.toString(), configPath.toString(), customConfigs); } - private static void recoverGravitinoServerConfig() throws IOException { + private void recoverGravitinoServerConfig() throws IOException { String gravitinoHome = System.getenv("GRAVITINO_HOME"); Path configPath = Paths.get(gravitinoHome, "conf", GravitinoServer.CONF_FILE); @@ -139,7 +146,7 @@ private static void recoverGravitinoServerConfig() throws IOException { } } - protected static void downLoadJDBCDriver() throws IOException { + protected void downLoadJDBCDriver() throws IOException { String gravitinoHome = System.getenv("GRAVITINO_HOME"); if (!ITUtils.EMBEDDED_TEST_MODE.equals(testMode)) { String serverPath = ITUtils.joinPath(gravitinoHome, "libs"); @@ -157,7 +164,7 @@ protected static void downLoadJDBCDriver() throws IOException { } } - public static String startAndInitPGBackend() { + public String startAndInitPGBackend() { META_DATA = PG_JDBC_BACKEND; containerSuite.startPostgreSQLContainer(META_DATA); POSTGRESQL_CONTAINER = containerSuite.getPostgreSQLContainer(); @@ -208,7 +215,7 @@ public static String startAndInitPGBackend() { return pgUrlWithoutSchema; } - public static String startAndInitMySQLBackend() { + public String startAndInitMySQLBackend() { META_DATA = TestDatabaseName.MYSQL_JDBC_BACKEND; containerSuite.startMySQLContainer(META_DATA); MYSQL_CONTAINER = containerSuite.getMySQLContainer(); @@ -248,15 +255,8 @@ public static String startAndInitMySQLBackend() { } } - @ParameterizedTest - @CsvSource({ - "embedded, jdbcBackend", - "embedded, kvBackend", - "deploy, jdbcBackend", - "deploy, kvBackend" - }) @BeforeAll - public static void startIntegrationTest() throws Exception { + public void startIntegrationTest() throws Exception { testMode = System.getProperty(ITUtils.TEST_MODE) == null ? ITUtils.EMBEDDED_TEST_MODE @@ -352,7 +352,7 @@ public static void startIntegrationTest() throws Exception { } @AfterAll - public static void stopIntegrationTest() throws IOException, InterruptedException { + public void stopIntegrationTest() throws IOException, InterruptedException { if (testMode != null && testMode.equals(ITUtils.EMBEDDED_TEST_MODE) && miniGravitino != null) { miniGravitino.stop(); } else { @@ -366,7 +366,7 @@ public static void stopIntegrationTest() throws IOException, InterruptedExceptio LOG.info("Tearing down Gravitino Server"); } - public static GravitinoAdminClient getGravitinoClient() { + public GravitinoAdminClient getGravitinoClient() { return client; } diff --git a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/CloseContainerExtension.java b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/CloseContainerExtension.java index 82d823f0e25..a37a9647009 100644 --- a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/CloseContainerExtension.java +++ b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/util/CloseContainerExtension.java @@ -27,7 +27,7 @@ /** * This is an extension for JUnit 5, which aims to perform certain operations (such as resource * recycling, etc.) after all test executions are completed (regardless of success or failure). You - * can Refer to {@link AbstractIT} for more information. + * can Refer to {@link BaseIT} for more information. */ public class CloseContainerExtension implements BeforeAllCallback { @Override diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java index 30e6ed44b3f..b534a9772f7 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/SparkEnvIT.java @@ -30,7 +30,6 @@ import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; import org.apache.gravitino.server.web.JettyServerConfig; import org.apache.gravitino.spark.connector.GravitinoSparkConfig; import org.apache.gravitino.spark.connector.iceberg.IcebergPropertiesConstants; @@ -84,7 +83,7 @@ void startUp() throws Exception { initIcebergRestServiceEnv(); } // Start Gravitino server - AbstractIT.startIntegrationTest(); + super.startIntegrationTest(); initHdfsFileSystem(); initGravitinoEnv(); initMetalakeAndCatalogs(); @@ -107,7 +106,7 @@ void stop() throws IOException, InterruptedException { if (sparkSession != null) { sparkSession.close(); } - AbstractIT.stopIntegrationTest(); + super.stopIntegrationTest(); } // AbstractIT#startIntegrationTest() is static, so we couldn't update the value of @@ -115,14 +114,14 @@ void stop() throws IOException, InterruptedException { // if startIntegrationTest() is auto invoked by Junit. So here we override // startIntegrationTest() to disable the auto invoke by junit. @BeforeAll - public static void startIntegrationTest() {} + public void startIntegrationTest() {} @AfterAll - public static void stopIntegrationTest() {} + public void stopIntegrationTest() {} private void initMetalakeAndCatalogs() { - AbstractIT.client.createMetalake(metalakeName, "", Collections.emptyMap()); - GravitinoMetalake metalake = AbstractIT.client.loadMetalake(metalakeName); + client.createMetalake(metalakeName, "", Collections.emptyMap()); + GravitinoMetalake metalake = client.loadMetalake(metalakeName); Map properties = getCatalogConfigs(); if (lakeHouseIcebergProvider.equalsIgnoreCase(getProvider())) { properties.put(SPARK_PROPERTY_PREFIX + ICEBERG_CATALOG_CACHE_ENABLED, "true"); @@ -133,7 +132,7 @@ private void initMetalakeAndCatalogs() { private void initGravitinoEnv() { // Gravitino server is already started by AbstractIT, just construct gravitinoUrl - int gravitinoPort = AbstractIT.getGravitinoServerPort(); + int gravitinoPort = getGravitinoServerPort(); gravitinoUri = String.format("http://127.0.0.1:%d", gravitinoPort); icebergRestServiceUri = getIcebergRestServiceUri(); } @@ -173,7 +172,7 @@ private void initIcebergRestServiceEnv() { + "." + IcebergPropertiesConstants.GRAVITINO_ICEBERG_CATALOG_WAREHOUSE, warehouse); - AbstractIT.registerCustomConfigs(icebergRestServiceConfigs); + registerCustomConfigs(icebergRestServiceConfigs); } private void initHdfsFileSystem() { diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java index 5680e2e30c2..c543d82819e 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java @@ -36,12 +36,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class SparkHiveCatalogIT extends SparkCommonIT { @Override diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT.java index 428f680bfb9..344b538cc51 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT.java @@ -22,11 +22,9 @@ import java.util.Map; import org.apache.gravitino.spark.connector.iceberg.IcebergPropertiesConstants; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.TestInstance; /** This class use Apache Iceberg HiveCatalog for backend catalog. */ @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class SparkIcebergCatalogHiveBackendIT extends SparkIcebergCatalogIT { @Override diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT.java index 2e2ad1607c6..a10c82e0e6d 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT.java @@ -22,13 +22,11 @@ import java.util.Map; import org.apache.gravitino.spark.connector.iceberg.IcebergPropertiesConstants; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.TestInstance; /** * This class use Apache Iceberg RESTCatalog for test, and the real backend catalog is HiveCatalog. */ @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class SparkIcebergCatalogRestBackendIT extends SparkIcebergCatalogIT { @Override diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkQueryRunner.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkQueryRunner.java index 982035e8b62..02301b362eb 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkQueryRunner.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkQueryRunner.java @@ -36,7 +36,7 @@ import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.spark.connector.GravitinoSparkConfig; import org.apache.gravitino.spark.connector.iceberg.IcebergPropertiesConstants; import org.apache.gravitino.spark.connector.plugin.GravitinoSparkPlugin; @@ -61,6 +61,7 @@ public class SparkQueryRunner { private Map catalogs = new HashMap<>(); private boolean isGravitinoEnvSetup; private String dataDir; + private BaseIT baseIT; private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -83,6 +84,7 @@ public SparkQueryRunner(SparkTestConfig sparkTestConfig) { } initSparkEnv(); + baseIT = new BaseIT(); catalogs.put(CatalogType.HIVE, HIVE_CATALOG_NAME); catalogs.put(CatalogType.ICEBERG, ICEBERG_CATALOG_NAME); catalogs.put(CatalogType.UNKNOWN, HIVE_CATALOG_NAME); @@ -134,12 +136,12 @@ private void setupGravitinoEnv() throws Exception { HiveContainer.HDFS_DEFAULTFS_PORT); // Start Gravitino server - AbstractIT.startIntegrationTest(); - int gravitinoPort = AbstractIT.getGravitinoServerPort(); + baseIT.stopIntegrationTest(); + int gravitinoPort = baseIT.getGravitinoServerPort(); this.gravitinoUri = String.format("http://127.0.0.1:%d", gravitinoPort); // Init metalake and catalog - GravitinoAdminClient client = AbstractIT.getGravitinoClient(); + GravitinoAdminClient client = baseIT.getGravitinoClient(); client.createMetalake(metalakeName, "", Collections.emptyMap()); GravitinoMetalake metalake = client.loadMetalake(metalakeName); metalake.createCatalog( @@ -177,7 +179,7 @@ private Map getIcebergCatalogConfigs(String hiveMetastoreUri) { } private void closeGravitinoEnv() throws Exception { - AbstractIT.stopIntegrationTest(); + baseIT.stopIntegrationTest(); } private void writeQueryOutput(Path outputFile, List queryOutputs) diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java index dea3dd36ce1..e6d517b8f66 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java @@ -32,7 +32,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +42,6 @@ * -PenableSparkSQLITs */ @Tag("gravitino-docker-test") -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class SparkSQLRegressionTest { private static final Logger LOG = LoggerFactory.getLogger(SparkSQLRegressionTest.class); private static final String SPARK_TEST_CONFIG_FILE = "configFile"; diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java index 05637c0ce39..646f414841b 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java @@ -28,7 +28,7 @@ import java.util.TimeZone; import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.spark.sql.AnalysisException; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; @@ -44,7 +44,7 @@ * *

Referred from spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/SparkTestBase.java */ -public abstract class SparkUtilIT extends AbstractIT { +public abstract class SparkUtilIT extends BaseIT { protected static final String NULL_STRING = "NULL"; protected abstract SparkSession getSparkSession(); diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestConnectorUtil.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestConnectorUtil.java index 36c8ef7770b..32250340867 100644 --- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestConnectorUtil.java +++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestConnectorUtil.java @@ -23,9 +23,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestConnectorUtil { @Test diff --git a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoConnectorIT.java b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoConnectorIT.java index 589821e6faa..162fd10b746 100644 --- a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoConnectorIT.java +++ b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoConnectorIT.java @@ -37,7 +37,7 @@ import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.HiveContainer; import org.apache.gravitino.integration.test.container.TrinoContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.integration.test.util.GravitinoITUtils; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.Table; @@ -68,7 +68,7 @@ @Disabled @Deprecated @Tag("gravitino-docker-test") -public class TrinoConnectorIT extends AbstractIT { +public class TrinoConnectorIT extends BaseIT { public static final Logger LOG = LoggerFactory.getLogger(TrinoConnectorIT.class); private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); @@ -88,7 +88,7 @@ public class TrinoConnectorIT extends AbstractIT { private static Catalog catalog; @BeforeAll - public static void startDockerContainer() throws TException, InterruptedException { + public void startDockerContainer() throws TException, InterruptedException { String trinoConfDir = System.getenv("TRINO_CONF_DIR"); containerSuite.startHiveContainer(); @@ -1379,7 +1379,7 @@ void testDropCatalogAndCreateAgain() { } } - private static void createMetalake() { + private void createMetalake() { GravitinoMetalake[] gravitinoMetalakes = client.listMetalakes(); Assertions.assertEquals(0, gravitinoMetalakes.length); diff --git a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryIT.java b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryIT.java index c737e762fab..3ec2b6d46e7 100644 --- a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryIT.java +++ b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryIT.java @@ -46,10 +46,12 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Tag("gravitino-docker-test") +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TrinoQueryIT extends TrinoQueryITBase { private static final Logger LOG = LoggerFactory.getLogger(TrinoQueryIT.class); @@ -67,6 +69,8 @@ public class TrinoQueryIT extends TrinoQueryITBase { static Set ciTestsets = new HashSet<>(); + static TrinoQueryITBase trinoQueryITBase; + static { testsetsDir = TrinoQueryIT.class.getClassLoader().getResource("trino-ci-testset").getPath(); testsetsDir = ITUtils.joinPath(testsetsDir, "testsets"); @@ -79,8 +83,9 @@ public class TrinoQueryIT extends TrinoQueryITBase { } @BeforeAll - public static void setup() throws Exception { - TrinoQueryITBase.setup(); + public void setup() throws Exception { + trinoQueryITBase = new TrinoQueryITBase(); + trinoQueryITBase.setup(); cleanupTestEnv(); queryParams.put("mysql_uri", mysqlUri); diff --git a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryITBase.java b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryITBase.java index 1c8e7559fd4..14558237786 100644 --- a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryITBase.java +++ b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryITBase.java @@ -35,7 +35,7 @@ import org.apache.gravitino.exceptions.RESTException; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.TrinoITContainers; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.apache.gravitino.rel.TableCatalog; import org.junit.jupiter.api.Assertions; import org.slf4j.Logger; @@ -68,14 +68,17 @@ public class TrinoQueryITBase { protected static final String metalakeName = "test"; protected static GravitinoMetalake metalake; - private static void setEnv() throws Exception { + private static BaseIT baseIT; + + private void setEnv() throws Exception { + baseIT = new BaseIT(); if (autoStart) { - AbstractIT.startIntegrationTest(); - gravitinoClient = AbstractIT.getGravitinoClient(); - gravitinoUri = String.format("http://127.0.0.1:%d", AbstractIT.getGravitinoServerPort()); + baseIT.startIntegrationTest(); + gravitinoClient = baseIT.getGravitinoClient(); + gravitinoUri = String.format("http://127.0.0.1:%d", baseIT.getGravitinoServerPort()); trinoITContainers = ContainerSuite.getTrinoITContainers(); - trinoITContainers.launch(AbstractIT.getGravitinoServerPort()); + trinoITContainers.launch(baseIT.getGravitinoServerPort()); trinoUri = trinoITContainers.getTrinoUri(); hiveMetastoreUri = trinoITContainers.getHiveMetastoreUri(); @@ -84,16 +87,16 @@ private static void setEnv() throws Exception { postgresqlUri = trinoITContainers.getPostgresqlUri(); } else if (autoStartGravitino) { - AbstractIT.startIntegrationTest(); - gravitinoClient = AbstractIT.getGravitinoClient(); - gravitinoUri = String.format("http://127.0.0.1:%d", AbstractIT.getGravitinoServerPort()); + baseIT.startIntegrationTest(); + gravitinoClient = baseIT.getGravitinoClient(); + gravitinoUri = String.format("http://127.0.0.1:%d", baseIT.getGravitinoServerPort()); } else { gravitinoClient = GravitinoAdminClient.builder(gravitinoUri).build(); } } - public static void setup() throws Exception { + public void setup() throws Exception { if (started) { return; } @@ -113,7 +116,7 @@ public static void cleanup() { try { if (autoStart) { if (trinoITContainers != null) trinoITContainers.shutdown(); - AbstractIT.stopIntegrationTest(); + baseIT.stopIntegrationTest(); } } catch (Exception e) { LOG.error("Error in cleanup", e); diff --git a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryTestTool.java b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryTestTool.java index 676bcb62898..dee82d6a3c0 100644 --- a/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryTestTool.java +++ b/trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoQueryTestTool.java @@ -217,8 +217,8 @@ public static void main(String[] args) throws Exception { TrinoQueryITBase.autoStart = autoStart; TrinoQueryITBase.autoStartGravitino = autoStartGravitino; - TrinoQueryIT.setup(); TrinoQueryIT testerRunner = new TrinoQueryIT(); + testerRunner.setup(); if (commandLine.hasOption("gen_output")) { String catalogFileName = "catalog_" + catalog + "_prepare.sql"; diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java index 1fcd754b9fc..cac8e5a38cc 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java @@ -29,10 +29,9 @@ import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.DorisContainer; -import org.apache.gravitino.integration.test.util.AbstractIT; import org.apache.gravitino.integration.test.web.ui.pages.CatalogsPage; import org.apache.gravitino.integration.test.web.ui.pages.MetalakePage; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.expressions.NamedReference; import org.apache.gravitino.rel.expressions.distributions.Distributions; @@ -48,9 +47,9 @@ @Tag("gravitino-docker-test") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class CatalogsPageDorisTest extends AbstractWebIT { - MetalakePage metalakePage = new MetalakePage(); - CatalogsPage catalogsPage = new CatalogsPage(); +public class CatalogsPageDorisTest extends BaseWebIT { + private MetalakePage metalakePage; + private CatalogsPage catalogsPage; private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); protected static GravitinoAdminClient gravitinoClient; @@ -77,9 +76,9 @@ public class CatalogsPageDorisTest extends AbstractWebIT { private static final String PROPERTIES_VALUE1 = "val1"; @BeforeAll - public static void before() throws Exception { - gravitinoClient = AbstractIT.getGravitinoClient(); - gravitinoUri = String.format("http://127.0.0.1:%d", AbstractIT.getGravitinoServerPort()); + public void before() throws Exception { + gravitinoClient = getGravitinoClient(); + gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort()); containerSuite.startDorisContainer(); @@ -89,6 +88,9 @@ public static void before() throws Exception { containerSuite.getDorisContainer().getContainerIpAddress(), DorisContainer.FE_MYSQL_PORT); LOG.info("Doris jdbc url: {}", dorisJdbcConnectionUri); + + metalakePage = new MetalakePage(driver); + catalogsPage = new CatalogsPage(driver); } /** diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java index 5eea61c7a35..8af7277e20e 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java @@ -27,10 +27,9 @@ import org.apache.gravitino.client.GravitinoAdminClient; import org.apache.gravitino.client.GravitinoMetalake; import org.apache.gravitino.integration.test.container.ContainerSuite; -import org.apache.gravitino.integration.test.util.AbstractIT; import org.apache.gravitino.integration.test.web.ui.pages.CatalogsPage; import org.apache.gravitino.integration.test.web.ui.pages.MetalakePage; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.MethodOrderer; @@ -41,9 +40,9 @@ @Tag("gravitino-docker-test") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class CatalogsPageKafkaTest extends AbstractWebIT { - MetalakePage metalakePage = new MetalakePage(); - CatalogsPage catalogsPage = new CatalogsPage(); +public class CatalogsPageKafkaTest extends BaseWebIT { + private MetalakePage metalakePage; + private CatalogsPage catalogsPage; private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); protected static GravitinoAdminClient gravitinoClient; @@ -63,15 +62,18 @@ public class CatalogsPageKafkaTest extends AbstractWebIT { public static final int DEFAULT_BROKER_PORT = 9092; @BeforeAll - public static void before() throws Exception { - gravitinoClient = AbstractIT.getGravitinoClient(); + public void before() throws Exception { + gravitinoClient = getGravitinoClient(); - gravitinoUri = String.format("http://127.0.0.1:%d", AbstractIT.getGravitinoServerPort()); + gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort()); containerSuite.startKafkaContainer(); String address = containerSuite.getKafkaContainer().getContainerIpAddress(); kafkaUri = String.format("%s:%d", address, DEFAULT_BROKER_PORT); + + metalakePage = new MetalakePage(driver); + catalogsPage = new CatalogsPage(driver); } /** diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageTest.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageTest.java index 75d385ece8e..31e50e65725 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageTest.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/CatalogsPageTest.java @@ -33,10 +33,9 @@ import org.apache.gravitino.file.Fileset; import org.apache.gravitino.integration.test.container.ContainerSuite; import org.apache.gravitino.integration.test.container.TrinoITContainers; -import org.apache.gravitino.integration.test.util.AbstractIT; import org.apache.gravitino.integration.test.web.ui.pages.CatalogsPage; import org.apache.gravitino.integration.test.web.ui.pages.MetalakePage; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.apache.gravitino.rel.Column; import org.apache.gravitino.rel.expressions.NamedReference; import org.apache.gravitino.rel.expressions.distributions.Distribution; @@ -60,9 +59,9 @@ @Tag("gravitino-docker-test") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class CatalogsPageTest extends AbstractWebIT { - MetalakePage metalakePage = new MetalakePage(); - CatalogsPage catalogsPage = new CatalogsPage(); +public class CatalogsPageTest extends BaseWebIT { + private MetalakePage metalakePage; + private CatalogsPage catalogsPage; protected static TrinoITContainers trinoITContainers; protected static GravitinoAdminClient gravitinoClient; @@ -115,18 +114,21 @@ public class CatalogsPageTest extends AbstractWebIT { private static String defaultBaseLocation; @BeforeAll - public static void before() throws Exception { - gravitinoClient = AbstractIT.getGravitinoClient(); + public void before() throws Exception { + gravitinoClient = getGravitinoClient(); - gravitinoUri = String.format("http://127.0.0.1:%d", AbstractIT.getGravitinoServerPort()); + gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort()); trinoITContainers = ContainerSuite.getTrinoITContainers(); - trinoITContainers.launch(AbstractIT.getGravitinoServerPort()); + trinoITContainers.launch(getGravitinoServerPort()); hiveMetastoreUri = trinoITContainers.getHiveMetastoreUri(); hdfsUri = trinoITContainers.getHdfsUri(); mysqlUri = trinoITContainers.getMysqlUri(); postgresqlUri = trinoITContainers.getPostgresqlUri(); + + metalakePage = new MetalakePage(driver); + catalogsPage = new CatalogsPage(driver); } /** diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/MetalakePageTest.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/MetalakePageTest.java index d288543cc1f..fc27dc08b48 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/MetalakePageTest.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/MetalakePageTest.java @@ -19,8 +19,9 @@ package org.apache.gravitino.integration.test.web.ui; import org.apache.gravitino.integration.test.web.ui.pages.MetalakePage; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -29,7 +30,7 @@ @DisabledIfSystemProperty(named = "testMode", matches = "embedded") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class MetalakePageTest extends AbstractWebIT { +public class MetalakePageTest extends BaseWebIT { private static final String WEB_TITLE = "Gravitino"; private static final String METALAKE_NAME = "metalake_name"; private static final String EDITED_METALAKE_NAME = METALAKE_NAME + "_edited"; @@ -38,7 +39,12 @@ public class MetalakePageTest extends AbstractWebIT { private static final String FOOTER_LINK_LICENSE = "https://github.com/apache/gravitino/blob/main/LICENSE"; private static final String FOOTER_LINK_SUPPORT = "https://github.com/apache/gravitino/issues"; - MetalakePage metalakePage = new MetalakePage(); + private MetalakePage metalakePage; + + @BeforeAll + void init() { + metalakePage = new MetalakePage(driver); + } // Create a metalake by name, set the default comment and properties. public void createMetalakeAction(String name) throws InterruptedException { diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java index 1df4f41729c..222cbd22714 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/CatalogsPage.java @@ -26,17 +26,18 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -public class CatalogsPage extends AbstractWebIT { +public class CatalogsPage extends BaseWebIT { @FindBy(xpath = "//*[@data-refer='back-home-btn']") public WebElement backHomeBtn; @@ -115,7 +116,8 @@ public class CatalogsPage extends AbstractWebIT { @FindBy(xpath = "//ul[@aria-labelledby='select-catalog-type']") public WebElement catalogTypeList; - public CatalogsPage() { + public CatalogsPage(WebDriver driver) { + this.driver = driver; PageFactory.initElements(driver, this); } diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/MetalakePage.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/MetalakePage.java index 95153495b1c..419589f5ad9 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/MetalakePage.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/pages/MetalakePage.java @@ -22,17 +22,18 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import org.apache.gravitino.integration.test.web.ui.utils.AbstractWebIT; +import org.apache.gravitino.integration.test.web.ui.utils.BaseWebIT; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -public class MetalakePage extends AbstractWebIT { +public class MetalakePage extends BaseWebIT { private static final String PAGE_TITLE = "Metalakes"; @FindBy( @@ -109,7 +110,8 @@ public class MetalakePage extends AbstractWebIT { @FindBy(xpath = "//a[@data-refer='footer-link-support']") public WebElement footerLinkSupport; - public MetalakePage() { + public MetalakePage(WebDriver driver) { + this.driver = driver; PageFactory.initElements(driver, this); } diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/AbstractWebIT.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/BaseWebIT.java similarity index 92% rename from web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/AbstractWebIT.java rename to web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/BaseWebIT.java index 9b3b6945d4f..8ccc5132621 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/AbstractWebIT.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/BaseWebIT.java @@ -21,7 +21,7 @@ import com.google.common.base.Function; import java.time.Duration; import java.time.temporal.ChronoUnit; -import org.apache.gravitino.integration.test.util.AbstractIT; +import org.apache.gravitino.integration.test.util.BaseIT; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -41,13 +41,13 @@ import org.slf4j.LoggerFactory; // AbstractWebIT provides a WebDriver instance for WEB UI tests. -public class AbstractWebIT extends AbstractIT { - protected static final Logger LOG = LoggerFactory.getLogger(AbstractWebIT.class); - protected static WebDriver driver; +public class BaseWebIT extends BaseIT { + protected static final Logger LOG = LoggerFactory.getLogger(BaseWebIT.class); + protected WebDriver driver; // https://www.selenium.dev/documentation/webdriver/waits/#implicit-waits protected static final long MAX_IMPLICIT_WAIT = 30; - protected static final long MAX_TIMEOUT = 20; + protected static final long MAX_TIMEOUT = 60; protected static final long EACH_TEST_SLEEP_MILLIS = 1_000; protected static final long ACTION_SLEEP_MILLIS = 1_000; @@ -113,12 +113,12 @@ public void beforeEachTest() { } @BeforeAll - public static void startUp() { + public void startUp() { driver = WebDriverManager.getWebDriver(getGravitinoServerPort()); } @AfterAll - public static void tearDown() { + public void tearDown() { driver.quit(); } } diff --git a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/WebDriverManager.java b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/WebDriverManager.java index ab241ddf429..22cd9c53a1d 100644 --- a/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/WebDriverManager.java +++ b/web/integration-test/src/test/java/org/apache/gravitino/integration/test/web/ui/utils/WebDriverManager.java @@ -36,12 +36,12 @@ public static WebDriver getWebDriver(int port) { WebDriverProvider provide = new ChromeWebDriverProvider(); WebDriver driver = generateWebDriver(provide); - driver.manage().timeouts().implicitlyWait(AbstractWebIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS); + driver.manage().timeouts().implicitlyWait(BaseWebIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS); driver.get(url); // wait for webpage load compiled. try { - (new WebDriverWait(driver, AbstractWebIT.MAX_TIMEOUT)) + (new WebDriverWait(driver, BaseWebIT.MAX_TIMEOUT)) .until( d -> { String gravitinoVersion = d.findElement(By.id("gravitino_version")).getText();