From 1ca7bb4a4e2fce107bb5778b1d152d4480bb23fe Mon Sep 17 00:00:00 2001 From: Martin Traverso Date: Fri, 17 Nov 2023 14:05:08 -0800 Subject: [PATCH] Migrate tests to JUnit --- .../TestAggregationLoopBuilder.java | 12 +- ...AuthenticationFilterWithRefreshTokens.java | 16 +- .../trino/spiller/TestBinaryFileSpiller.java | 21 +- .../sql/planner/assertions/BasePlanTest.java | 4 - .../planner/optimizations/BaseTestUnion.java | 244 ++++++++++++++++++ .../sql/planner/optimizations/TestUnion.java | 230 +---------------- .../TestUnionWithReplicatedJoin.java | 2 +- lib/trino-matching/pom.xml | 6 - lib/trino-orc/pom.xml | 19 -- .../src/test/java/io/trino/orc/OrcTester.java | 4 +- .../AbstractStatisticsBuilderTest.java | 2 +- .../TestBinaryStatisticsBuilder.java | 2 +- .../TestBooleanStatisticsBuilder.java | 2 +- .../statistics/TestDateStatistics.java | 2 +- .../statistics/TestDateStatisticsBuilder.java | 2 +- .../statistics/TestDecimalStatistics.java | 2 +- .../statistics/TestDoubleStatistics.java | 2 +- .../TestDoubleStatisticsBuilder.java | 2 +- .../statistics/TestIntegerStatistics.java | 2 +- .../TestIntegerStatisticsBuilder.java | 2 +- .../TestLongDecimalStatisticsBuilder.java | 2 +- .../TestShortDecimalStatisticsBuilder.java | 2 +- .../statistics/TestStringStatistics.java | 2 +- .../statistics/TestTimestampStatistics.java | 2 +- .../TestTimestampStatisticsBuilder.java | 2 +- .../hive/AbstractTestHiveFileSystemAbfs.java | 2 +- .../plugin/hive/TestHiveFileSystemAdl.java | 2 +- .../plugin/hive/TestHiveFileSystemS3.java | 2 +- .../plugin/hive/TestHiveFileSystemWasb.java | 2 +- ...TestTrinoS3FileSystemAccessOperations.java | 13 +- plugin/trino-memory/pom.xml | 6 - ...eFaultTolerantExecutionOrderByQueries.java | 2 - ...veFaultTolerantExecutionWindowQueries.java | 2 - .../execution/TestEventListenerBasic.java | 13 +- .../io/trino/execution/TestRevokeOnTable.java | 16 +- .../tests/TestLocalEngineOnlyQueries.java | 9 +- .../trino/tests/TestMinWorkerRequirement.java | 104 ++++---- .../trino/tests/TestQueryPlanDeterminism.java | 5 +- .../tests/TestQuerySerializationFailures.java | 2 +- .../io/trino/tests/TestQuerySpillLimits.java | 24 +- 40 files changed, 417 insertions(+), 375 deletions(-) create mode 100644 core/trino-main/src/test/java/io/trino/sql/planner/optimizations/BaseTestUnion.java diff --git a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestAggregationLoopBuilder.java b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestAggregationLoopBuilder.java index 53d55a59df6d..333384277129 100644 --- a/core/trino-main/src/test/java/io/trino/operator/aggregation/TestAggregationLoopBuilder.java +++ b/core/trino-main/src/test/java/io/trino/operator/aggregation/TestAggregationLoopBuilder.java @@ -24,8 +24,10 @@ import io.trino.spi.function.BlockPosition; import io.trino.spi.function.SqlNullable; import io.trino.spi.function.SqlType; -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 org.junit.jupiter.api.parallel.Execution; import java.lang.invoke.MethodHandle; import java.util.ArrayList; @@ -36,7 +38,11 @@ import static java.lang.invoke.MethodHandles.lookup; import static java.lang.invoke.MethodType.methodType; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT; +@TestInstance(PER_CLASS) +@Execution(CONCURRENT) public class TestAggregationLoopBuilder { private static final MethodHandle INPUT_FUNCTION; @@ -59,7 +65,7 @@ public class TestAggregationLoopBuilder private List keyBlocks; private List valueBlocks; - @BeforeClass + @BeforeAll public void setUp() throws ReflectiveOperationException { diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithRefreshTokens.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithRefreshTokens.java index 9509a220445a..b17eaf002226 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithRefreshTokens.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestOAuth2WebUiAuthenticationFilterWithRefreshTokens.java @@ -30,9 +30,11 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -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 org.junit.jupiter.api.parallel.Execution; import java.net.CookieManager; import java.net.CookieStore; @@ -48,7 +50,11 @@ import static jakarta.servlet.http.HttpServletResponse.SC_OK; 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.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT; +@TestInstance(PER_CLASS) +@Execution(CONCURRENT) public class TestOAuth2WebUiAuthenticationFilterWithRefreshTokens { protected static final Duration TTL_ACCESS_TOKEN_IN_SECONDS = Duration.ofSeconds(5); @@ -65,7 +71,7 @@ public class TestOAuth2WebUiAuthenticationFilterWithRefreshTokens private URI serverUri; private URI uiUri; - @BeforeClass + @BeforeAll public void setup() throws Exception { @@ -121,7 +127,7 @@ public void setup() serverUri + "/ui/logout/logout.html"); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() throws Exception { diff --git a/core/trino-main/src/test/java/io/trino/spiller/TestBinaryFileSpiller.java b/core/trino-main/src/test/java/io/trino/spiller/TestBinaryFileSpiller.java index bab545a51306..ca723183c382 100644 --- a/core/trino-main/src/test/java/io/trino/spiller/TestBinaryFileSpiller.java +++ b/core/trino-main/src/test/java/io/trino/spiller/TestBinaryFileSpiller.java @@ -25,10 +25,12 @@ import io.trino.spi.block.BlockEncodingSerde; import io.trino.spi.block.TestingBlockEncodingSerde; import io.trino.spi.type.Type; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; import java.io.File; import java.io.IOException; @@ -47,8 +49,11 @@ import static io.trino.spi.type.VarbinaryType.VARBINARY; import static io.trino.spi.type.VarcharType.VARCHAR; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -@Test(singleThreaded = true) +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestBinaryFileSpiller { private static final List TYPES = ImmutableList.of(BIGINT, VARCHAR, DOUBLE, BIGINT); @@ -60,14 +65,14 @@ public class TestBinaryFileSpiller private PageSerializer serializer; private AggregatedMemoryContext memoryContext; - @BeforeClass(alwaysRun = true) + @BeforeAll public void setUpClass() throws IOException { spillPath = Files.createTempDirectory("tmp").toFile(); } - @BeforeMethod + @BeforeEach public void setUp() { spillerStats = new SpillerStats(); @@ -83,7 +88,7 @@ public void setUp() memoryContext = newSimpleAggregatedMemoryContext(); } - @AfterMethod(alwaysRun = true) + @AfterEach public void tearDown() throws Exception { diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/BasePlanTest.java b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/BasePlanTest.java index 1d86481b4487..2715d24c0819 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/BasePlanTest.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/BasePlanTest.java @@ -34,8 +34,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.parallel.Execution; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import java.util.List; import java.util.Map; @@ -91,14 +89,12 @@ protected LocalQueryRunner createLocalQueryRunner() } @BeforeAll - @BeforeClass public final void initPlanTest() { this.queryRunner = createLocalQueryRunner(); } @AfterAll - @AfterClass(alwaysRun = true) public final void destroyPlanTest() { closeAllRuntimeException(queryRunner); diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/BaseTestUnion.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/BaseTestUnion.java new file mode 100644 index 000000000000..0dd1135c30d5 --- /dev/null +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/BaseTestUnion.java @@ -0,0 +1,244 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.trino.sql.planner.optimizations; + +import com.google.common.collect.Iterables; +import io.trino.sql.planner.Plan; +import io.trino.sql.planner.assertions.BasePlanTest; +import io.trino.sql.planner.plan.AggregationNode; +import io.trino.sql.planner.plan.ExchangeNode; +import io.trino.sql.planner.plan.JoinNode; +import io.trino.sql.planner.plan.PlanNode; +import io.trino.sql.planner.plan.TopNNode; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED; +import static io.trino.sql.planner.optimizations.PlanNodeSearcher.searchFrom; +import static io.trino.sql.planner.plan.ExchangeNode.Scope.REMOTE; +import static io.trino.sql.planner.plan.ExchangeNode.Type.GATHER; +import static io.trino.sql.planner.plan.ExchangeNode.Type.REPARTITION; +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; + +abstract class BaseTestUnion + extends BasePlanTest +{ + protected BaseTestUnion(Map sessionProperties) + { + super(sessionProperties); + } + + @Test + public void testSimpleUnion() + { + Plan plan = plan( + "SELECT suppkey FROM supplier UNION ALL SELECT nationkey FROM nation", + OPTIMIZED_AND_VALIDATED, + false); + + List remotes = searchFrom(plan.getRoot()) + .where(BaseTestUnion::isRemoteExchange) + .findAll(); + + assertThat(remotes.size()) + .describedAs("There should be exactly one RemoteExchange") + .isEqualTo(1); + assertThat(((ExchangeNode) Iterables.getOnlyElement(remotes)).getType()).isEqualTo(GATHER); + assertPlanIsFullyDistributed(plan); + } + + @Test + public void testUnionUnderTopN() + { + Plan plan = plan( + "SELECT * FROM (" + + " SELECT regionkey FROM nation " + + " UNION ALL " + + " SELECT nationkey FROM nation" + + ") t(a) " + + "ORDER BY a LIMIT 1", + OPTIMIZED_AND_VALIDATED, + false); + + List remotes = searchFrom(plan.getRoot()) + .where(BaseTestUnion::isRemoteExchange) + .findAll(); + + assertThat(remotes.size()) + .describedAs("There should be exactly one RemoteExchange") + .isEqualTo(1); + assertThat(((ExchangeNode) Iterables.getOnlyElement(remotes)).getType()).isEqualTo(GATHER); + + int numberOfpartialTopN = searchFrom(plan.getRoot()) + .where(planNode -> planNode instanceof TopNNode && ((TopNNode) planNode).getStep() == TopNNode.Step.PARTIAL) + .count(); + assertThat(numberOfpartialTopN) + .describedAs("There should be exactly two partial TopN nodes") + .isEqualTo(2); + assertPlanIsFullyDistributed(plan); + } + + @Test + public void testUnionOverSingleNodeAggregationAndUnion() + { + Plan plan = plan( + "SELECT count(*) FROM (" + + "SELECT 1 FROM nation GROUP BY regionkey " + + "UNION ALL (" + + " SELECT 1 FROM nation " + + " UNION ALL " + + " SELECT 1 FROM nation))", + OPTIMIZED_AND_VALIDATED, + false); + + List remotes = searchFrom(plan.getRoot()) + .where(BaseTestUnion::isRemoteExchange) + .findAll(); + + assertThat(remotes.size()) + .describedAs("There should be exactly two RemoteExchanges") + .isEqualTo(2); + assertThat(((ExchangeNode) remotes.get(0)).getType()).isEqualTo(GATHER); + assertThat(((ExchangeNode) remotes.get(1)).getType()).isEqualTo(REPARTITION); + } + + @Test + public void testPartialAggregationsWithUnion() + { + Plan plan = plan( + "SELECT orderstatus, sum(orderkey) FROM (SELECT orderkey, orderstatus FROM orders UNION ALL SELECT orderkey, orderstatus FROM orders) x GROUP BY (orderstatus)", + OPTIMIZED_AND_VALIDATED, + false); + assertAtMostOneAggregationBetweenRemoteExchanges(plan); + assertPlanIsFullyDistributed(plan); + } + + @Test + public void testPartialRollupAggregationsWithUnion() + { + Plan plan = plan( + "SELECT orderstatus, sum(orderkey) FROM (SELECT orderkey, orderstatus FROM orders UNION ALL SELECT orderkey, orderstatus FROM orders) x GROUP BY ROLLUP (orderstatus)", + OPTIMIZED_AND_VALIDATED, + false); + assertAtMostOneAggregationBetweenRemoteExchanges(plan); + assertPlanIsFullyDistributed(plan); + } + + @Test + public void testAggregationWithUnionAndValues() + { + Plan plan = plan( + "SELECT regionkey, count(*) FROM (SELECT regionkey FROM nation UNION ALL SELECT * FROM (VALUES 2, 100) t(regionkey)) GROUP BY regionkey", + OPTIMIZED_AND_VALIDATED, + false); + assertAtMostOneAggregationBetweenRemoteExchanges(plan); + // TODO: Enable this check once distributed UNION can handle both partitioned and single node sources at the same time + //assertPlanIsFullyDistributed(plan); + } + + @Test + public void testUnionOnProbeSide() + { + Plan plan = plan( + "SELECT * FROM (SELECT * FROM nation UNION ALL SELECT * from nation) n, region r WHERE n.regionkey=r.regionkey", + OPTIMIZED_AND_VALIDATED, + false); + + assertPlanIsFullyDistributed(plan); + } + + private void assertPlanIsFullyDistributed(Plan plan) + { + int numberOfGathers = searchFrom(plan.getRoot()) + .where(BaseTestUnion::isRemoteGatheringExchange) + .findAll() + .size(); + + if (numberOfGathers == 0) { + // there are no "gather" nodes, so the plan is expected to be fully distributed + return; + } + + assertThat(searchFrom(plan.getRoot()) + .recurseOnlyWhen(BaseTestUnion::isNotRemoteGatheringExchange) + .findAll() + .stream() + .noneMatch(this::shouldBeDistributed)) + .describedAs("There is a node that should be distributed between output and first REMOTE GATHER ExchangeNode") + .isTrue(); + + assertThat(numberOfGathers) + .describedAs("Only a single REMOTE GATHER was expected") + .isEqualTo(1); + } + + private boolean shouldBeDistributed(PlanNode planNode) + { + if (planNode instanceof JoinNode) { + return true; + } + if (planNode instanceof AggregationNode) { + // TODO: differentiate aggregation with empty grouping set + return true; + } + if (planNode instanceof TopNNode) { + return ((TopNNode) planNode).getStep() == TopNNode.Step.PARTIAL; + } + return false; + } + + private static void assertAtMostOneAggregationBetweenRemoteExchanges(Plan plan) + { + List fragments = searchFrom(plan.getRoot()) + .where(BaseTestUnion::isRemoteExchange) + .findAll() + .stream() + .flatMap(exchangeNode -> exchangeNode.getSources().stream()) + .collect(toList()); + + for (PlanNode fragment : fragments) { + List aggregations = searchFrom(fragment) + .where(AggregationNode.class::isInstance) + .recurseOnlyWhen(BaseTestUnion::isNotRemoteExchange) + .findAll(); + + assertThat(aggregations.size() > 1) + .describedAs("More than a single AggregationNode between remote exchanges") + .isFalse(); + } + } + + private static boolean isNotRemoteGatheringExchange(PlanNode planNode) + { + return !isRemoteGatheringExchange(planNode); + } + + private static boolean isRemoteGatheringExchange(PlanNode planNode) + { + return isRemoteExchange(planNode) && ((ExchangeNode) planNode).getType() == GATHER; + } + + private static boolean isNotRemoteExchange(PlanNode planNode) + { + return !isRemoteExchange(planNode); + } + + private static boolean isRemoteExchange(PlanNode planNode) + { + return (planNode instanceof ExchangeNode) && ((ExchangeNode) planNode).getScope() == REMOTE; + } +} diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnion.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnion.java index e839ca3c7c9d..d97255b181ae 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnion.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnion.java @@ -13,237 +13,13 @@ */ package io.trino.sql.planner.optimizations; -import com.google.common.collect.Iterables; -import io.trino.sql.planner.Plan; -import io.trino.sql.planner.assertions.BasePlanTest; -import io.trino.sql.planner.plan.AggregationNode; -import io.trino.sql.planner.plan.ExchangeNode; -import io.trino.sql.planner.plan.JoinNode; -import io.trino.sql.planner.plan.PlanNode; -import io.trino.sql.planner.plan.TopNNode; -import org.testng.annotations.Test; - -import java.util.List; -import java.util.Map; - -import static io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED; -import static io.trino.sql.planner.optimizations.PlanNodeSearcher.searchFrom; -import static io.trino.sql.planner.plan.ExchangeNode.Scope.REMOTE; -import static io.trino.sql.planner.plan.ExchangeNode.Type.GATHER; -import static io.trino.sql.planner.plan.ExchangeNode.Type.REPARTITION; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; +import com.google.common.collect.ImmutableMap; public class TestUnion - extends BasePlanTest + extends BaseTestUnion { public TestUnion() { - super(); - } - - public TestUnion(Map sessionProperties) - { - super(sessionProperties); - } - - @Test - public void testSimpleUnion() - { - Plan plan = plan( - "SELECT suppkey FROM supplier UNION ALL SELECT nationkey FROM nation", - OPTIMIZED_AND_VALIDATED, - false); - - List remotes = searchFrom(plan.getRoot()) - .where(TestUnion::isRemoteExchange) - .findAll(); - - assertThat(remotes.size()) - .describedAs("There should be exactly one RemoteExchange") - .isEqualTo(1); - assertThat(((ExchangeNode) Iterables.getOnlyElement(remotes)).getType()).isEqualTo(GATHER); - assertPlanIsFullyDistributed(plan); - } - - @Test - public void testUnionUnderTopN() - { - Plan plan = plan( - "SELECT * FROM (" + - " SELECT regionkey FROM nation " + - " UNION ALL " + - " SELECT nationkey FROM nation" + - ") t(a) " + - "ORDER BY a LIMIT 1", - OPTIMIZED_AND_VALIDATED, - false); - - List remotes = searchFrom(plan.getRoot()) - .where(TestUnion::isRemoteExchange) - .findAll(); - - assertThat(remotes.size()) - .describedAs("There should be exactly one RemoteExchange") - .isEqualTo(1); - assertThat(((ExchangeNode) Iterables.getOnlyElement(remotes)).getType()).isEqualTo(GATHER); - - int numberOfpartialTopN = searchFrom(plan.getRoot()) - .where(planNode -> planNode instanceof TopNNode && ((TopNNode) planNode).getStep() == TopNNode.Step.PARTIAL) - .count(); - assertThat(numberOfpartialTopN) - .describedAs("There should be exactly two partial TopN nodes") - .isEqualTo(2); - assertPlanIsFullyDistributed(plan); - } - - @Test - public void testUnionOverSingleNodeAggregationAndUnion() - { - Plan plan = plan( - "SELECT count(*) FROM (" + - "SELECT 1 FROM nation GROUP BY regionkey " + - "UNION ALL (" + - " SELECT 1 FROM nation " + - " UNION ALL " + - " SELECT 1 FROM nation))", - OPTIMIZED_AND_VALIDATED, - false); - - List remotes = searchFrom(plan.getRoot()) - .where(TestUnion::isRemoteExchange) - .findAll(); - - assertThat(remotes.size()) - .describedAs("There should be exactly two RemoteExchanges") - .isEqualTo(2); - assertThat(((ExchangeNode) remotes.get(0)).getType()).isEqualTo(GATHER); - assertThat(((ExchangeNode) remotes.get(1)).getType()).isEqualTo(REPARTITION); - } - - @Test - public void testPartialAggregationsWithUnion() - { - Plan plan = plan( - "SELECT orderstatus, sum(orderkey) FROM (SELECT orderkey, orderstatus FROM orders UNION ALL SELECT orderkey, orderstatus FROM orders) x GROUP BY (orderstatus)", - OPTIMIZED_AND_VALIDATED, - false); - assertAtMostOneAggregationBetweenRemoteExchanges(plan); - assertPlanIsFullyDistributed(plan); - } - - @Test - public void testPartialRollupAggregationsWithUnion() - { - Plan plan = plan( - "SELECT orderstatus, sum(orderkey) FROM (SELECT orderkey, orderstatus FROM orders UNION ALL SELECT orderkey, orderstatus FROM orders) x GROUP BY ROLLUP (orderstatus)", - OPTIMIZED_AND_VALIDATED, - false); - assertAtMostOneAggregationBetweenRemoteExchanges(plan); - assertPlanIsFullyDistributed(plan); - } - - @Test - public void testAggregationWithUnionAndValues() - { - Plan plan = plan( - "SELECT regionkey, count(*) FROM (SELECT regionkey FROM nation UNION ALL SELECT * FROM (VALUES 2, 100) t(regionkey)) GROUP BY regionkey", - OPTIMIZED_AND_VALIDATED, - false); - assertAtMostOneAggregationBetweenRemoteExchanges(plan); - // TODO: Enable this check once distributed UNION can handle both partitioned and single node sources at the same time - //assertPlanIsFullyDistributed(plan); - } - - @Test - public void testUnionOnProbeSide() - { - Plan plan = plan( - "SELECT * FROM (SELECT * FROM nation UNION ALL SELECT * from nation) n, region r WHERE n.regionkey=r.regionkey", - OPTIMIZED_AND_VALIDATED, - false); - - assertPlanIsFullyDistributed(plan); - } - - private void assertPlanIsFullyDistributed(Plan plan) - { - int numberOfGathers = searchFrom(plan.getRoot()) - .where(TestUnion::isRemoteGatheringExchange) - .findAll() - .size(); - - if (numberOfGathers == 0) { - // there are no "gather" nodes, so the plan is expected to be fully distributed - return; - } - - assertThat(searchFrom(plan.getRoot()) - .recurseOnlyWhen(TestUnion::isNotRemoteGatheringExchange) - .findAll() - .stream() - .noneMatch(this::shouldBeDistributed)) - .describedAs("There is a node that should be distributed between output and first REMOTE GATHER ExchangeNode") - .isTrue(); - - assertThat(numberOfGathers) - .describedAs("Only a single REMOTE GATHER was expected") - .isEqualTo(1); - } - - private boolean shouldBeDistributed(PlanNode planNode) - { - if (planNode instanceof JoinNode) { - return true; - } - if (planNode instanceof AggregationNode) { - // TODO: differentiate aggregation with empty grouping set - return true; - } - if (planNode instanceof TopNNode) { - return ((TopNNode) planNode).getStep() == TopNNode.Step.PARTIAL; - } - return false; - } - - private static void assertAtMostOneAggregationBetweenRemoteExchanges(Plan plan) - { - List fragments = searchFrom(plan.getRoot()) - .where(TestUnion::isRemoteExchange) - .findAll() - .stream() - .flatMap(exchangeNode -> exchangeNode.getSources().stream()) - .collect(toList()); - - for (PlanNode fragment : fragments) { - List aggregations = searchFrom(fragment) - .where(AggregationNode.class::isInstance) - .recurseOnlyWhen(TestUnion::isNotRemoteExchange) - .findAll(); - - assertThat(aggregations.size() > 1) - .describedAs("More than a single AggregationNode between remote exchanges") - .isFalse(); - } - } - - private static boolean isNotRemoteGatheringExchange(PlanNode planNode) - { - return !isRemoteGatheringExchange(planNode); - } - - private static boolean isRemoteGatheringExchange(PlanNode planNode) - { - return isRemoteExchange(planNode) && ((ExchangeNode) planNode).getType() == GATHER; - } - - private static boolean isNotRemoteExchange(PlanNode planNode) - { - return !isRemoteExchange(planNode); - } - - private static boolean isRemoteExchange(PlanNode planNode) - { - return (planNode instanceof ExchangeNode) && ((ExchangeNode) planNode).getScope() == REMOTE; + super(ImmutableMap.of()); } } diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnionWithReplicatedJoin.java b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnionWithReplicatedJoin.java index ecb8b74cbfae..586526932259 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnionWithReplicatedJoin.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/optimizations/TestUnionWithReplicatedJoin.java @@ -19,7 +19,7 @@ import static io.trino.sql.planner.OptimizerConfig.JoinDistributionType.BROADCAST; public class TestUnionWithReplicatedJoin - extends TestUnion + extends BaseTestUnion { public TestUnionWithReplicatedJoin() { diff --git a/lib/trino-matching/pom.xml b/lib/trino-matching/pom.xml index d0cccac41602..d6c4649d9135 100644 --- a/lib/trino-matching/pom.xml +++ b/lib/trino-matching/pom.xml @@ -45,11 +45,5 @@ junit-jupiter-engine test - - - org.testng - testng - test - diff --git a/lib/trino-orc/pom.xml b/lib/trino-orc/pom.xml index 04f9293efcbf..299c25ca57d0 100644 --- a/lib/trino-orc/pom.xml +++ b/lib/trino-orc/pom.xml @@ -185,12 +185,6 @@ jmh-generator-annprocess test - - - org.testng - testng - test - @@ -205,19 +199,6 @@ **/TestFullOrcReader.java - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - diff --git a/lib/trino-orc/src/test/java/io/trino/orc/OrcTester.java b/lib/trino-orc/src/test/java/io/trino/orc/OrcTester.java index 5803bdd684f8..8a02dcdb6709 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/OrcTester.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/OrcTester.java @@ -198,7 +198,7 @@ import static org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaTimestampTZObjectInspector; import static org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getCharTypeInfo; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.data.Offset.offset; public class OrcTester { @@ -602,7 +602,7 @@ else if (type.equals(DOUBLE)) { .isTrue(); } else { - assertEquals(actualDouble, expectedDouble, 0.001); + assertThat(actualDouble).isCloseTo(expectedDouble, offset(0.001)); } } else if (type.equals(UUID)) { diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/AbstractStatisticsBuilderTest.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/AbstractStatisticsBuilderTest.java index 8e81fb5d4a07..313996c19ae0 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/AbstractStatisticsBuilderTest.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/AbstractStatisticsBuilderTest.java @@ -14,7 +14,7 @@ package io.trino.orc.metadata.statistics; import com.google.common.collect.ImmutableList; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collections; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBinaryStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBinaryStatisticsBuilder.java index 6982ac477f11..6b624015b625 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBinaryStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBinaryStatisticsBuilder.java @@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.slice.Slice; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBooleanStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBooleanStatisticsBuilder.java index 7b73da88209b..fa76d84a03c4 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBooleanStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestBooleanStatisticsBuilder.java @@ -14,7 +14,7 @@ package io.trino.orc.metadata.statistics; import com.google.common.collect.ImmutableList; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatistics.java index d401cbad4e8f..f3a521e632ea 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatistics.java @@ -13,7 +13,7 @@ */ package io.trino.orc.metadata.statistics; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.airlift.slice.SizeOf.instanceSize; import static java.lang.Integer.MAX_VALUE; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatisticsBuilder.java index 11f37a759f76..c90d6cdfac99 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDateStatisticsBuilder.java @@ -17,7 +17,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.trino.orc.metadata.statistics.AbstractStatisticsBuilderTest.StatisticsType.DATE; import static io.trino.orc.metadata.statistics.DateStatistics.DATE_VALUE_BYTES; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDecimalStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDecimalStatistics.java index 9084d7ca066b..4f3e921f2ffc 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDecimalStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDecimalStatistics.java @@ -13,7 +13,7 @@ */ package io.trino.orc.metadata.statistics; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatistics.java index 4aaeea94c776..91174a6a4628 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatistics.java @@ -13,7 +13,7 @@ */ package io.trino.orc.metadata.statistics; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.airlift.slice.SizeOf.instanceSize; import static java.lang.Double.NEGATIVE_INFINITY; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatisticsBuilder.java index 18b4e6358c00..f2a61acac277 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestDoubleStatisticsBuilder.java @@ -14,7 +14,7 @@ package io.trino.orc.metadata.statistics; import com.google.common.collect.ImmutableList; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.LongStream; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatistics.java index d8f9d031a960..a1546f7cb278 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatistics.java @@ -13,7 +13,7 @@ */ package io.trino.orc.metadata.statistics; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.airlift.slice.SizeOf.instanceSize; import static java.lang.Long.MAX_VALUE; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatisticsBuilder.java index 06c7b1e9c4e6..d38862a0aeac 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestIntegerStatisticsBuilder.java @@ -17,7 +17,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestLongDecimalStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestLongDecimalStatisticsBuilder.java index 7d81c4a1578e..8121e751de01 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestLongDecimalStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestLongDecimalStatisticsBuilder.java @@ -17,7 +17,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.util.List; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestShortDecimalStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestShortDecimalStatisticsBuilder.java index 15252da314cd..a6e155005951 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestShortDecimalStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestShortDecimalStatisticsBuilder.java @@ -17,7 +17,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestStringStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestStringStatistics.java index 40ba294eef1c..13c0dce8a540 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestStringStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestStringStatistics.java @@ -14,7 +14,7 @@ package io.trino.orc.metadata.statistics; import io.airlift.slice.Slice; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.airlift.slice.SizeOf.instanceSize; import static io.airlift.slice.Slices.EMPTY_SLICE; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatistics.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatistics.java index 6c4a183fbac6..818ba511742e 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatistics.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatistics.java @@ -13,7 +13,7 @@ */ package io.trino.orc.metadata.statistics; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.airlift.slice.SizeOf.instanceSize; import static java.lang.Long.MAX_VALUE; diff --git a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatisticsBuilder.java b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatisticsBuilder.java index 26b227bde41f..1a5708882fb6 100644 --- a/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatisticsBuilder.java +++ b/lib/trino-orc/src/test/java/io/trino/orc/metadata/statistics/TestTimestampStatisticsBuilder.java @@ -17,7 +17,7 @@ import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.trino.orc.metadata.statistics.AbstractStatisticsBuilderTest.StatisticsType.TIMESTAMP; import static io.trino.orc.metadata.statistics.TimestampStatistics.TIMESTAMP_VALUE_BYTES; diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java index 532323a3ffa0..8daba40b523b 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/AbstractTestHiveFileSystemAbfs.java @@ -42,7 +42,7 @@ import static io.trino.plugin.hive.HiveTableProperties.STORAGE_FORMAT_PROPERTY; import static io.trino.spi.type.BigintType.BIGINT; import static java.lang.String.format; -import static org.testng.util.Strings.isNullOrEmpty; +import static org.assertj.core.util.Strings.isNullOrEmpty; public abstract class AbstractTestHiveFileSystemAbfs extends AbstractTestHiveFileSystem 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 df69bddd44be..525bf5063106 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 @@ -34,8 +34,8 @@ import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.util.Strings.isNullOrEmpty; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.util.Strings.isNullOrEmpty; @TestInstance(PER_CLASS) public class TestHiveFileSystemAdl 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 ae5c1833a8d5..c2d29ba9730c 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 @@ -58,8 +58,8 @@ import static java.io.InputStream.nullInputStream; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.util.Strings.isNullOrEmpty; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.util.Strings.isNullOrEmpty; @TestInstance(PER_CLASS) public class TestHiveFileSystemS3 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 955675b7d1d5..08d9eda5c3e4 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 @@ -27,8 +27,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; +import static org.assertj.core.util.Strings.isNullOrEmpty; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.util.Strings.isNullOrEmpty; @TestInstance(PER_CLASS) public class TestHiveFileSystemWasb diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestTrinoS3FileSystemAccessOperations.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestTrinoS3FileSystemAccessOperations.java index 960f6b54d324..32083e867c6c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestTrinoS3FileSystemAccessOperations.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestTrinoS3FileSystemAccessOperations.java @@ -35,8 +35,11 @@ import io.trino.testing.QueryRunner; import io.trino.testing.containers.Minio; import org.intellij.lang.annotations.Language; -import org.testng.annotations.AfterClass; -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.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import java.io.File; @@ -48,8 +51,10 @@ import static io.trino.testing.containers.Minio.MINIO_ACCESS_KEY; import static io.trino.testing.containers.Minio.MINIO_SECRET_KEY; import static java.util.stream.Collectors.toCollection; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -@Test(singleThreaded = true) // S3 request counters shares mutable state so can't be run from many threads simultaneously +@TestInstance(PER_CLASS) +@Execution(ExecutionMode.SAME_THREAD) // S3 request counters shares mutable state so can't be run from many threads simultaneously public class TestTrinoS3FileSystemAccessOperations extends AbstractTestQueryFramework { @@ -100,7 +105,7 @@ protected QueryRunner createQueryRunner() .build(); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() { // closed by closeAfterClass diff --git a/plugin/trino-memory/pom.xml b/plugin/trino-memory/pom.xml index 42c275e8d656..9900c9b1e51c 100644 --- a/plugin/trino-memory/pom.xml +++ b/plugin/trino-memory/pom.xml @@ -190,11 +190,5 @@ junit-jupiter-engine test - - - org.testng - testng - test - diff --git a/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionOrderByQueries.java b/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionOrderByQueries.java index 48f0e58d69cb..d9bd5ae28238 100644 --- a/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionOrderByQueries.java +++ b/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionOrderByQueries.java @@ -20,7 +20,6 @@ import io.trino.testing.QueryRunner; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; -import org.testng.annotations.AfterClass; import java.util.Map; @@ -51,7 +50,6 @@ protected QueryRunner createQueryRunner(Map extraProperties) } @AfterAll - @AfterClass(alwaysRun = true) public void destroy() throws Exception { diff --git a/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionWindowQueries.java b/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionWindowQueries.java index 9b61d9ee2f69..54d9ad72c195 100644 --- a/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionWindowQueries.java +++ b/testing/trino-faulttolerant-tests/src/test/java/io/trino/faulttolerant/hive/TestHiveFaultTolerantExecutionWindowQueries.java @@ -20,7 +20,6 @@ import io.trino.testing.QueryRunner; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.TestInstance; -import org.testng.annotations.AfterClass; import java.util.Map; @@ -53,7 +52,6 @@ protected QueryRunner createQueryRunner(Map extraProperties) } @AfterAll - @AfterClass(alwaysRun = true) public void destroy() throws Exception { diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestEventListenerBasic.java b/testing/trino-tests/src/test/java/io/trino/execution/TestEventListenerBasic.java index 76809bb35f9d..ade1e9fc96c6 100644 --- a/testing/trino-tests/src/test/java/io/trino/execution/TestEventListenerBasic.java +++ b/testing/trino-tests/src/test/java/io/trino/execution/TestEventListenerBasic.java @@ -50,7 +50,10 @@ import io.trino.testing.DistributedQueryRunner; import io.trino.testing.QueryRunner; import org.intellij.lang.annotations.Language; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.parallel.Execution; import java.io.File; import java.net.URISyntaxException; @@ -81,8 +84,11 @@ import static java.lang.String.format; import static java.util.UUID.randomUUID; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -@Test(singleThreaded = true) +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestEventListenerBasic extends AbstractTestQueryFramework { @@ -268,7 +274,8 @@ public void testAbortedWhileWaitingForResources() assertFailedQuery(mySession, "SELECT * FROM tpch.sf1.nation", "Insufficient active worker nodes. Waited 10.00ms for at least 17 workers, but only 1 workers are active"); } - @Test(timeOut = 30_000) + @Test + @Timeout(30) public void testKilledWhileWaitingForResources() throws Exception { diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnTable.java b/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnTable.java index 50b1324004f8..7f19308c6172 100644 --- a/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnTable.java +++ b/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnTable.java @@ -27,9 +27,11 @@ import io.trino.spi.security.TrinoPrincipal; import io.trino.sql.query.QueryAssertions; import io.trino.testing.DistributedQueryRunner; -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 org.junit.jupiter.api.parallel.Execution; import java.util.EnumSet; @@ -39,7 +41,11 @@ import static java.lang.String.format; 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.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT; +@TestInstance(PER_CLASS) +@Execution(CONCURRENT) public class TestRevokeOnTable { private static final Session admin = sessionOf("admin"); @@ -52,7 +58,7 @@ public class TestRevokeOnTable private DistributedQueryRunner queryRunner; private QueryAssertions assertions; - @BeforeClass + @BeforeAll public void initClass() throws Exception { @@ -78,7 +84,7 @@ public void initClass() assertions = new QueryAssertions(queryRunner); } - @AfterClass(alwaysRun = true) + @AfterAll public void teardown() { assertions.close(); diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestLocalEngineOnlyQueries.java b/testing/trino-tests/src/test/java/io/trino/tests/TestLocalEngineOnlyQueries.java index e33cea6524eb..b1acc5037d8e 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestLocalEngineOnlyQueries.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestLocalEngineOnlyQueries.java @@ -18,9 +18,10 @@ import io.trino.testing.AbstractTestEngineOnlyQueries; import io.trino.testing.LocalQueryRunner; import io.trino.testing.QueryRunner; -import org.testng.SkipException; +import org.junit.jupiter.api.Test; import static io.airlift.testing.Closeables.closeAllSuppress; +import static org.junit.jupiter.api.Assumptions.abort; public class TestLocalEngineOnlyQueries extends AbstractTestEngineOnlyQueries @@ -45,15 +46,17 @@ protected QueryRunner createQueryRunner() return queryRunner; } + @Test @Override public void testSetSession() { - throw new SkipException("SET SESSION is not supported by LocalQueryRunner"); + abort("SET SESSION is not supported by LocalQueryRunner"); } + @Test @Override public void testResetSession() { - throw new SkipException("RESET SESSION is not supported by LocalQueryRunner"); + abort("RESET SESSION is not supported by LocalQueryRunner"); } } diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java b/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java index 8dc4d9add6a5..27de229f8821 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestMinWorkerRequirement.java @@ -23,7 +23,9 @@ import io.trino.testing.DistributedQueryRunner; import io.trino.testing.MaterializedResultWithQueryId; import io.trino.tests.tpch.TpchQueryRunnerBuilder; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; import static io.trino.SystemSessionProperties.REQUIRED_WORKERS_COUNT; import static io.trino.SystemSessionProperties.REQUIRED_WORKERS_MAX_WAIT_TIME; @@ -34,42 +36,51 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Fail.fail; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; // run single threaded to avoid creating multiple query runners at once -@Test(singleThreaded = true) +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestMinWorkerRequirement { - @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "Insufficient active worker nodes. Waited 1.00ns for at least 5 workers, but only 4 workers are active") + @Test public void testInsufficientWorkerNodes() - throws Exception { - try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() - .setCoordinatorProperties(ImmutableMap.builder() - .put("query-manager.required-workers", "5") - .put("query-manager.required-workers-max-wait", "1ns") - .buildOrThrow()) - .setNodeCount(4) - .build()) { - queryRunner.execute("SELECT COUNT(*) from lineitem"); - fail("Expected exception due to insufficient active worker nodes"); - } + assertThatThrownBy(() -> { + try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() + .setCoordinatorProperties(ImmutableMap.builder() + .put("query-manager.required-workers", "5") + .put("query-manager.required-workers-max-wait", "1ns") + .buildOrThrow()) + .setNodeCount(4) + .build()) { + queryRunner.execute("SELECT COUNT(*) from lineitem"); + fail("Expected exception due to insufficient active worker nodes"); + } + }) + .isInstanceOf(RuntimeException.class) + .hasMessage("Insufficient active worker nodes. Waited 1.00ns for at least 5 workers, but only 4 workers are active"); } - @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "Insufficient active worker nodes. Waited 1.00ns for at least 4 workers, but only 3 workers are active") + @Test public void testInsufficientWorkerNodesWithCoordinatorExcluded() - throws Exception { - try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() - .setCoordinatorProperties(ImmutableMap.builder() - .put("node-scheduler.include-coordinator", "false") - .put("query-manager.required-workers", "4") - .put("query-manager.required-workers-max-wait", "1ns") - .buildOrThrow()) - .setNodeCount(4) - .build()) { - queryRunner.execute("SELECT COUNT(*) from lineitem"); - fail("Expected exception due to insufficient active worker nodes"); - } + assertThatThrownBy(() -> { + try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() + .setCoordinatorProperties(ImmutableMap.builder() + .put("node-scheduler.include-coordinator", "false") + .put("query-manager.required-workers", "4") + .put("query-manager.required-workers-max-wait", "1ns") + .buildOrThrow()) + .setNodeCount(4) + .build()) { + queryRunner.execute("SELECT COUNT(*) from lineitem"); + fail("Expected exception due to insufficient active worker nodes"); + } + }) + .isInstanceOf(RuntimeException.class) + .hasMessage("Insufficient active worker nodes. Waited 1.00ns for at least 4 workers, but only 3 workers are active"); } @Test @@ -116,26 +127,29 @@ public void testInsufficientWorkerNodesAfterDrop() } } - @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "Insufficient active worker nodes. Waited 99.00ns for at least 3 workers, but only 2 workers are active") + @Test public void testRequiredNodesMaxWaitSessionOverride() - throws Exception { - try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() - .setCoordinatorProperties(ImmutableMap.builder() - .put("query-manager.required-workers", "3") - .put("query-manager.required-workers-max-wait", "1ns") - .buildOrThrow()) - .setNodeCount(2) - .build()) { - Session session = testSessionBuilder() - .setSystemProperty(REQUIRED_WORKERS_COUNT, "3") - .setSystemProperty(REQUIRED_WORKERS_MAX_WAIT_TIME, "99ns") - .setCatalog("tpch") - .setSchema("tiny") - .build(); - queryRunner.execute(session, "SELECT COUNT(*) from lineitem"); - fail("Expected exception due to insufficient active worker nodes"); - } + assertThatThrownBy(() -> { + try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder() + .setCoordinatorProperties(ImmutableMap.builder() + .put("query-manager.required-workers", "3") + .put("query-manager.required-workers-max-wait", "1ns") + .buildOrThrow()) + .setNodeCount(2) + .build()) { + Session session = testSessionBuilder() + .setSystemProperty(REQUIRED_WORKERS_COUNT, "3") + .setSystemProperty(REQUIRED_WORKERS_MAX_WAIT_TIME, "99ns") + .setCatalog("tpch") + .setSchema("tiny") + .build(); + queryRunner.execute(session, "SELECT COUNT(*) from lineitem"); + fail("Expected exception due to insufficient active worker nodes"); + } + }) + .isInstanceOf(RuntimeException.class) + .hasMessage("Insufficient active worker nodes. Waited 99.00ns for at least 3 workers, but only 2 workers are active"); } @Test diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestQueryPlanDeterminism.java b/testing/trino-tests/src/test/java/io/trino/tests/TestQueryPlanDeterminism.java index 71bd2d193611..9a6bd296c921 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestQueryPlanDeterminism.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestQueryPlanDeterminism.java @@ -25,10 +25,10 @@ import io.trino.testing.TestingAccessControlManager.TestingPrivilege; import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import org.testng.SkipException; import java.util.List; @@ -267,10 +267,11 @@ public void testTpcdsQ6deterministic() " )\n"); } + @Test @Override public void testLargeIn() { // testLargeIn is expensive - throw new SkipException("Skipping testLargeIn"); + Assumptions.abort("Skipping testLargeIn"); } } diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySerializationFailures.java b/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySerializationFailures.java index b764d491e726..19cf90a7b95c 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySerializationFailures.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySerializationFailures.java @@ -24,7 +24,7 @@ import io.trino.testing.DistributedQueryRunner; import io.trino.testing.QueryRunner; import io.trino.testng.services.Flaky; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.Set; diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySpillLimits.java b/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySpillLimits.java index b56a82185651..9fb634752fa4 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySpillLimits.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestQuerySpillLimits.java @@ -21,9 +21,12 @@ import io.trino.spiller.NodeSpillConfig; import io.trino.testing.LocalQueryRunner; import io.trino.testing.QueryRunner; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.parallel.Execution; import java.io.File; import java.nio.file.Files; @@ -32,8 +35,11 @@ import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE; import static io.trino.testing.TestingSession.testSessionBuilder; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_METHOD; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -@Test(singleThreaded = true) +@TestInstance(PER_METHOD) +@Execution(SAME_THREAD) public class TestQuerySpillLimits { private static final Session SESSION = testSessionBuilder() @@ -43,21 +49,22 @@ public class TestQuerySpillLimits private File spillPath; - @BeforeMethod + @BeforeEach public void setUp() throws Exception { this.spillPath = Files.createTempDirectory(null).toFile(); } - @AfterMethod(alwaysRun = true) + @AfterEach public void tearDown() throws Exception { deleteRecursively(spillPath.toPath(), ALLOW_INSECURE); } - @Test(timeOut = 240_000, expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Query exceeded local spill limit of 10B") + @Test + @Timeout(240) public void testMaxSpillPerNodeLimit() { assertThatThrownBy(() -> { @@ -69,7 +76,8 @@ public void testMaxSpillPerNodeLimit() .hasMessage(".*Query exceeded local spill limit of 10B"); } - @Test(timeOut = 240_000, expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Query exceeded per-query local spill limit of 10B") + @Test + @Timeout(240) public void testQueryMaxSpillPerNodeLimit() { assertThatThrownBy(() -> {