From 1e03f765d298c519e221cad6419b327acf4a855d Mon Sep 17 00:00:00 2001 From: Martin Traverso Date: Wed, 25 Oct 2023 15:28:10 -0700 Subject: [PATCH] Migrate tests to JUnit --- .../trino/hdfs/s3/TestTrinoS3FileSystem.java | 6 +- .../cassandra/TestCassandraTypeMapping.java | 13 +++-- .../clickhouse/BaseClickHouseTypeMapping.java | 9 ++- .../hive/TestHiveFileSystemAbfsAccessKey.java | 30 +++++----- .../hive/TestHiveFileSystemAbfsOAuth.java | 45 ++++++-------- .../plugin/hive/TestHiveFileSystemAdl.java | 31 +++++----- .../plugin/hive/TestHiveFileSystemS3.java | 31 +++++----- .../plugin/hive/TestHiveFileSystemWasb.java | 27 ++++----- .../hive/AbstractTestHiveFileSystem.java | 13 +++-- .../plugin/hive/AbstractTestHiveRoles.java | 30 ++++++++-- .../hive/TestBackgroundHiveSplitLoader.java | 26 ++++----- .../plugin/hive/TestHive3OnDataLake.java | 9 ++- .../io/trino/plugin/hive/TestHiveRoles.java | 3 - .../plugin/hive/TestLegacyHiveRoles.java | 3 - .../hive/TestOrcPageSourceMemoryTracking.java | 13 +++-- .../plugin/hive/TestOriginalFilesUtils.java | 2 +- .../plugin/hive/TestParquetPageSkipping.java | 2 +- ...astoreMetadataQueriesAccessOperations.java | 58 +++++++++++++++++-- 18 files changed, 209 insertions(+), 142 deletions(-) diff --git a/lib/trino-hdfs/src/test/java/io/trino/hdfs/s3/TestTrinoS3FileSystem.java b/lib/trino-hdfs/src/test/java/io/trino/hdfs/s3/TestTrinoS3FileSystem.java index 6a4b672978a5..dcba948b242f 100644 --- a/lib/trino-hdfs/src/test/java/io/trino/hdfs/s3/TestTrinoS3FileSystem.java +++ b/lib/trino-hdfs/src/test/java/io/trino/hdfs/s3/TestTrinoS3FileSystem.java @@ -51,8 +51,7 @@ import org.apache.hadoop.fs.LocatedFileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RemoteIterator; -import org.testng.SkipException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import javax.crypto.spec.SecretKeySpec; @@ -111,6 +110,7 @@ import static java.nio.file.Files.createTempFile; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assumptions.abort; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; @@ -477,7 +477,7 @@ public void testCreateWithStagingDirectorySymlink() Files.createSymbolicLink(link, staging); } catch (UnsupportedOperationException e) { - throw new SkipException("Filesystem does not support symlinks", e); + abort("Filesystem does not support symlinks"); } try (TrinoS3FileSystem fs = new TrinoS3FileSystem()) { diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java index 827775a58872..6894781f8369 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java @@ -28,9 +28,10 @@ import io.trino.testing.datatype.SqlDataTypeTest; import io.trino.testing.sql.TrinoSqlExecutor; import org.intellij.lang.annotations.Language; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.time.LocalDate; import java.time.LocalDateTime; @@ -67,7 +68,9 @@ import static java.lang.String.format; import static java.time.ZoneOffset.UTC; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +@TestInstance(PER_CLASS) public class TestCassandraTypeMapping extends AbstractTestQueryFramework { @@ -98,7 +101,7 @@ public class TestCassandraTypeMapping private CassandraServer server; private CassandraSession session; - @BeforeClass + @BeforeAll public void setUp() { checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); @@ -146,7 +149,7 @@ protected QueryRunner createQueryRunner() ImmutableList.of()); } - @AfterClass(alwaysRun = true) + @AfterAll public void cleanUp() { session.close(); diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java index 3dec9001ed10..12a08e8dc9c2 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java @@ -27,8 +27,9 @@ import io.trino.testing.sql.SqlExecutor; import io.trino.testing.sql.TestTable; import io.trino.testing.sql.TrinoSqlExecutor; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.time.LocalDate; import java.time.LocalDateTime; @@ -56,7 +57,9 @@ import static io.trino.type.IpAddressType.IPADDRESS; import static java.lang.String.format; import static java.time.ZoneOffset.UTC; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +@TestInstance(PER_CLASS) public abstract class BaseClickHouseTypeMapping extends AbstractTestQueryFramework { @@ -70,7 +73,7 @@ public abstract class BaseClickHouseTypeMapping protected TestingClickHouseServer clickhouseServer; - @BeforeClass + @BeforeAll public void setUp() { checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsAccessKey.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsAccessKey.java index cf9de14fb450..539fc8ffcc47 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsAccessKey.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsAccessKey.java @@ -14,28 +14,28 @@ package io.trino.plugin.hive; import io.trino.hdfs.azure.HiveAzureConfig; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; + +@TestInstance(PER_CLASS) public class TestHiveFileSystemAbfsAccessKey extends AbstractTestHiveFileSystemAbfs { private String accessKey; - @Parameters({ - "hive.hadoop2.metastoreHost", - "hive.hadoop2.metastorePort", - "hive.hadoop2.databaseName", - "hive.hadoop2.abfs.container", - "hive.hadoop2.abfs.account", - "hive.hadoop2.abfs.accessKey", - "hive.hadoop2.abfs.testDirectory", - }) - @BeforeClass - public void setup(String host, int port, String databaseName, String container, String account, String accessKey, String testDirectory) + @BeforeAll + public void setup() { - this.accessKey = checkParameter(accessKey, "access key"); - super.setup(host, port, databaseName, container, account, testDirectory); + this.accessKey = checkParameter(System.getProperty("hive.hadoop2.abfs.accessKey"), "access key"); + super.setup( + System.getProperty("hive.hadoop2.metastoreHost"), + Integer.getInteger("hive.hadoop2.metastorePort"), + System.getProperty("hive.hadoop2.databaseName"), + System.getProperty("hive.hadoop2.abfs.container"), + System.getProperty("hive.hadoop2.abfs.account"), + System.getProperty("hive.hadoop2.abfs.testDirectory")); } @Override diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsOAuth.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsOAuth.java index e2e5cf2c61da..36adb3a9db31 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsOAuth.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAbfsOAuth.java @@ -14,9 +14,12 @@ package io.trino.plugin.hive; import io.trino.hdfs.azure.HiveAzureConfig; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; + +@TestInstance(PER_CLASS) public class TestHiveFileSystemAbfsOAuth extends AbstractTestHiveFileSystemAbfs { @@ -24,33 +27,19 @@ public class TestHiveFileSystemAbfsOAuth private String clientId; private String secret; - @Parameters({ - "hive.hadoop2.metastoreHost", - "hive.hadoop2.metastorePort", - "hive.hadoop2.databaseName", - "test.hive.azure.abfs.container", - "test.hive.azure.abfs.storage-account", - "test.hive.azure.abfs.test-directory", - "test.hive.azure.abfs.oauth.endpoint", - "test.hive.azure.abfs.oauth.client-id", - "test.hive.azure.abfs.oauth.secret", - }) - @BeforeClass - public void setup( - String host, - int port, - String databaseName, - String container, - String account, - String testDirectory, - String clientEndpoint, - String clientId, - String clientSecret) + @BeforeAll + public void setup() { - this.endpoint = checkParameter(clientEndpoint, "endpoint"); - this.clientId = checkParameter(clientId, "client ID"); - this.secret = checkParameter(clientSecret, "secret"); - super.setup(host, port, databaseName, container, account, testDirectory); + this.endpoint = checkParameter(System.getProperty("test.hive.azure.abfs.oauth.endpoint"), "endpoint"); + this.clientId = checkParameter(System.getProperty("test.hive.azure.abfs.oauth.client-id"), "client ID"); + this.secret = checkParameter(System.getProperty("test.hive.azure.abfs.oauth.secret"), "secret"); + super.setup( + System.getProperty("hive.hadoop2.metastoreHost"), + Integer.getInteger("hive.hadoop2.metastorePort"), + System.getProperty("hive.hadoop2.databaseName"), + System.getProperty("test.hive.azure.abfs.container"), + System.getProperty("test.hive.azure.abfs.storage-account"), + System.getProperty("test.hive.azure.abfs.test-directory")); } @Override diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAdl.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAdl.java index b31c64296465..88758304df51 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAdl.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemAdl.java @@ -23,9 +23,9 @@ import io.trino.hdfs.azure.TrinoAzureConfigurationInitializer; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.FileNotFoundException; import java.util.UUID; @@ -33,10 +33,12 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import static org.testng.util.Strings.isNullOrEmpty; +@TestInstance(PER_CLASS) public class TestHiveFileSystemAdl extends AbstractTestHiveFileSystem { @@ -46,19 +48,18 @@ public class TestHiveFileSystemAdl private String refreshUrl; private String testDirectory; - @Parameters({ - "hive.hadoop2.metastoreHost", - "hive.hadoop2.metastorePort", - "hive.hadoop2.databaseName", - "hive.hadoop2.adl.name", - "hive.hadoop2.adl.clientId", - "hive.hadoop2.adl.credential", - "hive.hadoop2.adl.refreshUrl", - "hive.hadoop2.adl.testDirectory", - }) - @BeforeClass - public void setup(String host, int port, String databaseName, String dataLakeName, String clientId, String credential, String refreshUrl, String testDirectory) + @BeforeAll + public void setup() { + String host = System.getProperty("hive.hadoop2.metastoreHost"); + int port = Integer.getInteger("hive.hadoop2.metastorePort"); + String databaseName = System.getProperty("hive.hadoop2.databaseName"); + String dataLakeName = System.getProperty("hive.hadoop2.adl.name"); + String clientId = System.getProperty("hive.hadoop2.adl.clientId"); + String credential = System.getProperty("hive.hadoop2.adl.credential"); + String refreshUrl = System.getProperty("hive.hadoop2.adl.refreshUrl"); + String testDirectory = System.getProperty("hive.hadoop2.adl.testDirectory"); + checkArgument(!isNullOrEmpty(host), "expected non empty host"); checkArgument(!isNullOrEmpty(databaseName), "expected non empty databaseName"); checkArgument(!isNullOrEmpty(dataLakeName), "expected non empty dataLakeName"); diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemS3.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemS3.java index 21d9dda64406..448b085b728d 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemS3.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemS3.java @@ -44,9 +44,9 @@ import io.trino.plugin.hive.metastore.Table; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.util.Arrays; import java.util.List; @@ -59,9 +59,11 @@ import static java.io.InputStream.nullInputStream; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertFalse; import static org.testng.util.Strings.isNullOrEmpty; +@TestInstance(PER_CLASS) public class TestHiveFileSystemS3 extends AbstractTestHiveFileSystem { @@ -72,19 +74,18 @@ public class TestHiveFileSystemS3 private String testDirectory; private AmazonS3 s3Client; - @Parameters({ - "hive.hadoop2.metastoreHost", - "hive.hadoop2.metastorePort", - "hive.hadoop2.databaseName", - "hive.hadoop2.s3.endpoint", - "hive.hadoop2.s3.awsAccessKey", - "hive.hadoop2.s3.awsSecretKey", - "hive.hadoop2.s3.writableBucket", - "hive.hadoop2.s3.testDirectory", - }) - @BeforeClass - public void setup(String host, int port, String databaseName, String s3endpoint, String awsAccessKey, String awsSecretKey, String writableBucket, String testDirectory) + @BeforeAll + public void setup() { + String host = System.getProperty("hive.hadoop2.metastoreHost"); + int port = Integer.getInteger("hive.hadoop2.metastorePort"); + String databaseName = System.getProperty("hive.hadoop2.databaseName"); + String s3endpoint = System.getProperty("hive.hadoop2.s3.endpoint"); + String awsAccessKey = System.getProperty("hive.hadoop2.s3.awsAccessKey"); + String awsSecretKey = System.getProperty("hive.hadoop2.s3.awsSecretKey"); + String writableBucket = System.getProperty("hive.hadoop2.s3.writableBucket"); + String testDirectory = System.getProperty("hive.hadoop2.s3.testDirectory"); + checkArgument(!isNullOrEmpty(host), "Expected non empty host"); checkArgument(!isNullOrEmpty(databaseName), "Expected non empty databaseName"); checkArgument(!isNullOrEmpty(awsAccessKey), "Expected non empty awsAccessKey"); diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemWasb.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemWasb.java index cab2e698f4c9..955675b7d1d5 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemWasb.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHiveFileSystemWasb.java @@ -22,13 +22,15 @@ import io.trino.hdfs.azure.HiveAzureConfig; import io.trino.hdfs.azure.TrinoAzureConfigurationInitializer; import org.apache.hadoop.fs.Path; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.util.Strings.isNullOrEmpty; +@TestInstance(PER_CLASS) public class TestHiveFileSystemWasb extends AbstractTestHiveFileSystem { @@ -37,18 +39,17 @@ public class TestHiveFileSystemWasb private String accessKey; private String testDirectory; - @Parameters({ - "hive.hadoop2.metastoreHost", - "hive.hadoop2.metastorePort", - "hive.hadoop2.databaseName", - "hive.hadoop2.wasb.container", - "hive.hadoop2.wasb.account", - "hive.hadoop2.wasb.accessKey", - "hive.hadoop2.wasb.testDirectory", - }) - @BeforeClass - public void setup(String host, int port, String databaseName, String container, String account, String accessKey, String testDirectory) + @BeforeAll + public void setup() { + String host = System.getProperty("hive.hadoop2.metastoreHost"); + int port = Integer.getInteger("hive.hadoop2.metastorePort"); + String databaseName = System.getProperty("hive.hadoop2.databaseName"); + String container = System.getProperty("hive.hadoop2.wasb.container"); + String account = System.getProperty("hive.hadoop2.wasb.account"); + String accessKey = System.getProperty("hive.hadoop2.wasb.accessKey"); + String testDirectory = System.getProperty("hive.hadoop2.wasb.testDirectory"); + checkArgument(!isNullOrEmpty(host), "expected non empty host"); checkArgument(!isNullOrEmpty(databaseName), "expected non empty databaseName"); checkArgument(!isNullOrEmpty(container), "expected non empty container"); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystem.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystem.java index fb35286e3f27..64893b857cfb 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystem.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystem.java @@ -79,9 +79,10 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.BufferedReader; import java.io.IOException; @@ -133,10 +134,12 @@ import static java.util.concurrent.Executors.newCachedThreadPool; import static java.util.concurrent.Executors.newScheduledThreadPool; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +@TestInstance(PER_CLASS) public abstract class AbstractTestHiveFileSystem { protected static final HdfsContext TESTING_CONTEXT = new HdfsContext(ConnectorIdentity.ofUser("test")); @@ -161,14 +164,14 @@ public abstract class AbstractTestHiveFileSystem private HiveConfig config; private ScheduledExecutorService heartbeatService; - @BeforeClass + @BeforeAll public void setUp() { executor = newCachedThreadPool(daemonThreadsNamed("hive-%s")); heartbeatService = newScheduledThreadPool(1); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() { if (executor != null) { diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveRoles.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveRoles.java index 0c850856b80b..c19e3b7fe5d6 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveRoles.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/AbstractTestHiveRoles.java @@ -22,8 +22,8 @@ import io.trino.testing.AbstractTestQueryFramework; import io.trino.testing.MaterializedResult; import io.trino.testing.QueryRunner; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; import java.util.List; import java.util.Optional; @@ -36,9 +36,10 @@ import static io.trino.spi.type.VarcharType.createUnboundedVarcharType; import static io.trino.testing.QueryAssertions.assertContains; import static io.trino.testing.QueryAssertions.assertEqualsIgnoreOrder; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; import static org.testng.Assert.assertEquals; -@Test(singleThreaded = true) +@Execution(SAME_THREAD) abstract class AbstractTestHiveRoles extends AbstractTestQueryFramework { @@ -58,8 +59,7 @@ protected QueryRunner createQueryRunner() .build(); } - @AfterMethod(alwaysRun = true) - public void afterMethod() + private void cleanup() { for (String role : listRoles()) { executeFromAdmin(dropRoleSql(role)); @@ -72,6 +72,7 @@ public void testCreateRole() executeFromAdmin(createRoleSql("role1")); assertEquals(listRoles(), ImmutableSet.of("role1", "admin")); assertEquals(listRoles(), ImmutableSet.of("role1", "admin")); + cleanup(); } @Test @@ -79,12 +80,14 @@ public void testCreateDuplicateRole() { executeFromAdmin(createRoleSql("duplicate_role")); assertQueryFails(createAdminSession(), createRoleSql("duplicate_role"), ".*?Role 'duplicate_role' already exists"); + cleanup(); } @Test public void testCreateRoleWithAdminOption() { assertQueryFails(createAdminSession(), "CREATE ROLE role1 WITH ADMIN admin" + optionalCatalogDeclaration(), ".*?Hive Connector does not support WITH ADMIN statement"); + cleanup(); } @Test @@ -94,12 +97,14 @@ public void testCreateReservedRole() assertQueryFails(createAdminSession(), createRoleSql("default"), "Role name cannot be one of the reserved roles: \\[all, default, none\\]"); assertQueryFails(createAdminSession(), createRoleSql("none"), "Role name cannot be one of the reserved roles: \\[all, default, none\\]"); assertQueryFails(createAdminSession(), createRoleSql("None"), "Role name cannot be one of the reserved roles: \\[all, default, none\\]"); + cleanup(); } @Test public void testCreateRoleByNonAdminUser() { assertQueryFails(createUserSession("non_admin_user"), createRoleSql("role1"), "Access Denied: Cannot create role role1"); + cleanup(); } @Test @@ -109,6 +114,7 @@ public void testDropRole() assertEquals(listRoles(), ImmutableSet.of("role1", "admin")); executeFromAdmin(dropRoleSql("role1")); assertEquals(listRoles(), ImmutableSet.of("admin")); + cleanup(); } @Test @@ -147,6 +153,7 @@ public void testGrantRoleToUser() executeFromAdmin(createRoleSql("role1")); executeFromAdmin(grantRoleToUserSql("role1", "user")); assertContains(listApplicableRoles("user"), applicableRoles("user", "USER", "role1", "NO")); + cleanup(); } @Test @@ -159,6 +166,7 @@ public void testGrantRoleToRole() assertContains(listApplicableRoles("user"), applicableRoles( "user", "USER", "role1", "NO", "role1", "ROLE", "role2", "NO")); + cleanup(); } @Test @@ -171,6 +179,7 @@ public void testGrantRoleWithAdminOption() assertContains(listApplicableRoles("user"), applicableRoles( "user", "USER", "role1", "YES", "role1", "ROLE", "role2", "YES")); + cleanup(); } @Test @@ -189,6 +198,7 @@ public void testGrantRoleMultipleTimes() assertContains(listApplicableRoles("user"), applicableRoles( "user", "USER", "role1", "YES", "role1", "ROLE", "role2", "YES")); + cleanup(); } @Test @@ -201,6 +211,7 @@ public void testGrantNonExistingRole() assertQueryFails( grantRoleToRoleSql("grant_revoke_role_existing_1", "grant_revoke_role_existing_2"), ".*?Role 'grant_revoke_role_existing_2' does not exist in catalog '.*'"); + cleanup(); } @Test @@ -212,6 +223,7 @@ public void testRevokeRoleFromUser() executeFromAdmin(revokeRoleFromUserSql("role1", "user")); assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles("user", "USER", "public", "NO")); + cleanup(); } @Test @@ -229,6 +241,7 @@ public void testRevokeRoleFromRole() assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles( "user", "USER", "public", "NO", "user", "USER", "role1", "NO")); + cleanup(); } @Test @@ -240,6 +253,7 @@ public void testDropGrantedRole() executeFromAdmin(dropRoleSql("role1")); assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles("user", "USER", "public", "NO")); + cleanup(); } @Test @@ -258,6 +272,7 @@ public void testRevokeTransitiveRoleFromUser() executeFromAdmin(revokeRoleFromUserSql("role1", "user")); assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles("user", "USER", "public", "NO")); + cleanup(); } @Test @@ -278,6 +293,7 @@ public void testRevokeTransitiveRoleFromRole() assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles( "user", "USER", "public", "NO", "user", "USER", "role1", "NO")); + cleanup(); } @Test @@ -298,6 +314,7 @@ public void testDropTransitiveRole() assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles( "user", "USER", "public", "NO", "user", "USER", "role1", "NO")); + cleanup(); } @Test @@ -316,6 +333,7 @@ public void testRevokeAdminOption() assertContains(listApplicableRoles("user"), applicableRoles( "user", "USER", "role1", "NO", "role1", "ROLE", "role2", "NO")); + cleanup(); } @Test @@ -342,6 +360,7 @@ public void testRevokeRoleMultipleTimes() executeFromAdmin(revokeRoleFromRoleSql("role2", "role1")); executeFromAdmin(revokeRoleFromRoleSql("role2", "role1")); assertEqualsIgnoreOrder(listApplicableRoles("user"), applicableRoles("user", "USER", "public", "NO")); + cleanup(); } @Test @@ -459,6 +478,7 @@ public void testSetRole() executeFromAdmin(dropRoleSql("set_role_2")); executeFromAdmin(dropRoleSql("set_role_3")); executeFromAdmin(dropRoleSql("set_role_4")); + cleanup(); } private Set listRoles() diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestBackgroundHiveSplitLoader.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestBackgroundHiveSplitLoader.java index 87a28bcb831f..17b31225c66e 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestBackgroundHiveSplitLoader.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestBackgroundHiveSplitLoader.java @@ -62,9 +62,10 @@ import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.ql.io.SymlinkTextInputFormat; import org.apache.hadoop.util.Progressable; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.Timeout; import java.io.File; import java.io.IOException; @@ -129,10 +130,12 @@ import static org.apache.hadoop.hive.serde.serdeConstants.SERIALIZATION_LIB; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +@TestInstance(PER_CLASS) public class TestBackgroundHiveSplitLoader { private static final int BUCKET_COUNT = 2; @@ -163,19 +166,12 @@ public class TestBackgroundHiveSplitLoader private static final Table SIMPLE_TABLE = table(ImmutableList.of(), Optional.empty(), ImmutableMap.of()); private static final Table PARTITIONED_TABLE = table(PARTITION_COLUMNS, BUCKET_PROPERTY, ImmutableMap.of()); - private ExecutorService executor; + private final ExecutorService executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s")); - @BeforeClass - public void setUp() - { - executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s")); - } - - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() { executor.shutdownNow(); - executor = null; } @Test @@ -313,7 +309,8 @@ public void testNoHangIfPartitionIsOffline() .hasMessage("OFFLINE"); } - @Test(timeOut = 30_000) + @Test + @Timeout(30) public void testIncompleteDynamicFilterTimeout() throws Exception { @@ -446,7 +443,8 @@ public void testGetAttemptId() assertFalse(hasAttemptId("base_00000_00")); } - @Test(timeOut = 60_000) + @Test + @Timeout(60) public void testPropagateException() { testPropagateException(false, 1); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java index aaac5c676802..54bf554e3d7c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHive3OnDataLake.java @@ -32,8 +32,9 @@ import io.trino.testing.AbstractTestQueryFramework; import io.trino.testing.QueryRunner; import io.trino.testing.minio.MinioClient; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -63,7 +64,9 @@ import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +@TestInstance(PER_CLASS) public class TestHive3OnDataLake extends AbstractTestQueryFramework { @@ -105,7 +108,7 @@ protected QueryRunner createQueryRunner() .build(); } - @BeforeClass + @BeforeAll public void setUp() { computeActual(format( diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveRoles.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveRoles.java index cedbdccdec17..c24d3425b969 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveRoles.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveRoles.java @@ -13,9 +13,6 @@ */ package io.trino.plugin.hive; -import org.testng.annotations.Test; - -@Test(singleThreaded = true) public class TestHiveRoles extends AbstractTestHiveRoles { diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestLegacyHiveRoles.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestLegacyHiveRoles.java index c1a1e265c154..13c1678e367b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestLegacyHiveRoles.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestLegacyHiveRoles.java @@ -13,9 +13,6 @@ */ package io.trino.plugin.hive; -import org.testng.annotations.Test; - -@Test(singleThreaded = true) public class TestLegacyHiveRoles extends AbstractTestHiveRoles { diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcPageSourceMemoryTracking.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcPageSourceMemoryTracking.java index 67234855a006..54e956e311db 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcPageSourceMemoryTracking.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOrcPageSourceMemoryTracking.java @@ -71,9 +71,10 @@ import org.apache.hadoop.io.compress.CompressionCodecFactory; import org.apache.hadoop.mapred.FileSplit; import org.apache.hadoop.mapred.JobConf; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.File; import java.lang.reflect.Constructor; @@ -125,12 +126,14 @@ import static org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.COMPRESS_CODEC; import static org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.COMPRESS_TYPE; import static org.joda.time.DateTimeZone.UTC; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +@TestInstance(PER_CLASS) public class TestOrcPageSourceMemoryTracking { private static final String ORC_RECORD_WRITER = OrcOutputFormat.class.getName() + "$OrcRecordWriter"; @@ -152,7 +155,7 @@ public class TestOrcPageSourceMemoryTracking private File tempFile; private TestPreparer testPreparer; - @BeforeClass + @BeforeAll public void setUp() throws Exception { @@ -161,7 +164,7 @@ public void setUp() testPreparer = new TestPreparer(tempFile.getAbsolutePath()); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() { tempFile.delete(); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOriginalFilesUtils.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOriginalFilesUtils.java index bdef3926f484..8e10003d0e33 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOriginalFilesUtils.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestOriginalFilesUtils.java @@ -16,7 +16,7 @@ import io.trino.filesystem.Location; import io.trino.orc.OrcReaderOptions; import io.trino.plugin.hive.orc.OriginalFilesUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestParquetPageSkipping.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestParquetPageSkipping.java index d06519d20ee0..0ffa7cd64f7f 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestParquetPageSkipping.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestParquetPageSkipping.java @@ -27,7 +27,7 @@ import io.trino.testing.MaterializedResultWithQueryId; import io.trino.testing.QueryRunner; import org.intellij.lang.annotations.Language; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.net.URISyntaxException; diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHiveMetastoreMetadataQueriesAccessOperations.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHiveMetastoreMetadataQueriesAccessOperations.java index 227270a9bfc5..4bbae5d0f9d4 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHiveMetastoreMetadataQueriesAccessOperations.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHiveMetastoreMetadataQueriesAccessOperations.java @@ -30,8 +30,8 @@ import io.trino.testing.DistributedQueryRunner; import io.trino.testing.QueryRunner; import org.intellij.lang.annotations.Language; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; import java.util.List; import java.util.Optional; @@ -48,8 +48,9 @@ import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE; import static io.trino.plugin.hive.metastore.StorageFormat.fromHiveStorageFormat; import static io.trino.testing.TestingSession.testSessionBuilder; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -@Test(singleThreaded = true) // metastore invocation counters shares mutable state so can't be run from many threads simultaneously +@Execution(SAME_THREAD) public class TestHiveMetastoreMetadataQueriesAccessOperations extends AbstractTestQueryFramework { @@ -82,8 +83,7 @@ protected QueryRunner createQueryRunner() return queryRunner; } - @BeforeMethod - public void resetMetastoreSetup() + private void resetMetastoreSetup() { mockMetastore.setAllTablesViewsImplemented(false); } @@ -91,6 +91,8 @@ public void resetMetastoreSetup() @Test public void testSelectSchemasWithoutPredicate() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.schemata", ImmutableMultiset.of(GET_ALL_DATABASES)); assertMetastoreInvocations("SELECT * FROM system.jdbc.schemas", ImmutableMultiset.of(GET_ALL_DATABASES)); } @@ -98,6 +100,8 @@ public void testSelectSchemasWithoutPredicate() @Test public void testSelectSchemasWithFilterByInformationSchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.schemata WHERE schema_name = 'information_schema'", ImmutableMultiset.of(GET_ALL_DATABASES)); assertMetastoreInvocations("SELECT * FROM system.jdbc.schemas WHERE table_schem = 'information_schema'", ImmutableMultiset.of(GET_ALL_DATABASES)); } @@ -105,6 +109,8 @@ public void testSelectSchemasWithFilterByInformationSchema() @Test public void testSelectSchemasWithLikeOverSchemaName() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.schemata WHERE schema_name LIKE 'test%'", ImmutableMultiset.of(GET_ALL_DATABASES)); assertMetastoreInvocations("SELECT * FROM system.jdbc.schemas WHERE table_schem LIKE 'test%'", ImmutableMultiset.of(GET_ALL_DATABASES)); } @@ -112,6 +118,8 @@ public void testSelectSchemasWithLikeOverSchemaName() @Test public void testSelectTablesWithoutPredicate() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); Multiset tables = ImmutableMultiset.builder() .add(GET_ALL_TABLES) @@ -133,6 +141,8 @@ public void testSelectTablesWithoutPredicate() @Test public void testSelectTablesWithFilterByInformationSchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.tables WHERE table_schema = 'information_schema'", ImmutableMultiset.of()); assertMetastoreInvocations("SELECT * FROM system.jdbc.tables WHERE table_schem = 'information_schema'", ImmutableMultiset.of()); } @@ -140,6 +150,8 @@ public void testSelectTablesWithFilterByInformationSchema() @Test public void testSelectTablesWithFilterBySchema() { + resetMetastoreSetup(); + assertMetastoreInvocations( "SELECT * FROM information_schema.tables WHERE table_schema = 'test_schema_0'", ImmutableMultiset.builder() @@ -157,6 +169,8 @@ public void testSelectTablesWithFilterBySchema() @Test public void testSelectTablesWithLikeOverSchema() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.tables WHERE table_schema LIKE 'test%'", @@ -185,6 +199,8 @@ public void testSelectTablesWithLikeOverSchema() @Test public void testSelectTablesWithFilterByTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.tables WHERE table_name = 'test_table_0'", @@ -217,6 +233,8 @@ public void testSelectTablesWithFilterByTableName() @Test public void testSelectTablesWithLikeOverTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.tables WHERE table_name LIKE 'test%'", @@ -245,6 +263,8 @@ public void testSelectTablesWithLikeOverTableName() @Test public void testSelectViewsWithoutPredicate() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations("SELECT * FROM information_schema.views", ImmutableMultiset.of(GET_ALL_VIEWS)); assertMetastoreInvocations( @@ -273,6 +293,8 @@ public void testSelectViewsWithoutPredicate() @Test public void testSelectViewsWithFilterByInformationSchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.views WHERE table_schema = 'information_schema'", ImmutableMultiset.of()); assertMetastoreInvocations("SELECT * FROM system.jdbc.tables WHERE table_type = 'VIEW' AND table_schem = 'information_schema'", ImmutableMultiset.of()); } @@ -280,6 +302,8 @@ public void testSelectViewsWithFilterByInformationSchema() @Test public void testSelectViewsWithFilterBySchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.views WHERE table_schema = 'test_schema_0'", ImmutableMultiset.of(GET_ALL_VIEWS_FROM_DATABASE)); assertMetastoreInvocations("SELECT * FROM system.jdbc.tables WHERE table_type = 'VIEW' AND table_schem = 'test_schema_0'", ImmutableMultiset.builder() @@ -291,6 +315,8 @@ public void testSelectViewsWithFilterBySchema() @Test public void testSelectViewsWithLikeOverSchema() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.views WHERE table_schema LIKE 'test%'", @@ -324,6 +350,8 @@ public void testSelectViewsWithLikeOverSchema() @Test public void testSelectViewsWithFilterByTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.views WHERE table_name = 'test_table_0'", @@ -357,6 +385,8 @@ public void testSelectViewsWithFilterByTableName() @Test public void testSelectViewsWithLikeOverTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.views WHERE table_name LIKE 'test%'", @@ -390,6 +420,8 @@ public void testSelectViewsWithLikeOverTableName() @Test public void testSelectColumnsWithoutPredicate() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); ImmutableMultiset tables = ImmutableMultiset.builder() .add(GET_ALL_TABLES) @@ -413,6 +445,8 @@ public void testSelectColumnsWithoutPredicate() @Test public void testSelectColumnsFilterByInformationSchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.columns WHERE table_schema = 'information_schema'", ImmutableMultiset.of()); assertMetastoreInvocations("SELECT * FROM system.jdbc.columns WHERE table_schem = 'information_schema'", ImmutableMultiset.of()); } @@ -420,6 +454,8 @@ public void testSelectColumnsFilterByInformationSchema() @Test public void testSelectColumnsFilterBySchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.columns WHERE table_schema = 'test_schema_0'", ImmutableMultiset.builder() .add(GET_ALL_TABLES_FROM_DATABASE) @@ -450,6 +486,8 @@ public void testSelectColumnsFilterBySchema() @Test public void testSelectColumnsWithLikeOverSchema() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.columns WHERE table_schema LIKE 'test%'", @@ -488,6 +526,8 @@ public void testSelectColumnsWithLikeOverSchema() @Test public void testSelectColumnsFilterByTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.columns WHERE table_name = 'test_table_0'", @@ -554,6 +594,8 @@ public void testSelectColumnsFilterByTableName() @Test public void testSelectColumnsWithLikeOverTableName() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations("SELECT * FROM information_schema.columns WHERE table_name LIKE 'test%'", ImmutableMultiset.builder() @@ -590,6 +632,8 @@ public void testSelectColumnsWithLikeOverTableName() @Test public void testSelectColumnsFilterByColumn() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.columns WHERE column_name = 'name'", @@ -628,6 +672,8 @@ public void testSelectColumnsFilterByColumn() @Test public void testSelectColumnsWithLikeOverColumn() { + resetMetastoreSetup(); + mockMetastore.setAllTablesViewsImplemented(true); assertMetastoreInvocations( "SELECT * FROM information_schema.columns WHERE column_name LIKE 'n%'", @@ -667,6 +713,8 @@ public void testSelectColumnsWithLikeOverColumn() @Test public void testSelectColumnsFilterByTableAndSchema() { + resetMetastoreSetup(); + assertMetastoreInvocations("SELECT * FROM information_schema.columns WHERE table_schema = 'test_schema_0' AND table_name = 'test_table_0'", ImmutableMultiset.of(GET_TABLE)); assertMetastoreInvocations("SELECT * FROM system.jdbc.columns WHERE table_schem = 'test_schema_0' AND table_name = 'test_table_0'", ImmutableMultiset.of(GET_TABLE)); assertMetastoreInvocations("SELECT * FROM system.jdbc.columns WHERE table_schem LIKE 'test\\_schema\\_0' ESCAPE '\\' AND table_name LIKE 'test\\_table\\_0' ESCAPE '\\'", ImmutableMultiset.of(GET_TABLE));