diff --git a/modules/calcite/pom.xml b/modules/calcite/pom.xml index 7596a45718fd7..ea11f83733196 100644 --- a/modules/calcite/pom.xml +++ b/modules/calcite/pom.xml @@ -47,10 +47,26 @@ 3.6.1 1.15.0 1.2 + 3.0 + 6.1.3 + 1.5.0 https://ignite.apache.org + + + + + org.junit + junit-bom + ${junit.version} + pom + import + + + + ${project.groupId} @@ -211,6 +227,12 @@ ignite-core test-jar test + + + junit + junit + + @@ -253,6 +275,70 @@ test + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + + + + com.tngtech.archunit + archunit-junit5 + ${archunit.version} + test + + + + org.junit.platform + junit-platform-suite-api + ${junit.version} + test + + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + org.junit.platform + junit-platform-engine + ${junit.version} + test + + + + org.junit.platform + junit-platform-launcher + ${junit.version} + test + + + + org.junit.platform + junit-platform-suite-engine + ${junit.version} + test + + + + + org.junit.vintage + junit-vintage-engine + ${junit.version} + test + + io.trino.tpch tpch diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityValueColumnAliasTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityValueColumnAliasTest.java index 180f72a672333..88afe36745382 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityValueColumnAliasTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityValueColumnAliasTest.java @@ -26,11 +26,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; +import org.junit.jupiter.api.Test; /** */ -public class QueryEntityValueColumnAliasTest extends GridCommonAbstractTest { +public class QueryEntityValueColumnAliasTest extends GridCommonAbstractWrapperTest { /** */ private static final String CACHE_NAME = "cache"; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/SessionContextSqlFunctionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/SessionContextSqlFunctionTest.java index 466e3a5086806..86c8618fef037 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/SessionContextSqlFunctionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/SessionContextSqlFunctionTest.java @@ -28,18 +28,23 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.resources.SessionContextProviderResource; import org.apache.ignite.session.SessionContext; import org.apache.ignite.session.SessionContextProvider; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** */ -@RunWith(Parameterized.class) -public class SessionContextSqlFunctionTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "mode={0}, isClnNode={1}") +@MethodSource("parameters") +public class SessionContextSqlFunctionTest extends GridCommonAbstractWrapperTest { /** */ private static final String SESSION_ID = "sessionId"; @@ -47,21 +52,21 @@ public class SessionContextSqlFunctionTest extends GridCommonAbstractTest { private Ignite ign; /** */ - @Parameterized.Parameter + @Parameter(0) public CacheAtomicityMode mode; /** */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean isClnNode; /** */ - @Parameterized.Parameters(name = "mode={0}, isClnNode={1}") - public static List parameters() { - List params = new ArrayList<>(); + @MethodSource("parameters") + private static List parameters() { + List params = new ArrayList<>(); for (CacheAtomicityMode m: CacheAtomicityMode.values()) { - params.add(new Object[] {m, false}); - params.add(new Object[] {m, true}); + params.add(Arguments.of(m, false)); + params.add(Arguments.of(m, true)); } return params; @@ -82,8 +87,9 @@ public static List parameters() { return cfg; } - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + /** */ + @BeforeEach + void setup() throws Exception { ign = startGrids(3); if (isClnNode) @@ -93,6 +99,7 @@ public static List parameters() { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() { stopAllGrids(); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorPropertiesTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorPropertiesTest.java index bd0f3646d741e..2b6cbcc263e6b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorPropertiesTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorPropertiesTest.java @@ -34,8 +34,7 @@ import org.apache.ignite.spi.metric.LongMetric; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.QueryParserMetricsHolder.QUERY_PARSER_METRIC_GROUP_NAME; import static org.apache.ignite.internal.processors.query.calcite.DistributedCalciteConfiguration.DFLT_PLAN_CACHE_SIZE; import static org.apache.ignite.internal.processors.query.calcite.DistributedCalciteConfiguration.DFLT_RECURSIVE_CTE_ITERATION_LIMIT; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java index 5c54c4cad4252..5408f05b29d21 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java @@ -57,10 +57,13 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.awaitReservationsRelease; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsIndexScan; @@ -69,13 +72,14 @@ import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "false") -public class CalciteQueryProcessorTest extends GridCommonAbstractTest { +public class CalciteQueryProcessorTest extends GridCommonAbstractWrapperTest { /** */ private static IgniteEx client; @@ -96,6 +100,7 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { startGrids(5); @@ -103,6 +108,7 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws InterruptedException { for (Ignite ign : G.allGrids()) { for (String cacheName : ign.cacheNames()) @@ -117,11 +123,6 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest { awaitPartitionMapExchange(); } - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() { - stopAllGrids(); - } - /** * Test verifies that replicated cache with specified cache group * could be properly mapped on server nodes. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java index da4dfdd1d87c2..bf8dc44615638 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java @@ -35,9 +35,9 @@ import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static java.util.Collections.singletonList; import static org.apache.ignite.cache.query.QueryCancelledException.ERR_MSG; @@ -46,9 +46,10 @@ /** * Cancel query test. */ -public class CancelTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { +public class CancelTest extends GridCommonAbstractWrapperTest { + /** */ + @BeforeEach + void setup() throws Exception { startGrids(2); IgniteCache c = grid(0).cache("TEST"); @@ -57,6 +58,7 @@ public class CancelTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -153,7 +155,7 @@ public void testNotOriginatorNodeStop() throws Exception { fail("Unexpected exception: " + ex); } - Assert.assertTrue(GridTestUtils.waitForCondition( + assertTrue(GridTestUtils.waitForCondition( () -> engine.runningQueries().isEmpty(), 10_000)); awaitReservationsRelease(grid(0), "TEST"); @@ -180,7 +182,7 @@ public void testOriginatorNodeStop() throws Exception { CalciteQueryProcessor engine1 = (CalciteQueryProcessor)Commons.lookupComponent( grid(1).context(), QueryEngine.class); - Assert.assertTrue(GridTestUtils.waitForCondition( + assertTrue(GridTestUtils.waitForCondition( () -> engine1.runningQueries().isEmpty(), 10_000)); awaitReservationsRelease(grid(1), "TEST"); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/GridCommonAbstractWrapperTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/GridCommonAbstractWrapperTest.java new file mode 100644 index 0000000000000..c4ee3ad71ec22 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/GridCommonAbstractWrapperTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.query.calcite; + +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestInstance; + +import static org.apache.ignite.tools.junit.JUnitTeamcityReporter.escapeForTeamcity; + +/** */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class GridCommonAbstractWrapperTest extends GridCommonAbstractTest { + /** */ + @BeforeEach + void beforeTest(TestInfo testInfo) { + printTestName(testInfo, true); + } + + /** */ + @AfterEach + void afterTest(TestInfo testInfo) { + printTestName(testInfo, false); + } + + /** Get and print the display name of the upcoming test. */ + private void printTestName(TestInfo testInfo, boolean start) { + // Get and print the display name of the upcoming test + String testName = testInfo.getDisplayName(); + String testCls = testInfo.getTestClass().orElse(Object.class).getSimpleName(); + + String testFullName = escapeForTeamcity(testCls + "#" + testName); + + if (start) + U.quietAndInfo(log(), ">>> Starting test: " + testFullName + " <<<"); + else + U.quietAndInfo(log(), ">>> Stopping test: " + testFullName + " <<<"); + } + + /** */ + @BeforeAll + void init() { + beforeFirstTest0(); + } + + /** {@inheritDoc} */ + @AfterAll + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java index 67534cee626f1..5cdb7ebcad41c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java @@ -54,9 +54,9 @@ import org.hamcrest.core.SubstringMatcher; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Query checker. @@ -217,36 +217,56 @@ public static Matcher containsSubPlan(String subPlan) { /** */ public static Matcher matches(final String substring) { - return new SubstringMatcher(substring) { + return new SubstringMatcher("contains", false, substring) { /** {@inheritDoc} */ @Override protected boolean evalSubstringOf(String sIn) { sIn = sIn.replaceAll("\n", ""); return sIn.matches(substring); } + }; + } + /** Matches only one occurrence. */ + static Matcher matchesOnce(String pattern) { + return occursTimes(pattern, 1, true); + } + + /** Has specified number of occurrence. */ + static Matcher occursTimes(String pattern, int times, boolean noMore) { + return new SubstringMatcher(resolveRelation(times, noMore), false, pattern) { /** {@inheritDoc} */ - @Override protected String relationship() { - return null; + @Override protected boolean evalSubstringOf(String strIn) { + strIn = strIn.replaceAll(System.lineSeparator(), ""); + + return contains(strIn, substring, times, noMore); } }; } - /** Matches only one occurance. */ - public static Matcher matchesOnce(final String substring) { - return new SubstringMatcher(substring) { - /** {@inheritDoc} */ - @Override protected boolean evalSubstringOf(String sIn) { - sIn = sIn.replaceAll("\n", ""); + /** */ + private static String resolveRelation(int times, boolean noMore) { + assert times >= 0; - return containsOnce(sIn, substring); - } + return switch (times) { + case 0 -> noMore ? "does not contain" : "can contain"; + case 1 -> noMore ? "contains once" : "contains only once"; + default -> (noMore ? "contains " : "contains only ") + times + " times"; + }; + } - /** {@inheritDoc} */ - @Override protected String relationship() { - return null; + /** Check that {@code s} contains {@code substring} {@code times} times. */ + static boolean contains(String s, CharSequence substring, int times, boolean noMore) { + Pattern pattern = Pattern.compile(substring.toString()); + java.util.regex.Matcher matcher = pattern.matcher(s); + + for (int i = 0; i < times; i++) { + if (!matcher.find()) { + return false; // Not enough occurrences } - }; + } + + return !noMore || !matcher.find(); } /** Check only single matching. */ @@ -466,7 +486,7 @@ public void check() { res = cur.getAll(); if (expectedResultSize >= 0) - assertEquals("Unexpected result size", expectedResultSize, res.size()); + assertEquals(expectedResultSize, res.size(), "Unexpected result size"); if (resultChecker != null) resultChecker.accept(res); @@ -491,7 +511,7 @@ public void check() { * @param act Actual collection. */ private void assertEqualsCollections(Collection exp, Collection act) { - assertEquals("Collections sizes are not equal:\nExpected: " + exp + "\nActual: " + act, exp.size(), act.size()); + assertEquals(exp.size(), act.size(), "Collections sizes are not equal:\nExpected: " + exp + "\nActual: " + act); Iterator it1 = exp.iterator(); Iterator it2 = act.iterator(); @@ -581,6 +601,6 @@ public static void awaitReservationsRelease(IgniteEx node, String cacheName) thr }, PART_RELEASE_TIMEOUT); for (GridDhtLocalPartition p : parts) - assertEquals("Partition is reserved: [node=" + node.name() + ", part=" + p, 0, p.reservations()); + assertEquals(0, p.reservations(), "Partition is reserved: [node=" + node.name() + ", part=" + p); } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryCheckerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryCheckerTest.java index d125e3ddb0892..22bce273a7e3a 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryCheckerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryCheckerTest.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.query.calcite; import org.hamcrest.Matcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsResultRowCount; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.matchesOnce; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** Query checker tests. */ public class QueryCheckerTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java index 1eb9bb7626864..85791cf5deef5 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java @@ -27,14 +27,14 @@ import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.AfterClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static java.util.Collections.singletonList; /** */ -public class SqlFieldsQueryUsageTest extends GridCommonAbstractTest { +public class SqlFieldsQueryUsageTest extends GridCommonAbstractWrapperTest { /** */ private static IgniteEx client; @@ -44,15 +44,16 @@ public class SqlFieldsQueryUsageTest extends GridCommonAbstractTest { new SqlConfiguration().setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration())); } - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { + /** */ + @BeforeAll + void setup() throws Exception { startGrids(1); client = startClientGrid(); } /** */ - @AfterClass + @AfterAll public static void tearDown() { G.stopAll(false); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolderTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolderTest.java index 0310edd80499e..6ebe500178f77 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolderTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/ClosableIteratorsHolderTest.java @@ -23,17 +23,16 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * */ -public class ClosableIteratorsHolderTest extends GridCommonAbstractTest { +public class ClosableIteratorsHolderTest extends GridCommonAbstractWrapperTest { /** */ private static final int GENERATED = 10000; @@ -44,7 +43,7 @@ public class ClosableIteratorsHolderTest extends GridCommonAbstractTest { private ClosableIteratorsHolder holder; /** */ - @Before + @BeforeEach public void setup() throws Exception { iterators = Collections.newSetFromMap(new ConcurrentHashMap<>()); holder = new ClosableIteratorsHolder(log()); @@ -52,7 +51,7 @@ public void setup() throws Exception { } /** */ - @After + @AfterEach public void tearDown() throws Exception { holder.tearDown(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/KeyFilteringCursorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/KeyFilteringCursorTest.java index a5f8bb514d821..dfcc96c51660f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/KeyFilteringCursorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/KeyFilteringCursorTest.java @@ -39,9 +39,8 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.lang.GridCursor; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** */ public class KeyFilteringCursorTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/LogicalRelImplementorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/LogicalRelImplementorTest.java index 3e87461ea0bdf..a0563bf1e8b41 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/LogicalRelImplementorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/LogicalRelImplementorTest.java @@ -38,6 +38,7 @@ import org.apache.calcite.util.ImmutableBitSet; import org.apache.calcite.util.mapping.Mappings; import org.apache.ignite.internal.processors.query.QueryUtils; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.exec.exp.RangeIterable; import org.apache.ignite.internal.processors.query.calcite.exec.rel.CollectNode; import org.apache.ignite.internal.processors.query.calcite.exec.rel.IndexSpoolNode; @@ -62,16 +63,15 @@ import org.apache.ignite.internal.processors.query.calcite.util.RexUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.tools.Frameworks.createRootSchema; /** * Test LogicalRelImplementor class. */ -public class LogicalRelImplementorTest extends GridCommonAbstractTest { +public class LogicalRelImplementorTest extends GridCommonAbstractWrapperTest { /** */ private LogicalRelImplementor relImplementor; @@ -91,8 +91,9 @@ public class LogicalRelImplementorTest extends GridCommonAbstractTest { private IgniteTypeFactory tf; /** */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); + @BeforeEach + void setup() throws Exception { + beforeTest(); tf = Commons.typeFactory(); RelDataTypeFactory.Builder b = new RelDataTypeFactory.Builder(tf); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/NumericTypesPrecisionsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/NumericTypesPrecisionsTest.java index e582e24b72ac8..496820c988e7d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/NumericTypesPrecisionsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/NumericTypesPrecisionsTest.java @@ -24,9 +24,9 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.processors.query.calcite.util.Commons; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** Test for numeric types precisions. */ public class NumericTypesPrecisionsTest { @@ -196,7 +196,7 @@ private static void doTestExpectedLeastRestrictive(RelDataType testType, RelData for (int i = 0; i < TEST_SUITE.length; ++i) { RelDataType actualType = TYPE_FACTORY.leastRestrictive(Arrays.asList(testType, TEST_SUITE[i])); - assertEquals("leastRestrictive(" + testType + ", " + TEST_SUITE[i] + ")", expectedLeast[i], actualType); + assertEquals(expectedLeast[i], actualType, "leastRestrictive(" + testType + ", " + TEST_SUITE[i] + ")"); } } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/RuntimeSortedIndexTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/RuntimeSortedIndexTest.java index 66dfd58362f74..868008d95f888 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/RuntimeSortedIndexTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/RuntimeSortedIndexTest.java @@ -30,19 +30,19 @@ import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.calcite.util.ImmutableIntList; import org.apache.calcite.util.Pair; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.exec.tracker.NoOpIoTracker; import org.apache.ignite.internal.processors.query.calcite.exec.tracker.NoOpMemoryTracker; import org.apache.ignite.internal.processors.query.calcite.prepare.BaseQueryContext; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.lang.GridCursor; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * */ -public class RuntimeSortedIndexTest extends GridCommonAbstractTest { +public class RuntimeSortedIndexTest extends GridCommonAbstractWrapperTest { /** */ private static final int UNIQUE_GROUPS = 10_000; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteSqlFunctionsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteSqlFunctionsTest.java index b6c1e4afd9353..ee9cd6d551cce 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteSqlFunctionsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteSqlFunctionsTest.java @@ -18,8 +18,11 @@ package org.apache.ignite.internal.processors.query.calcite.exec.exp; import java.math.BigDecimal; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @@ -28,70 +31,70 @@ public class IgniteSqlFunctionsTest { /** */ @Test public void testBigDecimalToString() { - Assert.assertNull(IgniteSqlFunctions.toString((BigDecimal)null)); + assertNull(IgniteSqlFunctions.toString((BigDecimal)null)); - Assert.assertEquals( + assertEquals( "10", IgniteSqlFunctions.toString(BigDecimal.valueOf(10)) ); - Assert.assertEquals( + assertEquals( "9223372036854775807", IgniteSqlFunctions.toString(BigDecimal.valueOf(Long.MAX_VALUE)) ); - Assert.assertEquals( + assertEquals( "340282350000000000000000000000000000000", IgniteSqlFunctions.toString(new BigDecimal(String.valueOf(Float.MAX_VALUE))) ); - Assert.assertEquals( + assertEquals( "-340282346638528860000000000000000000000", IgniteSqlFunctions.toString(BigDecimal.valueOf(-Float.MAX_VALUE)) ); } /** */ - @Test(expected = UnsupportedOperationException.class) + @Test public void testBooleanPrimitiveToBigDecimal() { - IgniteSqlFunctions.toBigDecimal(true, 10, 10); + assertThrows(UnsupportedOperationException.class, () -> IgniteSqlFunctions.toBigDecimal(true, 10, 10)); } /** */ - @Test(expected = UnsupportedOperationException.class) + @Test public void testBooleanObjectToBigDecimal() { - IgniteSqlFunctions.toBigDecimal(Boolean.valueOf(true), 10, 10); + assertThrows(UnsupportedOperationException.class, () -> IgniteSqlFunctions.toBigDecimal(Boolean.valueOf(true), 10, 10)); } /** */ @Test public void testPrimitiveToDecimal() { - Assert.assertEquals( + assertEquals( new BigDecimal(10), IgniteSqlFunctions.toBigDecimal((byte)10, 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal(10), IgniteSqlFunctions.toBigDecimal((short)10, 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal(10), IgniteSqlFunctions.toBigDecimal(10, 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.0"), IgniteSqlFunctions.toBigDecimal(10L, 10, 1) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.101"), IgniteSqlFunctions.toBigDecimal(10.101f, 10, 3) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.101"), IgniteSqlFunctions.toBigDecimal(10.101d, 10, 3) ); @@ -100,38 +103,38 @@ public void testPrimitiveToDecimal() { /** */ @Test public void testObjectToDecimal() { - Assert.assertNull(IgniteSqlFunctions.toBigDecimal((Object)null, 10, 0)); + assertNull(IgniteSqlFunctions.toBigDecimal((Object)null, 10, 0)); - Assert.assertNull(IgniteSqlFunctions.toBigDecimal((Double)null, 10, 0)); + assertNull(IgniteSqlFunctions.toBigDecimal((Double)null, 10, 0)); - Assert.assertNull(IgniteSqlFunctions.toBigDecimal((String)null, 10, 0)); + assertNull(IgniteSqlFunctions.toBigDecimal((String)null, 10, 0)); - Assert.assertEquals( + assertEquals( new BigDecimal(10), - IgniteSqlFunctions.toBigDecimal(new Byte("10"), 10, 0) + IgniteSqlFunctions.toBigDecimal(Byte.valueOf("10"), 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal(10), IgniteSqlFunctions.toBigDecimal(Short.valueOf("10"), 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal(10), IgniteSqlFunctions.toBigDecimal(Integer.valueOf(10), 10, 0) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.0"), IgniteSqlFunctions.toBigDecimal(Long.valueOf(10L), 10, 1) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.101"), IgniteSqlFunctions.toBigDecimal(Float.valueOf(10.101f), 10, 3) ); - Assert.assertEquals( + assertEquals( new BigDecimal("10.101"), IgniteSqlFunctions.toBigDecimal(Double.valueOf(10.101d), 10, 3) ); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionParametrizedTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionParametrizedTest.java new file mode 100644 index 0000000000000..c790a80a2ed27 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionParametrizedTest.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.query.calcite.exec.rel; + +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; + +/** */ +@ParameterizedClass(name = "Task executor = {0}, Execution strategy = {1}") +@MethodSource("parameters") +public class AbstractExecutionParametrizedTest extends AbstractExecutionTest{ +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java index b7f5880259be2..4f40c3e90a984 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractExecutionTest.java @@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.pool.PoolProcessor; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.QueryRegistryImpl; import org.apache.ignite.internal.processors.query.calcite.exec.ArrayRowHandler; import org.apache.ignite.internal.processors.query.calcite.exec.ExchangeService; @@ -66,26 +67,20 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.GridTestKernalContext; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.provider.Arguments; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_THREAD_KEEP_ALIVE_TIME; /** * */ -@RunWith(Parameterized.class) -public class AbstractExecutionTest extends GridCommonAbstractTest { +public class AbstractExecutionTest extends GridCommonAbstractWrapperTest { /** Last parameter number. */ protected static final int LAST_PARAM_NUM = 1; - /** Params string. */ - protected static final String PARAMS_STRING = "Task executor = {0}, Execution strategy = {1}"; - /** */ public static final int IN_BUFFER_SIZE = AbstractNode.IN_BUFFER_SIZE; @@ -156,9 +151,21 @@ public T2 nextTask(Deque> tasks) { } } + /** Task executor. */ + @Parameter(0) + public TaskExecutorType taskExecutorType; + + /** Execution direction. */ + @Parameter(LAST_PARAM_NUM) + public ExecutionStrategy execStgy; + /** */ - @Parameterized.Parameters(name = PARAMS_STRING) - public static List parameters() { + public static Stream parameters() { + return innerParams().stream().map(Arguments::of); + } + + /** */ + static List innerParams() { List params = Stream.of(ExecutionStrategy.values()) .map(s -> new Object[] {TaskExecutorType.STRIPED, s}) .collect(Collectors.toList()); @@ -168,16 +175,8 @@ public static List parameters() { return params; } - /** Task executor. */ - @Parameterized.Parameter - public TaskExecutorType taskExecutorType; - - /** Execution direction. */ - @Parameterized.Parameter(LAST_PARAM_NUM) - public ExecutionStrategy execStgy; - /** */ - @Before + @BeforeEach public void setup() throws Exception { nodes = IntStream.range(0, nodesCnt) .mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList()); @@ -311,7 +310,7 @@ public IgniteTestStripedThreadPoolExecutor( } /** */ - @After + @AfterEach public void tearDown() { taskExecutors.values().forEach(AbstractQueryTaskExecutor::tearDown); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractSetOpExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractSetOpExecutionTest.java index 452e1633c84e7..0e18f6ea8708a 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractSetOpExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/AbstractSetOpExecutionTest.java @@ -34,22 +34,22 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.MAP; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.REDUCE; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.SINGLE; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * Abstract test for set operator (MINUS, INTERSECT) execution. */ -public abstract class AbstractSetOpExecutionTest extends AbstractExecutionTest { +public abstract class AbstractSetOpExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -165,7 +165,7 @@ protected void checkSetOp(boolean single, boolean all, List> data assertTrue(F.isEmpty(expectedResult) || root.hasNext()); for (Object[] row : expectedResult) - Assert.assertArrayEquals(row, root.next()); + assertArrayEquals(row, root.next()); assertFalse(root.hasNext()); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/BaseAggregateTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/BaseAggregateTest.java index b0bfe89e9769b..60847bff97ac7 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/BaseAggregateTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/BaseAggregateTest.java @@ -26,7 +26,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.IntStream; -import java.util.stream.Stream; import com.google.common.collect.ImmutableList; import org.apache.calcite.rel.RelCollations; import org.apache.calcite.rel.core.AggregateCall; @@ -45,41 +44,46 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") +@ParameterizedClass(name = "Task executor = {0}, Execution strategy = {1}, testAgg={2}") +@MethodSource("data") public abstract class BaseAggregateTest extends AbstractExecutionTest { /** Last parameter number. */ protected static final int TEST_AGG_PARAM_NUM = LAST_PARAM_NUM + 1; /** */ - @Parameterized.Parameter(TEST_AGG_PARAM_NUM) + @Parameter(TEST_AGG_PARAM_NUM) public TestAggregateType testAgg; /** */ - @Parameterized.Parameters(name = PARAMS_STRING + ", type={" + TEST_AGG_PARAM_NUM + "}") - public static List data() { - List extraParams = new ArrayList<>(); + private static List data() { + List extraParams = new ArrayList<>(); - ImmutableList newParams = ImmutableList.of( - new Object[] {TestAggregateType.SINGLE}, - new Object[] {TestAggregateType.MAP_REDUCE} - ); - - for (Object[] newParam : newParams) { - for (Object[] inheritedParam : AbstractExecutionTest.parameters()) { - Object[] both = Stream.concat(Arrays.stream(inheritedParam), Arrays.stream(newParam)) - .toArray(Object[]::new); + for (TestAggregateType newParam : TestAggregateType.values()) { + for (Object[] inheritedParam : innerParams()) { + Object[] combined = new Object[1 + inheritedParam.length]; + System.arraycopy(inheritedParam, 0, combined, 0, inheritedParam.length); + combined[inheritedParam.length] = newParam; - extraParams.add(both); + Arguments res = Arguments.of(combined); + extraParams.add(res); } } @@ -89,7 +93,7 @@ public static List data() { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -138,8 +142,8 @@ public void count() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, 2), root.next()); - Assert.assertArrayEquals(row(1, 2), root.next()); + assertArrayEquals(row(0, 2), root.next()); + assertArrayEquals(row(1, 2), root.next()); assertFalse(root.hasNext()); } @@ -187,8 +191,8 @@ public void min() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, 200), root.next()); - Assert.assertArrayEquals(row(1, 300), root.next()); + assertArrayEquals(row(0, 200), root.next()); + assertArrayEquals(row(1, 300), root.next()); assertFalse(root.hasNext()); } @@ -236,8 +240,8 @@ public void max() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, 1000), root.next()); - Assert.assertArrayEquals(row(1, 1400), root.next()); + assertArrayEquals(row(0, 1000), root.next()); + assertArrayEquals(row(1, 1400), root.next()); assertFalse(root.hasNext()); } @@ -285,8 +289,8 @@ public void avg() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, 600), root.next()); - Assert.assertArrayEquals(row(1, 800), root.next()); + assertArrayEquals(row(0, 600), root.next()); + assertArrayEquals(row(1, 800), root.next()); assertFalse(root.hasNext()); } @@ -375,8 +379,8 @@ public void singleAggr(List scanInput, Object[] output, boolean mustFa Runnable r = () -> { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, output[0]), root.next()); - Assert.assertArrayEquals(row(1, output[1]), root.next()); + assertArrayEquals(row(0, output[0]), root.next()); + assertArrayEquals(row(1, output[1]), root.next()); assertFalse(root.hasNext()); }; @@ -435,8 +439,8 @@ public void distinctSum() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, 1200), root.next()); - Assert.assertArrayEquals(row(1, 500), root.next()); + assertArrayEquals(row(0, 1200), root.next()); + assertArrayEquals(row(1, 500), root.next()); assertFalse(root.hasNext()); } @@ -550,7 +554,7 @@ public void sumIntegerOverflow() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, (long)Integer.MAX_VALUE / 2 + (long)Integer.MAX_VALUE / 2 + 11L), root.next()); + assertArrayEquals(row(0, (long)Integer.MAX_VALUE / 2 + (long)Integer.MAX_VALUE / 2 + 11L), root.next()); assertFalse(root.hasNext()); } @@ -596,7 +600,7 @@ public void sumLongOverflow() { assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0, new BigDecimal(Long.MAX_VALUE).add(new BigDecimal(10))), root.next()); + assertArrayEquals(row(0, new BigDecimal(Long.MAX_VALUE).add(new BigDecimal(10))), root.next()); assertFalse(root.hasNext()); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java index 435c8e6e670ee..cb29edcc73476 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ContinuousExecutionTest.java @@ -18,13 +18,12 @@ package org.apache.ignite.internal.processors.query.calcite.exec.rel; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Random; import java.util.UUID; -import java.util.stream.Stream; import com.google.common.collect.ImmutableList; import org.apache.calcite.rel.type.RelDataType; import org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl; @@ -35,15 +34,21 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; -import org.junit.Before; -import org.junit.Test; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * */ @SuppressWarnings("TypeMayBeWeakened") +@ParameterizedClass(name = "Task executor = {0}, Execution strategy = {1}, " + + "rowsCount={2}, " + + "remoteFragmentsCount={3}") +@MethodSource("params") public class ContinuousExecutionTest extends AbstractExecutionTest { /** Row count parameter number. */ protected static final int ROW_CNT_PARAM_NUM = LAST_PARAM_NUM + 1; @@ -60,11 +65,8 @@ public class ContinuousExecutionTest extends AbstractExecutionTest { public int remoteFragmentsCnt; /** */ - @Parameterized.Parameters(name = PARAMS_STRING + ", " + - "rowsCount={" + ROW_CNT_PARAM_NUM + "}, " + - "remoteFragmentsCount={" + REMOTE_FRAGMENTS_PARAM_NUM + "}") - public static List data() { - List extraParams = new ArrayList<>(); + public static Collection params() { + List extraParams = new ArrayList<>(); ImmutableList newParams = ImmutableList.of( new Object[] {10, 1}, @@ -79,11 +81,13 @@ public static List data() { ); for (Object[] newParam : newParams) { - for (Object[] inheritedParam : AbstractExecutionTest.parameters()) { - Object[] both = Stream.concat(Arrays.stream(inheritedParam), Arrays.stream(newParam)) - .toArray(Object[]::new); + for (Object[] inheritedParam : innerParams()) { + Object[] combined = new Object[newParam.length + inheritedParam.length]; + System.arraycopy(inheritedParam, 0, combined, 0, inheritedParam.length); + System.arraycopy(newParam, 0, combined, inheritedParam.length, newParam.length); - extraParams.add(both); + Arguments res = Arguments.of(combined); + extraParams.add(res); } } @@ -93,7 +97,7 @@ public static List data() { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = remoteFragmentsCnt + 1; super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java index 6ab1ea04565a9..63cb4af061d58 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java @@ -33,10 +33,11 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static java.lang.Math.max; import static java.lang.Math.min; @@ -47,17 +48,19 @@ import static org.apache.calcite.rel.core.JoinRelType.RIGHT; import static org.apache.calcite.rel.core.JoinRelType.SEMI; import static org.apache.ignite.internal.processors.query.calcite.util.Commons.getFieldFromBiRows; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class ExecutionTest extends AbstractExecutionTest { +public class ExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -122,8 +125,8 @@ public void testSimpleExecution() { assertEquals(2, rows.size()); - Assert.assertArrayEquals(new Object[] {2, "Ivan", "Calcite"}, rows.get(0)); - Assert.assertArrayEquals(new Object[] {2, "Ivan", "Ignite"}, rows.get(1)); + assertArrayEquals(new Object[] {2, "Ivan", "Calcite"}, rows.get(0)); + assertArrayEquals(new Object[] {2, "Ivan", "Ignite"}, rows.get(1)); } /** @@ -227,10 +230,10 @@ public void testLeftJoin() { assertEquals(4, rows.size()); - Assert.assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); - Assert.assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(1)); - Assert.assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(2)); - Assert.assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(3)); + assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); + assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(1)); + assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(2)); + assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(3)); } /** @@ -288,10 +291,10 @@ public void testRightJoin() { assertEquals(4, rows.size()); - Assert.assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); - Assert.assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(1)); - Assert.assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(2)); - Assert.assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(3)); + assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); + assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(1)); + assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(2)); + assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(3)); } /** @@ -349,11 +352,11 @@ public void testFullOuterJoin() { assertEquals(5, rows.size()); - Assert.assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); - Assert.assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(1)); - Assert.assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(2)); - Assert.assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(3)); - Assert.assertArrayEquals(new Object[] {null, null, "QA"}, rows.get(4)); + assertArrayEquals(new Object[] {0, "Igor", "Core"}, rows.get(0)); + assertArrayEquals(new Object[] {1, "Roman", "SQL"}, rows.get(1)); + assertArrayEquals(new Object[] {2, "Ivan", null}, rows.get(2)); + assertArrayEquals(new Object[] {3, "Alexey", "Core"}, rows.get(3)); + assertArrayEquals(new Object[] {null, null, "QA"}, rows.get(4)); } /** @@ -410,8 +413,8 @@ public void testSemiJoin() { assertEquals(2, rows.size()); - Assert.assertArrayEquals(new Object[] {"Core"}, rows.get(0)); - Assert.assertArrayEquals(new Object[] {"SQL"}, rows.get(1)); + assertArrayEquals(new Object[] {"Core"}, rows.get(0)); + assertArrayEquals(new Object[] {"SQL"}, rows.get(1)); } /** @@ -468,7 +471,7 @@ public void testAntiJoin() { assertEquals(1, rows.size()); - Assert.assertArrayEquals(new Object[] {"QA"}, rows.get(0)); + assertArrayEquals(new Object[] {"QA"}, rows.get(0)); } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java index 95b8ae9a4346e..c6fb167c07c35 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java @@ -36,18 +36,21 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Assert; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.MAP; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.REDUCE; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.SINGLE; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") public class HashAggregateExecutionTest extends BaseAggregateTest { /** {@inheritDoc} */ @@ -200,7 +203,7 @@ public void countOfEmptyWithRewind() { root.register(aggChain); assertTrue(root.hasNext()); - Assert.assertArrayEquals(row(0), root.next()); + assertArrayEquals(row(0), root.next()); assertFalse(root.hasNext()); aggChain.rewind(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateSingleGroupExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateSingleGroupExecutionTest.java index 1b4ee59c5bb7b..65cbb108beab5 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateSingleGroupExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateSingleGroupExecutionTest.java @@ -39,9 +39,11 @@ import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Before; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.MAP; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.REDUCE; @@ -51,12 +53,13 @@ * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class HashAggregateSingleGroupExecutionTest extends AbstractExecutionTest { +public class HashAggregateSingleGroupExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -452,7 +455,6 @@ public void singleMax() { assertFalse(root.hasNext()); } - /** */ @Test public void singleCount() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashIndexSpoolExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashIndexSpoolExecutionTest.java index 5536e48439fcd..9ceff6d05e781 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashIndexSpoolExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashIndexSpoolExecutionTest.java @@ -30,20 +30,23 @@ import org.apache.ignite.internal.util.lang.GridTuple3; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class HashIndexSpoolExecutionTest extends AbstractExecutionTest { +public class HashIndexSpoolExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashJoinExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashJoinExecutionTest.java index d1a1e81c4d4ae..019dc0f42ca2d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashJoinExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashJoinExecutionTest.java @@ -31,8 +31,7 @@ import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.rel.core.JoinRelType.ANTI; import static org.apache.calcite.rel.core.JoinRelType.FULL; import static org.apache.calcite.rel.core.JoinRelType.INNER; @@ -41,7 +40,7 @@ import static org.apache.calcite.rel.core.JoinRelType.SEMI; /** */ -public class HashJoinExecutionTest extends AbstractExecutionTest { +public class HashJoinExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testHashJoinRewind() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/JoinBuffersExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/JoinBuffersExecutionTest.java index 0d52216bd9836..9a29c1c152483 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/JoinBuffersExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/JoinBuffersExecutionTest.java @@ -33,7 +33,7 @@ import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.calcite.rel.core.JoinRelType.ANTI; import static org.apache.calcite.rel.core.JoinRelType.FULL; @@ -43,7 +43,7 @@ import static org.apache.calcite.rel.core.JoinRelType.SEMI; /** Tests that buffers of join nodes are cleared at the join end and that a join node is not stuck. */ -public class JoinBuffersExecutionTest extends AbstractExecutionTest { +public class JoinBuffersExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testMergeJoinBuffers() throws Exception { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/LimitExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/LimitExecutionTest.java index fda6deaacc92a..d732f61f3646c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/LimitExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/LimitExecutionTest.java @@ -28,12 +28,12 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test LimitNode execution. */ -public class LimitExecutionTest extends AbstractExecutionTest { +public class LimitExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testLimit() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/MergeJoinExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/MergeJoinExecutionTest.java index c54b1225474a4..da81912bdff45 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/MergeJoinExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/MergeJoinExecutionTest.java @@ -27,9 +27,8 @@ import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.rel.core.JoinRelType.ANTI; import static org.apache.calcite.rel.core.JoinRelType.FULL; @@ -37,18 +36,19 @@ import static org.apache.calcite.rel.core.JoinRelType.LEFT; import static org.apache.calcite.rel.core.JoinRelType.RIGHT; import static org.apache.calcite.rel.core.JoinRelType.SEMI; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; /** */ @SuppressWarnings("TypeMayBeWeakened") -public class MergeJoinExecutionTest extends AbstractExecutionTest { +public class MergeJoinExecutionTest extends AbstractExecutionParametrizedTest { /** */ public static final Object[][] EMPTY = new Object[0][]; /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -452,7 +452,7 @@ else if (o2 != null) while (node.hasNext()) rows.add(node.next()); - Assert.assertThat(rows.toArray(EMPTY), equalTo(expRes)); + assertThat(rows.toArray(EMPTY), equalTo(expRes)); } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/NestedLoopJoinExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/NestedLoopJoinExecutionTest.java index d9a00d6823366..bf13826b72bb6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/NestedLoopJoinExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/NestedLoopJoinExecutionTest.java @@ -28,10 +28,11 @@ import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.calcite.rel.core.JoinRelType.ANTI; import static org.apache.calcite.rel.core.JoinRelType.FULL; @@ -40,18 +41,20 @@ import static org.apache.calcite.rel.core.JoinRelType.RIGHT; import static org.apache.calcite.rel.core.JoinRelType.SEMI; import static org.apache.ignite.internal.processors.query.calcite.util.Commons.getFieldFromBiRows; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class NestedLoopJoinExecutionTest extends AbstractExecutionTest { +public class NestedLoopJoinExecutionTest extends AbstractExecutionParametrizedTest { /** */ public static final Object[][] EMPTY = new Object[0][]; /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); @@ -365,7 +368,7 @@ private void verifyJoin(Object[][] left, Object[][] right, JoinRelType joinType, while (node.hasNext()) rows.add(node.next()); - Assert.assertArrayEquals(expRes, rows.toArray(EMPTY)); + assertArrayEquals(expRes, rows.toArray(EMPTY)); } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ScanTableRowExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ScanTableRowExecutionTest.java index f88e46d1a3c5e..003ea61d362bf 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ScanTableRowExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ScanTableRowExecutionTest.java @@ -27,12 +27,12 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Execution test for ScanTableRowNode. */ -public class ScanTableRowExecutionTest extends AbstractExecutionTest { +public class ScanTableRowExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testScanTableRow() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortAggregateExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortAggregateExecutionTest.java index 2c556ac310a04..0ac41eb21b313 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortAggregateExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortAggregateExecutionTest.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.WithSystemProperty; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.MAP; import static org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType.REDUCE; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortedIndexSpoolExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortedIndexSpoolExecutionTest.java index 706ddcfc5b2d3..21a32e79b48ab 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortedIndexSpoolExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortedIndexSpoolExecutionTest.java @@ -35,21 +35,24 @@ import org.apache.ignite.internal.util.lang.GridTuple4; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T3; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class SortedIndexSpoolExecutionTest extends AbstractExecutionTest { +public class SortedIndexSpoolExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TableSpoolExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TableSpoolExecutionTest.java index 6db0c94d4b26d..461efb2940625 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TableSpoolExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TableSpoolExecutionTest.java @@ -28,10 +28,12 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static java.util.Collections.singletonList; @@ -39,12 +41,13 @@ * */ @SuppressWarnings("TypeMayBeWeakened") +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class TableSpoolExecutionTest extends AbstractExecutionTest { +public class TableSpoolExecutionTest extends AbstractExecutionParametrizedTest { /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TimeCalculationExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TimeCalculationExecutionTest.java index e13b1a5a17741..b978186e0062f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TimeCalculationExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/TimeCalculationExecutionTest.java @@ -27,12 +27,12 @@ import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test execution/idle time calculation. */ -public class TimeCalculationExecutionTest extends AbstractExecutionTest { +public class TimeCalculationExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testTime() throws Exception { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/UncollectExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/UncollectExecutionTest.java index a5835a82005de..a5cf492e47e27 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/UncollectExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/UncollectExecutionTest.java @@ -31,12 +31,12 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test for UNCOLLECT node execution. */ -public class UncollectExecutionTest extends AbstractExecutionTest { +public class UncollectExecutionTest extends AbstractExecutionParametrizedTest { /** */ @Test public void testCollectionSizes() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/WindowExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/WindowExecutionTest.java index bf409bde84b22..6abff318bd81c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/WindowExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/WindowExecutionTest.java @@ -50,16 +50,15 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.TypeUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.rex.RexWindowBounds.CURRENT_ROW; import static org.apache.calcite.rex.RexWindowBounds.UNBOUNDED_FOLLOWING; import static org.apache.calcite.rex.RexWindowBounds.UNBOUNDED_PRECEDING; /** */ -public class WindowExecutionTest extends AbstractExecutionTest { +public class WindowExecutionTest extends AbstractExecutionParametrizedTest { /** row_number() over (partition by {0}). */ @Test public void testRowNumber() { @@ -530,7 +529,7 @@ private void checkWindow( Node input, Object[][] expRes ) { - Assert.assertEquals(streaming, WindowFunctions.streamable(grp)); + assertEquals(streaming, WindowFunctions.streamable(grp)); WindowNode window = createWindowNode(ctx, grp, input); @@ -623,7 +622,7 @@ private Node createSeqInputNode(ExecutionContext ctx, int si /** * @throws Exception If failed. */ - @Before + @BeforeEach @Override public void setup() throws Exception { nodesCnt = 1; super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryBlockingTaskExecutorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryBlockingTaskExecutorTest.java index 22d354b6180d5..dce280f3aa375 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryBlockingTaskExecutorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryBlockingTaskExecutorTest.java @@ -25,14 +25,14 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.pool.PoolProcessor; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.security.NoOpIgniteSecurityProcessor; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.GridTestKernalContext; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** */ -public class QueryBlockingTaskExecutorTest extends GridCommonAbstractTest { +public class QueryBlockingTaskExecutorTest extends GridCommonAbstractWrapperTest { /** Tests that tasks for different queries can be executed concurrently. */ @Test public void testConcurrentTasks() throws Exception { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryTasksQueueTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryTasksQueueTest.java index e132d4fd68323..923cbee7d9a52 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryTasksQueueTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/task/QueryTasksQueueTest.java @@ -21,12 +21,12 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** Tests QueryTasksQueue data structure. */ -public class QueryTasksQueueTest extends GridCommonAbstractTest { +public class QueryTasksQueueTest extends GridCommonAbstractWrapperTest { /** */ @Test public void testQueryBlockingUnblocking() throws Exception { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/tracker/MemoryTrackerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/tracker/MemoryTrackerTest.java index f45b4c574acfb..a5a1f9dc0a441 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/tracker/MemoryTrackerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/tracker/MemoryTrackerTest.java @@ -21,14 +21,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * */ -public class MemoryTrackerTest extends GridCommonAbstractTest { +public class MemoryTrackerTest extends GridCommonAbstractWrapperTest { /** */ @Test public void testBatchesAllocation() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java index e471b6c80e40b..d5ebda2f85f1d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java @@ -19,6 +19,8 @@ import java.util.Collections; import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.calcite.plan.RelOptCluster; import org.apache.calcite.rel.RelCollation; import org.apache.calcite.rex.RexNode; @@ -37,6 +39,7 @@ import org.apache.ignite.internal.processors.query.QueryContext; import org.apache.ignite.internal.processors.query.QueryEngine; import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl; @@ -51,9 +54,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import static org.apache.ignite.internal.processors.authentication.AuthenticationProcessorSelfTest.authenticate; import static org.apache.ignite.internal.processors.authentication.User.DFAULT_USER_NAME; @@ -64,7 +68,7 @@ /** * */ -public class AbstractBasicIntegrationTest extends GridCommonAbstractTest { +public class AbstractBasicIntegrationTest extends GridCommonAbstractWrapperTest { /** */ protected static final Object[] NULL_RESULT = new Object[] { null }; @@ -75,6 +79,7 @@ public class AbstractBasicIntegrationTest extends GridCommonAbstractTest { protected static IgniteEx client; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { cleanPersistenceDir(); @@ -88,6 +93,23 @@ protected boolean destroyCachesAfterTest() { return true; } + /** */ + @AfterEach + public void runAfterTest() throws Exception { + AtomicBoolean afterTestFinished = new AtomicBoolean(false); + + ScheduledExecutorService scheduler = scheduleThreadDumpOnAfterTestTimeOut(afterTestFinished); + + try { + afterTest(); + } + finally { + afterTestFinished.set(true); + + scheduler.shutdownNow(); + } + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTransactionalTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTransactionalTest.java index f35e2c29a01d1..6b5c5ee315379 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTransactionalTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTransactionalTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -35,23 +35,31 @@ import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.testframework.SupplierX; import org.apache.ignite.transactions.Transaction; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "sqlTxMode={0}") +@MethodSource("parameters") public abstract class AbstractBasicIntegrationTransactionalTest extends AbstractBasicIntegrationTest { /** */ - @Parameterized.Parameter() + @Parameter(0) public SqlTransactionMode sqlTxMode; /** @return Test parameters. */ - @Parameterized.Parameters(name = "sqlTxMode={0}") - public static Collection parameters() { - return Arrays.asList(SqlTransactionMode.values()); + private static Collection parameters() { + Collection params = new ArrayList<>(); + for (SqlTransactionMode mode : SqlTransactionMode.values()) { + params.add(Arguments.of(mode)); + } + return params; } /** */ @@ -71,6 +79,7 @@ public static Collection parameters() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { if (currentMode != null && sqlTxMode == currentMode) return; @@ -84,7 +93,6 @@ public static Collection parameters() { init(); } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { clearTransaction(); @@ -93,6 +101,7 @@ public static Collection parameters() { } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() throws Exception { clearTransaction(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractDdlIntegrationTest.java index 2a4a6c5b280c2..d959207eb99b1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractDdlIntegrationTest.java @@ -22,7 +22,9 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; -import org.junit.After; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; /** */ public class AbstractDdlIntegrationTest extends AbstractBasicIntegrationTest { @@ -38,6 +40,7 @@ public class AbstractDdlIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -45,6 +48,7 @@ public class AbstractDdlIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() throws Exception { super.afterTestsStopped(); @@ -68,7 +72,7 @@ public class AbstractDdlIntegrationTest extends AbstractBasicIntegrationTest { } /** */ - @After + @AfterEach public void cleanUp() { client.destroyCaches(client.cacheNames()); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractMultiEngineIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractMultiEngineIntegrationTest.java index 119bebfce4ae7..a163fa7bfe970 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractMultiEngineIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractMultiEngineIntegrationTest.java @@ -16,8 +16,6 @@ */ package org.apache.ignite.internal.processors.query.calcite.integration; -import java.util.Arrays; -import java.util.Collection; import java.util.List; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; @@ -25,23 +23,21 @@ import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.CsvSource; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "Query engine={0}") +@CsvSource({CalciteQueryEngineConfiguration.ENGINE_NAME, IndexingQueryEngineConfiguration.ENGINE_NAME}) public class AbstractMultiEngineIntegrationTest extends AbstractBasicIntegrationTest { /** */ - @Parameterized.Parameter - public String engine; - - /** */ - @Parameterized.Parameters(name = "Query engine={0}") - public static Collection params() { - return Arrays.asList(CalciteQueryEngineConfiguration.ENGINE_NAME, IndexingQueryEngineConfiguration.ENGINE_NAME); - } + @Parameter(0) + String engine; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AggregatesIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AggregatesIntegrationTest.java index 7b0b9685e47e5..71f52e885d7cf 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AggregatesIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AggregatesIntegrationTest.java @@ -29,8 +29,8 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @@ -118,7 +118,7 @@ public void testCountWithBackupsAndCacheModes() { } /** */ - @Ignore("https://issues.apache.org/jira/browse/IGNITE-25765") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-25765") @Test public void testArrayConcatAgg() { sql("CREATE TABLE tarr(val INT, arrn INTEGER ARRAY, arrnn INTEGER ARRAY NOT NULL, arrn2 INTEGER ARRAY) WITH " diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AuthorizationIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AuthorizationIntegrationTest.java index 677728b3089a3..18a415939b631 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AuthorizationIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AuthorizationIntegrationTest.java @@ -46,10 +46,15 @@ import org.apache.ignite.plugin.security.SecurityPermissionSet; import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.AfterAll; +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.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED; import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_CREATE; @@ -63,7 +68,9 @@ /** * Test authorization of different operations. */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "allowDdl = {0}") +@MethodSource("parameters") +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AuthorizationIntegrationTest extends AbstractSecurityTest { /** */ private static final String LOGIN = "client"; @@ -87,15 +94,29 @@ public class AuthorizationIntegrationTest extends AbstractSecurityTest { private static final AtomicInteger removeCnt = new AtomicInteger(); /** */ - @Parameterized.Parameter + @Parameter(0) public boolean allowDdl; /** */ - @Parameterized.Parameters(name = "allowDdl = {0}") + @MethodSource("parameters") public static Iterable parameters() { return Arrays.asList(false, true); } + /** */ + @BeforeAll + static void init() { + beforeFirstTest0(); + } + + /** {@inheritDoc} */ + @AfterAll + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) @@ -112,6 +133,7 @@ public static Iterable parameters() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -147,6 +169,7 @@ public static Iterable parameters() { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/BulkOperationDeadlockIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/BulkOperationDeadlockIntegrationTest.java index 85abb91b5d835..d88f012c85a26 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/BulkOperationDeadlockIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/BulkOperationDeadlockIntegrationTest.java @@ -42,8 +42,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionIsolation; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -74,6 +75,7 @@ public class BulkOperationDeadlockIntegrationTest extends AbstractBasicIntegrati } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -122,7 +124,7 @@ public void testSelectForUpdateWithOppositeOrderDoesNotDeadlock() { } /** Concurrent updates lock rows produced by an unordered scan without deadlocks. */ - @Ignore("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") + @Disabled("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") @Test public void testUpdateWithWhereDoesNotDeadlock() { runConcurrentBulkOperation( @@ -139,7 +141,7 @@ public void testUpdateWithWhereDoesNotDeadlock() { } /** Concurrent putAll operations lock keys in opposite map iteration orders without deadlocks. */ - @Ignore("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") + @Disabled("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") @Test public void testPutAllWithOppositeKeyOrderDoesNotDeadlock() { runConcurrentBulkOperation( @@ -158,7 +160,7 @@ public void testPutAllWithOppositeKeyOrderDoesNotDeadlock() { } /** Concurrent getAll operations lock keys in opposite set iteration orders without deadlocks. */ - @Ignore("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") + @Disabled("IGNITE-28958 Prevent deadlocks in concurrent bulk operations with different key orders") @Test public void testGetAllWithOppositeKeyOrderDoesNotDeadlock() { runConcurrentBulkOperation( diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheStoreTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheStoreTest.java index 948a34f9f35c6..0e48feb29dc92 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheStoreTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheStoreTest.java @@ -18,47 +18,71 @@ package org.apache.ignite.internal.processors.query.calcite.integration; import java.io.Serializable; -import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Stream; import javax.cache.Cache; import javax.cache.configuration.FactoryBuilder; import javax.cache.integration.CacheWriterException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; -import org.junit.runners.Parameterized; - -import static java.util.Arrays.asList; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct; /** */ -public class CacheStoreTest extends AbstractMultiEngineIntegrationTest { +@ParameterizedClass(name = "Engine={0}, atomicityMode={1}, cacheMode={2}, backups={3}, loadPreviousValue={4}") +@MethodSource("parameters") +public class CacheStoreTest extends AbstractBasicIntegrationTest { + /** */ + @Parameter(0) + String engine; + /** */ - @Parameterized.Parameter(1) + @Parameter(1) public CacheAtomicityMode atomicityMode; /** */ - @Parameterized.Parameter(2) + @Parameter(2) public CacheMode cacheMode; /** */ - @Parameterized.Parameter(3) + @Parameter(3) public int backups; /** */ - @Parameterized.Parameter(4) + @Parameter(4) public boolean loadPreviousValue; + /** {@inheritDoc} */ + @BeforeAll + @Override protected void beforeTestsStarted() throws Exception { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + writeThroughEntries.clear(); + readThroughEntries.clear(); + } + /** */ private static final List writeThroughEntries = new CopyOnWriteArrayList<>(); @@ -66,20 +90,22 @@ public class CacheStoreTest extends AbstractMultiEngineIntegrationTest { private static final List readThroughEntries = new CopyOnWriteArrayList<>(); /** */ - @Parameterized.Parameters(name = "Engine={0}, atomicityMode={1}, cacheMode={2}, backups={3}, loadPreviousValue={4}") - public static Collection params() { + private static Stream parameters() { return cartesianProduct( - asList(CalciteQueryEngineConfiguration.ENGINE_NAME, IndexingQueryEngineConfiguration.ENGINE_NAME), - asList(CacheAtomicityMode.ATOMIC, CacheAtomicityMode.TRANSACTIONAL), - asList(CacheMode.PARTITIONED, CacheMode.REPLICATED), - asList(0, 1), - asList(false, true) - ); + List.of(CalciteQueryEngineConfiguration.ENGINE_NAME, IndexingQueryEngineConfiguration.ENGINE_NAME), + List.of(CacheAtomicityMode.ATOMIC, CacheAtomicityMode.TRANSACTIONAL), + List.of(CacheMode.PARTITIONED, CacheMode.REPLICATED), + List.of(0, 1), + List.of(false, true) + ).stream().map(Arguments::of); } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) + .setSqlConfiguration(new SqlConfiguration() + .setQueryEnginesConfiguration(engine.equals(CalciteQueryEngineConfiguration.ENGINE_NAME) ? + new CalciteQueryEngineConfiguration() : new IndexingQueryEngineConfiguration())); cfg.setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME) .setBackups(backups) @@ -101,14 +127,6 @@ public static Collection params() { return cfg; } - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - writeThroughEntries.clear(); - readThroughEntries.clear(); - } - /** */ @Test public void testCacheStoreOnDML() throws Exception { @@ -150,6 +168,12 @@ public void testCacheStoreOnDML() throws Exception { checkReadThrough(1002, 1003, 1004); } + /** */ + @Override protected List> sql(IgniteEx ignite, String sql, Object... params) { + return ignite.context().query().querySqlFields(new SqlFieldsQuery(sql).setArgs(params), true) + .getAll(); + } + /** */ private void checkWriteThrough(Object... keys) { assertEqualsCollectionsIgnoringOrder(F.asList(keys), writeThroughEntries); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheWithInterceptorIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheWithInterceptorIntegrationTest.java index 94342b8d58895..25040862f7e52 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheWithInterceptorIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CacheWithInterceptorIntegrationTest.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.query.calcite.integration; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.binary.BinaryObject; @@ -32,33 +32,36 @@ import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** Cache interceptor related tests. */ -@RunWith(Parameterized.class) -public class CacheWithInterceptorIntegrationTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "keepBinary={0}") +@MethodSource("parameters") +public class CacheWithInterceptorIntegrationTest extends GridCommonAbstractWrapperTest { /** Keep binary mode. */ - @Parameterized.Parameter(0) + @Parameter(0) public boolean keepBinary; /** */ - @Parameterized.Parameters(name = "keepBinary={0}") - public static Collection parameters() { - return List.of(true, false); + public static Stream parameters() { + return Stream.of(Arguments.of(true), Arguments.of(false)); } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteBasicSecondaryIndexIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteBasicSecondaryIndexIntegrationTest.java index 396eb28e8dc28..d57e05313feff 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteBasicSecondaryIndexIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteBasicSecondaryIndexIntegrationTest.java @@ -29,9 +29,9 @@ import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessorTest; import org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Ignore; -import org.junit.Test; - +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsAnyProject; @@ -213,6 +213,7 @@ public class CalciteBasicSecondaryIndexIntegrationTest extends AbstractBasicInte } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() { stopAllGrids(); } @@ -920,7 +921,7 @@ public void testOrCondition5() { // ===== various complex conditions ===== /** */ - @Ignore("TODO") + @Disabled("TODO") @Test public void testOrderByKey() { assertQuery("SELECT id, name, depId, age FROM Developer ORDER BY _key") diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteErrorHandlilngIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteErrorHandlilngIntegrationTest.java index 764fb1813bbc6..a5ce418db2e29 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteErrorHandlilngIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalciteErrorHandlilngIntegrationTest.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; - import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -39,24 +38,26 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.CorruptedTreeException; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.message.QueryStartRequest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.After; -import org.junit.Test; - +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementor.CNLJ_NOT_SUPPORTED_JOIN_ASSERTION_MSG; /** */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "false") -public class CalciteErrorHandlilngIntegrationTest extends GridCommonAbstractTest { +public class CalciteErrorHandlilngIntegrationTest extends GridCommonAbstractWrapperTest { /** */ - @After + @AfterEach public void cleanUp() { stopAllGrids(); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalcitePlanningDumpTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalcitePlanningDumpTest.java index 409dc4c38938a..0722c77cdee71 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalcitePlanningDumpTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CalcitePlanningDumpTest.java @@ -19,16 +19,15 @@ package org.apache.ignite.internal.processors.query.calcite.integration; import java.util.stream.Stream; - import org.apache.calcite.plan.RelOptPlanner; import org.apache.calcite.rel.RelCollation; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteTable; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Test; - -import static org.apache.ignite.IgniteCommonsSystemProperties.getLong; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.IGNITE_CALCITE_PLANNER_TIMEOUT; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; @@ -36,10 +35,11 @@ * This test assumes no Calcite classes are loaded in the current JVM before CalciteQueryProcessor. * Violating this invariant may cause the test to fail due to premature Calcite initialization. */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = IGNITE_CALCITE_PLANNER_TIMEOUT, value = "1000") public class CalcitePlanningDumpTest extends AbstractBasicIntegrationTest { /** */ - private static final long PLANNER_TIMEOUT = getLong(IGNITE_CALCITE_PLANNER_TIMEOUT, 0); + private static final long PLANNER_TIMEOUT = 1000L; /** */ @Test diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CollectIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CollectIntegrationTest.java index 726a3453e1b39..ecf49b67c4eb8 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CollectIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CollectIntegrationTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration; import org.apache.ignite.internal.processors.query.calcite.exec.rel.AbstractNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration test for collect node. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java index c07981e3c8d7a..69e03041d0fad 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java @@ -21,7 +21,7 @@ import java.time.Instant; import java.util.UUID; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests correlated queries. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java index e3f9d5e7cd935..eea94b3020abf 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java @@ -37,11 +37,11 @@ import org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.SupplierX; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.FRAMEWORK_CONFIG; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * Test SQL data types. @@ -679,7 +679,7 @@ public void testNumericConversion() { } /** */ - @Ignore("https://issues.apache.org/jira/browse/IGNITE-25749") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-25749") @Test public void testCharLiteralsInUnion() { assumeTrue(sqlTxMode == SqlTransactionMode.NONE); @@ -1107,6 +1107,6 @@ public void testCharToVarcharConversion() { /** */ private void assumeNoTransactions() { - assumeTrue("Test use queries that doesn't touch any data. Skip for tx modes", sqlTxMode == SqlTransactionMode.NONE); + assumeTrue(sqlTxMode == SqlTransactionMode.NONE, "Test use queries that doesn't touch any data. Skip for tx modes"); } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DateTimeTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DateTimeTest.java index a2d23d8b18a6a..efc4c70a41f9e 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DateTimeTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DateTimeTest.java @@ -27,8 +27,7 @@ import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.IgniteSQLException; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static java.util.Collections.singletonList; /** */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DistributedJoinIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DistributedJoinIntegrationTest.java index 9249c495d33ad..4b2bfed41df2e 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DistributedJoinIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DistributedJoinIntegrationTest.java @@ -21,7 +21,7 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** */ public class DistributedJoinIntegrationTest extends AbstractBasicIntegrationTransactionalTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DynamicParametersIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DynamicParametersIntegrationTest.java index 8a130f5a2e110..9728bee3d2583 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DynamicParametersIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DynamicParametersIntegrationTest.java @@ -33,7 +33,8 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Dynamic parameters types inference test. @@ -58,6 +59,7 @@ public class DynamicParametersIntegrationTest extends AbstractBasicIntegrationTe } /** {@inheritDoc} */ + @BeforeEach @Override public void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ExpiredEntriesIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ExpiredEntriesIntegrationTest.java index 625ed03d4b214..3ad02a54636e1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ExpiredEntriesIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ExpiredEntriesIntegrationTest.java @@ -27,8 +27,8 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsIndexScan; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsSubPlan; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsTableScan; @@ -38,6 +38,7 @@ */ public class ExpiredEntriesIntegrationTest extends AbstractBasicIntegrationTest { /** */ + @BeforeEach @Override protected void beforeTest() throws Exception { CacheConfiguration cacheCfg = new CacheConfiguration() .setIndexedTypes(Integer.class, Developer.class) diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/FunctionsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/FunctionsTest.java index 2e52c5a34797a..d022707002c05 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/FunctionsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/FunctionsTest.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test Ignite SQL functions. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/HashSpoolIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/HashSpoolIntegrationTest.java index f0313935fa08d..e9a523f0b6d49 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/HashSpoolIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/HashSpoolIntegrationTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Hash spool test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexDdlIntegrationTest.java index fd29b491d7162..e5827a7c84e05 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexDdlIntegrationTest.java @@ -28,7 +28,8 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** */ public class IndexDdlIntegrationTest extends AbstractDdlIntegrationTest { @@ -36,6 +37,7 @@ public class IndexDdlIntegrationTest extends AbstractDdlIntegrationTest { private static final String CACHE_NAME = "my_cache"; /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { sql("create table my_table(id int, val_int int, val_str varchar) with cache_name=\"" + CACHE_NAME + "\""); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexMultiRangeScanIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexMultiRangeScanIntegrationTest.java index a4239b8f33a0f..8cfa51e98019d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexMultiRangeScanIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexMultiRangeScanIntegrationTest.java @@ -16,38 +16,35 @@ */ package org.apache.ignite.internal.processors.query.calcite.integration; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.testframework.GridTestUtils; import org.hamcrest.CoreMatchers; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests index multi-range scans (with SEARCH/SARG operator or with dynamic parameters). */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "sqlTxMode={0}, dynamicParams={1}") +@MethodSource("parameters") public class IndexMultiRangeScanIntegrationTest extends AbstractBasicIntegrationTransactionalTest { /** */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean dynamicParams; - /** @return Test parameters. */ - @Parameterized.Parameters(name = "sqlTxMode={0},dynamicParams={1}") - public static Collection parameters() { - List params = new ArrayList<>(); - - for (boolean dynamicParams : new boolean[]{true, false}) { - for (SqlTransactionMode sqlTxMode : SqlTransactionMode.values()) { - params.add(new Object[]{sqlTxMode, dynamicParams}); - } - } - - return params; + /** */ + private static Stream parameters() { + return GridTestUtils.cartesianProduct( + Arrays.stream(SqlTransactionMode.values()).toList(), + List.of(true, false) + ).stream().map(Arguments::of); } /** {@inheritDoc} */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexRebuildIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexRebuildIntegrationTest.java index cc785af571e1c..5ad8a80f97327 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexRebuildIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexRebuildIntegrationTest.java @@ -39,7 +39,9 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.testframework.GridTestUtils; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test index rebuild. @@ -66,6 +68,7 @@ public class IndexRebuildIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { initLatch = null; startLatch = null; @@ -80,6 +83,7 @@ public class IndexRebuildIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { cleanPersistenceDir(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanMultiNodeIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanMultiNodeIntegrationTest.java index f890fd2d01c49..4116e52411086 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanMultiNodeIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanMultiNodeIntegrationTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Multi node index scan test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanlIntegrationTest.java index df79c0490c098..afa3742ef4829 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexScanlIntegrationTest.java @@ -45,7 +45,7 @@ import org.hamcrest.CoreMatchers; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Index scan test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexSpoolIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexSpoolIntegrationTest.java index e0db2f517f2ab..736cb5b7f1dbf 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexSpoolIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexSpoolIntegrationTest.java @@ -21,7 +21,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; - import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.QueryEntity; @@ -31,49 +30,54 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.QueryEngine; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +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.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - +import static org.hamcrest.MatcherAssert.assertThat; /** * Index spool test. */ -@RunWith(Parameterized.class) -public class IndexSpoolIntegrationTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "Rows: {0}") +@MethodSource("testData") +public class IndexSpoolIntegrationTest extends GridCommonAbstractWrapperTest { /** Rows. */ private static final int[] ROWS = {1, 10, 512, 513, 2000}; /** */ - @Parameterized.Parameter(0) + @Parameter(0) public int rows; /** * @return List of versions pairs to test. */ - @Parameterized.Parameters(name = "Rows: {0}") - public static Collection testData() { - List params = new ArrayList<>(); + private static Collection testData() { + List params = new ArrayList<>(); for (int rs : ROWS) - params.add(new Object[]{rs}); + params.add(Arguments.of(rs)); return params; } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { startGrids(2); } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { fillCache(grid(0).cache("TEST0"), rows); fillCache(grid(0).cache("TEST1"), rows); @@ -82,6 +86,7 @@ public static Collection testData() { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { grid(0).cache("TEST0").clear(); grid(0).cache("TEST1").clear(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IntervalTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IntervalTest.java index 63b2e816dfd81..30b944afcfa28 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IntervalTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IntervalTest.java @@ -23,7 +23,7 @@ import java.time.Duration; import java.time.Period; import org.apache.ignite.internal.processors.query.IgniteSQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test SQL INTERVAL data types. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/JoinIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/JoinIntegrationTest.java index ee797b3137e50..93eec4293a369 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/JoinIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/JoinIntegrationTest.java @@ -20,30 +20,34 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; -import org.junit.Assume; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "sqlTxMode={0}, joinType={1}") +@MethodSource("parameters") public class JoinIntegrationTest extends AbstractBasicIntegrationTransactionalTest { /** */ - @Parameterized.Parameter(1) + @Parameter(1) public JoinType joinType; /** */ - @Parameterized.Parameters(name = "sqlTxMode={0},joinType={1}") - public static List params() { - List params = new ArrayList<>(); + private static Stream parameters() { + List params = new ArrayList<>(); for (SqlTransactionMode sqlTxMode : SqlTransactionMode.values()) { for (JoinType jt : JoinType.values()) - params.add(new Object[] {sqlTxMode, jt}); + params.add(Arguments.of(sqlTxMode, jt)); } - return params; + return params.stream(); } /** {@inheritDoc} */ @@ -688,7 +692,7 @@ public void testLeftJoin() { */ @Test public void testRightJoin() { - Assume.assumeTrue(joinType != JoinType.CORRELATED); + assumeTrue(joinType != JoinType.CORRELATED); assertQuery("" + "select t1.c1 c11, t1.c2 c12, t2.c1 c21, t2.c2 c22, t2.c3 c23 " + @@ -1035,7 +1039,7 @@ public void testRightJoin() { */ @Test public void testFullJoin() { - Assume.assumeTrue(joinType != JoinType.CORRELATED); + assumeTrue(joinType != JoinType.CORRELATED); assertQuery("" + "select t1.c1 c11, t1.c2 c12, t1.c3 c13, t2.c1 c21, t2.c2 c22, t2.c3 c23 " + diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeepBinaryIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeepBinaryIntegrationTest.java index 6eaf7b1168764..d996c08f13c4f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeepBinaryIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeepBinaryIntegrationTest.java @@ -28,7 +28,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.SupplierX; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test "keep binary" in cache queries. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeyClassChangeIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeyClassChangeIntegrationTest.java index 6cefef53b03b6..fb421ef654ec5 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeyClassChangeIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KeyClassChangeIntegrationTest.java @@ -37,7 +37,8 @@ import org.apache.ignite.failure.TestFailureHandler; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** */ public class KeyClassChangeIntegrationTest extends AbstractMultiEngineIntegrationTest { @@ -56,9 +57,10 @@ public class KeyClassChangeIntegrationTest extends AbstractMultiEngineIntegratio /** */ private boolean pds; - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); + /** */ + @BeforeEach + void setup() throws Exception { + beforeTest(); failureHnd = new TestFailureHandler(true); validateTypes = false; @@ -70,8 +72,6 @@ public class KeyClassChangeIntegrationTest extends AbstractMultiEngineIntegratio /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { - super.afterTest(); - stopAllGrids(); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java index 6ddd58be28d9e..25945d09f7482 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java @@ -46,7 +46,8 @@ import org.apache.ignite.spi.systemview.view.ScanQueryView; import org.apache.ignite.spi.systemview.view.SystemView; import org.apache.ignite.transactions.Transaction; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW; import static org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW; @@ -69,6 +70,7 @@ public class KillCommandDdlIntegrationTest extends AbstractDdlIntegrationTest { public static final int TIMEOUT = 10_000; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillQueryCommandDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillQueryCommandDdlIntegrationTest.java index 1d03fdf9aae7c..6de9766167d14 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillQueryCommandDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillQueryCommandDdlIntegrationTest.java @@ -43,32 +43,34 @@ import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.internal.processors.query.running.RunningQueryManager.SQL_QRY_VIEW; /** * Tests `KILL QUERY` command. */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "isAsync={0}, cancelOnClient={1}") +@MethodSource("parameters") public class KillQueryCommandDdlIntegrationTest extends AbstractDdlIntegrationTest { /** Operations timeout. */ public static final int TIMEOUT = 10_000; /** If {@code true}, cancel asynchronously. */ - @Parameterized.Parameter(0) + @Parameter(0) public boolean isAsync; /** If {@code true}, cancel on client(initiator), otherwise on server. */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean cancelOnClient; /** @return Test parameters. */ - @Parameterized.Parameters(name = "isAsync={0},cancelOnClient={1}") - public static Collection parameters() { - return Stream.of(true, false).flatMap(p -> Stream.of(new Object[] {p, true}, new Object[] {p, false})) + @MethodSource("parameters") + private static Collection parameters() { + return Stream.of(true, false).flatMap(p -> Stream.of(Arguments.of(p, true), Arguments.of(p, false))) .collect(Collectors.toList()); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LimitOffsetIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LimitOffsetIntegrationTest.java index ac0f38e46cc20..54fd409ddae70 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LimitOffsetIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LimitOffsetIntegrationTest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static java.util.Collections.singletonList; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalDateTimeSupportTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalDateTimeSupportTest.java index 1b1f5bf7d529a..f28f2b268c371 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalDateTimeSupportTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalDateTimeSupportTest.java @@ -37,9 +37,11 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; import org.apache.ignite.internal.util.typedef.G; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.Collections.singletonList; import static org.apache.ignite.internal.cache.query.index.sorted.inline.types.DateValueUtils.convertToSqlDate; @@ -47,62 +49,61 @@ import static org.apache.ignite.internal.cache.query.index.sorted.inline.types.DateValueUtils.convertToTimestamp; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "sqlTxMode={0}, isValidationEnabled={1}, sqlType={2}, columnCls={3}, testObjCls={4}, beforeGregorian={6}") +@MethodSource("parameters") public class LocalDateTimeSupportTest extends AbstractBasicIntegrationTransactionalTest { /** */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean isValidationEnabled; /** */ - @Parameterized.Parameter(2) + @Parameter(2) public String sqlType; /** */ - @Parameterized.Parameter(3) + @Parameter(3) public Class colType; /** */ - @Parameterized.Parameter(4) + @Parameter(4) public Class objType; /** */ - @Parameterized.Parameter(5) + @Parameter(5) public Function sqlTypeConverter; /** */ - @Parameterized.Parameter(6) + @Parameter(6) public boolean isOldDate; /** */ - @Parameterized.Parameters( - name = "sqlTxMode={0}, isValidationEnabled={1}, sqlType={2}, columnCls={3}, testObjCls={4}, beforeGregorian={6}") - public static Collection parameters() { - Collection params = new ArrayList<>(); + private static Collection parameters() { + Collection params = new ArrayList<>(); for (SqlTransactionMode sqlTxmode : SqlTransactionMode.values()) { for (boolean isOldDate: Arrays.asList(true, false)) { for (boolean isV : Arrays.asList(true, false)) { - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, "TIMESTAMP", null, LocalDateTime.class, f(ts -> convertToTimestamp((LocalDateTime)ts)), isOldDate - }); - params.add(new Object[] { + )); + params.add(Arguments.of( sqlTxmode, isV, "TIMESTAMP", null, Date.class, f(ts -> new Timestamp(((Date)ts).getTime())), isOldDate - }); - params.add(new Object[] { + )); + params.add(Arguments.of( sqlTxmode, isV, "TIMESTAMP", null, java.sql.Date.class, f(ts -> new Timestamp(((Date)ts).getTime())), isOldDate - }); + )); for (Class testObjCls : Arrays.asList(Timestamp.class, LocalDateTime.class, Date.class, java.sql.Date.class)) { - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, Timestamp.class, testObjCls, f(ts -> { if (ts instanceof LocalDateTime) return convertToTimestamp((LocalDateTime)ts); return ts; }), isOldDate - }); + )); - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, Date.class, testObjCls, f(ts -> { if (testObjCls == LocalDateTime.class) return new Date(convertToTimestamp((LocalDateTime)ts).getTime()); @@ -111,9 +112,9 @@ else if (testObjCls == Timestamp.class) return ts; }), isOldDate - }); + )); - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, LocalDateTime.class, testObjCls, f(ts -> { if (testObjCls == Timestamp.class) return ((Timestamp)ts).toLocalDateTime(); @@ -125,55 +126,55 @@ else if (testObjCls == java.sql.Date.class) return ts; }), isOldDate - }); + )); } - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, "DATE", null, LocalDate.class, f(d -> convertToSqlDate((LocalDate)d)), isOldDate - }); + )); for (Class testObjCls : Arrays.asList(LocalDate.class, java.sql.Date.class)) { - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, java.sql.Date.class, testObjCls, f(ts -> { if (testObjCls == LocalDate.class) return convertToSqlDate((LocalDate)ts); return ts; }), isOldDate - }); + )); - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, LocalDate.class, testObjCls, f(ts -> { if (testObjCls == java.sql.Date.class) return ((java.sql.Date)ts).toLocalDate(); return ts; }), isOldDate - }); + )); } - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, "TIME", null, LocalTime.class, f(t -> convertToSqlTime((LocalTime)t)), isOldDate - }); + )); for (Class testObjCls : Arrays.asList(LocalTime.class, java.sql.Time.class)) { - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, java.sql.Time.class, testObjCls, f(ts -> { if (testObjCls == LocalTime.class) return convertToSqlTime((LocalTime)ts); return ts; }), isOldDate - }); + )); - params.add(new Object[] { + params.add(Arguments.of( sqlTxmode, isV, null, LocalTime.class, testObjCls, f(ts -> { if (testObjCls == java.sql.Time.class) return ((java.sql.Time)ts).toLocalTime(); return ts; }), isOldDate - }); + )); } } } @@ -195,10 +196,15 @@ sqlTxmode, isV, null, LocalTime.class, testObjCls, f(ts -> { @Override protected void afterTest() throws Exception { super.afterTest(); - for (Ignite ig: G.allGrids()) { - IgniteCacheObjectProcessor objProc = ((IgniteEx)ig).context().cacheObjects(); + try { + for (Ignite ig : G.allGrids()) { + IgniteCacheObjectProcessor objProc = ((IgniteEx)ig).context().cacheObjects(); - objProc.removeType(objProc.typeId(Data.class.getName())); + objProc.removeType(objProc.typeId(Data.class.getName())); + } + } + catch (Exception ignore) { + // No op. } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalQueryIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalQueryIntegrationTest.java index 9b4ece05519f5..cdead908e90b2 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalQueryIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/LocalQueryIntegrationTest.java @@ -27,7 +27,8 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.QueryContext; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** */ public class LocalQueryIntegrationTest extends AbstractBasicIntegrationTest { @@ -58,6 +59,7 @@ public class LocalQueryIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MemoryQuotasIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MemoryQuotasIntegrationTest.java index ca27117798676..b0b670e7c4b4b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MemoryQuotasIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MemoryQuotasIntegrationTest.java @@ -29,7 +29,8 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; @@ -57,9 +58,10 @@ public class MemoryQuotasIntegrationTest extends AbstractBasicIntegrationTest { .setTransactionConfiguration(new TransactionConfiguration().setTxAwareQueriesEnabled(true)); } - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); + /** */ + @BeforeEach + void setup() throws Exception { + beforeTest(); sql("CREATE TABLE tbl (id INT, b VARBINARY) WITH TEMPLATE=REPLICATED, ATOMICITY=TRANSACTIONAL"); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MetadataIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MetadataIntegrationTest.java index eea66fe70e835..3ff581c0e3973 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MetadataIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MetadataIntegrationTest.java @@ -22,8 +22,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.configuration.CacheConfiguration; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static java.util.stream.Collectors.joining; import static java.util.stream.Stream.generate; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MultiDcQueryMappingTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MultiDcQueryMappingTest.java index dd6169df11b60..9e0aaf067f17b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MultiDcQueryMappingTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/MultiDcQueryMappingTest.java @@ -39,7 +39,8 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** */ public class MultiDcQueryMappingTest extends AbstractBasicIntegrationTest { @@ -125,6 +126,7 @@ private CacheConfiguration cacheConfiguration(String name) { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/OperatorsExtensionIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/OperatorsExtensionIntegrationTest.java index 004580b915c45..db261920fe555 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/OperatorsExtensionIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/OperatorsExtensionIntegrationTest.java @@ -78,7 +78,7 @@ import org.apache.ignite.plugin.AbstractTestPluginProvider; import org.apache.ignite.plugin.PluginContext; import org.jetbrains.annotations.Nullable; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests SQL engine extension with plugin. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionPruneTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionPruneTest.java index ac6fc2c47adee..4b363c76abc56 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionPruneTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionPruneTest.java @@ -47,7 +47,8 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** */ public class PartitionPruneTest extends AbstractBasicIntegrationTest { @@ -115,6 +116,7 @@ public class PartitionPruneTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -317,7 +319,6 @@ public void testSelectIn() { }); } - /** */ @Test public void testSelectOr() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java index cf4314a439d32..03c974af6c081 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java @@ -34,7 +34,9 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteCacheTable; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.X; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests partition reservation/releasing for queries over unstable topology. @@ -47,12 +49,14 @@ public class PartitionsReservationIntegrationTest extends AbstractBasicIntegrati private static final int KEYS = PARTS * 100_000; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. Don't start any grids. } - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + /** */ + @BeforeEach + void setup() throws Exception { startGrids(2); client = startClientGrid(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryBlockingTaskExecutorIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryBlockingTaskExecutorIntegrationTest.java index c31b287caa8d3..a20dca19fa5da 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryBlockingTaskExecutorIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryBlockingTaskExecutorIntegrationTest.java @@ -19,14 +19,17 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR; /** * Integration test with common queries for query blocking task executor instead of striped task executor. */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR, value = "true") public class QueryBlockingTaskExecutorIntegrationTest extends AbstractBasicIntegrationTransactionalTest { /** */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryEngineConfigurationIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryEngineConfigurationIntegrationTest.java index 435f2b9b13282..272fb24019d52 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryEngineConfigurationIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryEngineConfigurationIntegrationTest.java @@ -36,12 +36,12 @@ import org.apache.ignite.internal.processors.query.NoOpQueryEngine; import org.apache.ignite.internal.processors.query.QueryEngine; import org.apache.ignite.internal.processors.query.QueryEngineConfigurationEx; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** */ -public class QueryEngineConfigurationIntegrationTest extends GridCommonAbstractTest { +public class QueryEngineConfigurationIntegrationTest extends GridCommonAbstractWrapperTest { /** */ private static final String jdbcUrl = "jdbc:ignite:thin://127.0.0.1"; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryMetadataIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryMetadataIntegrationTest.java index 5947b3cc8db6a..02bc2dd5d0b46 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryMetadataIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryMetadataIntegrationTest.java @@ -31,9 +31,8 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.T2; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; - import static org.apache.calcite.rel.type.RelDataType.PRECISION_NOT_SPECIFIED; import static org.apache.calcite.rel.type.RelDataType.SCALE_NOT_SPECIFIED; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java index e5e6833497477..b42331cb4303b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java @@ -35,12 +35,17 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "local = {0}, partSz = {1}") +@MethodSource("parameters") public class QueryWithPartitionsIntegrationTest extends AbstractBasicIntegrationTest { /** */ private static final int ENTRIES_COUNT = 10000; @@ -49,23 +54,24 @@ public class QueryWithPartitionsIntegrationTest extends AbstractBasicIntegration private volatile int[] parts; /** */ - @Parameterized.Parameter() + @Parameter(0) public boolean local; /** */ - @Parameterized.Parameter(1) + @Parameter(1) public int partSz; /** */ - @Parameterized.Parameters(name = "local = {0}, partSz = {1}") - public static List parameters() { + @MethodSource("parameters") + private static List parameters() { return Stream.of(true, false) .flatMap(isLocal -> Stream.of(1, 2, 5, 10, 20) - .map(i -> new Object[]{isLocal, i})) + .map(i -> Arguments.of(isLocal, i))) .collect(Collectors.toList()); } /** {@inheritDoc} */ + @BeforeEach @Override public void beforeTest() throws Exception { super.beforeTest(); @@ -104,6 +110,7 @@ public static List parameters() { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java index 6ca5e8934490b..32b11f921448c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java @@ -22,7 +22,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration tests for recursive common table expressions. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ResultSetSizeMetricsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ResultSetSizeMetricsTest.java index 95430e21e5e01..df14768904088 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ResultSetSizeMetricsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ResultSetSizeMetricsTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.internal.processors.metric.MetricRegistryImpl; import org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl; import org.apache.ignite.internal.processors.metric.impl.MaxValueMetric; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.running.RunningQueryManager.SQL_USER_QUERIES_REG_NAME; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RunningQueriesIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RunningQueriesIntegrationTest.java index 4c8d83cc3096b..3f5d6a21e66bb 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RunningQueriesIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RunningQueriesIntegrationTest.java @@ -61,11 +61,13 @@ import org.apache.ignite.spi.systemview.view.SqlQueryView; import org.apache.ignite.spi.systemview.view.SystemView; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static java.util.stream.Collectors.joining; import static org.apache.ignite.IgniteSystemProperties.getLong; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.FRAMEWORK_CONFIG; @@ -76,10 +78,11 @@ /** * */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = IGNITE_CALCITE_PLANNER_TIMEOUT, value = "2000") public class RunningQueriesIntegrationTest extends AbstractBasicIntegrationTest { /** */ - private static final long PLANNER_TIMEOUT = getLong(IGNITE_CALCITE_PLANNER_TIMEOUT, 0); + private static long plannerTimeout; /** */ private static IgniteEx srv; @@ -88,9 +91,12 @@ public class RunningQueriesIntegrationTest extends AbstractBasicIntegrationTest private static final long TIMEOUT_IN_MS = 10_000; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); + plannerTimeout = getLong(IGNITE_CALCITE_PLANNER_TIMEOUT, 0); + srv = grid(0); } @@ -326,7 +332,7 @@ public void testLongPlanningTimeout() throws IgniteCheckedException { try { AtomicReference>> res = new AtomicReference<>(); - GridTestUtils.assertTimeout(3 * PLANNER_TIMEOUT, TimeUnit.MILLISECONDS, () -> { + GridTestUtils.assertTimeout(3 * plannerTimeout, TimeUnit.MILLISECONDS, () -> { res.set(sql(longJoinQry)); }); @@ -340,9 +346,9 @@ public void testLongPlanningTimeout() throws IgniteCheckedException { DistributedSqlConfiguration distrCfg = queryProcessor(client).distributedConfiguration(); try { - distrCfg.defaultQueryTimeout((int)PLANNER_TIMEOUT / 3).get(); + distrCfg.defaultQueryTimeout((int)plannerTimeout / 3).get(); - GridTestUtils.assertTimeout(PLANNER_TIMEOUT, TimeUnit.MILLISECONDS, () -> { + GridTestUtils.assertTimeout(plannerTimeout, TimeUnit.MILLISECONDS, () -> { sql(longJoinQry + " AND 1=1"); // Modify SQL to skip cached plan. }); } @@ -398,7 +404,7 @@ public void testQueryInitiator() throws IgniteCheckedException { latch.countDown(); } - assertTrue(GridTestUtils.waitForCondition(() -> F.isEmpty(engine.runningQueries()), PLANNER_TIMEOUT * 2)); + assertTrue(GridTestUtils.waitForCondition(() -> F.isEmpty(engine.runningQueries()), plannerTimeout * 2)); } /** */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ScalarInIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ScalarInIntegrationTest.java index 0e4fc7d461d96..98e92d055af93 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ScalarInIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ScalarInIntegrationTest.java @@ -19,13 +19,15 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test scalar IN operator. */ public class ScalarInIntegrationTest extends AbstractBasicIntegrationTest { /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java index 9a3c56c98fe2b..e5c1ee8dcb978 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java @@ -28,8 +28,8 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.hamcrest.CoreMatchers; import org.jetbrains.annotations.Nullable; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static java.util.stream.Collectors.toList; import static org.apache.ignite.internal.processors.query.QueryUtils.KEY_FIELD_NAME; @@ -128,7 +128,7 @@ public void testCompositePkWithKeyTypeAndBinaryObject() { /** */ @Test - @Ignore("https://issues.apache.org/jira/browse/IGNITE-28374") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-28374") public void testCompositePkWithKeyTypeAndPersonCompositeKey() { checkCompositePk(true, false, null); } @@ -165,7 +165,7 @@ public void testCompositePkWithDifferentCmpOperations() { /** */ @Test - @Ignore("https://issues.apache.org/jira/browse/IGNITE-28374") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-28374") public void testCompositePkWithPersonCompositeKeyAndDifferentCmpOperations() { checkCompositePkWithDifferentCmpOperations(false); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectForUpdateIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectForUpdateIntegrationTest.java index c450ea1ad2106..3117aa62e71d7 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectForUpdateIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectForUpdateIntegrationTest.java @@ -34,7 +34,10 @@ import org.apache.ignite.internal.processors.query.calcite.util.IgniteResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTransactionalTest.SqlTransactionMode.ALL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -61,6 +64,7 @@ public class SelectForUpdateIntegrationTest extends AbstractBasicIntegrationTest } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -69,6 +73,7 @@ public class SelectForUpdateIntegrationTest extends AbstractBasicIntegrationTest } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() throws Exception { ignite0 = null; ignite1 = null; @@ -106,6 +111,7 @@ public class SelectForUpdateIntegrationTest extends AbstractBasicIntegrationTest } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ServerStatisticsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ServerStatisticsIntegrationTest.java index 6d1bdbb929696..418da2eb841b9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ServerStatisticsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ServerStatisticsIntegrationTest.java @@ -39,7 +39,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for server side statistics usage. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SetOpIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SetOpIntegrationTest.java index 718937962e0d1..fee789bbe94f0 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SetOpIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SetOpIntegrationTest.java @@ -26,7 +26,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration test for set op (EXCEPT, INTERSECT). diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java index dd802750931db..b1e5df5346c4d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java @@ -30,7 +30,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.calcite.exec.rel.AbstractNode; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Sort aggregate integration test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java index 5eb2f511ec0a8..98cce7e4e4cba 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java @@ -74,6 +74,7 @@ import org.apache.ignite.internal.util.future.GridCompoundFuture; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.metric.MetricRegistry; import org.apache.ignite.spi.metric.LongMetric; @@ -82,9 +83,12 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Test; - +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.IgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVAL; import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED; import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ; @@ -111,6 +115,7 @@ /** * Test SQL diagnostic tools. */ +@ExtendWith(SystemPropertiesExtension.class) public class SqlDiagnosticIntegrationTest extends AbstractBasicIntegrationTest { /** */ private static final String jdbcUrl = "jdbc:ignite:thin://127.0.0.1:" + ClientConnectorConfiguration.DFLT_PORT; @@ -144,14 +149,19 @@ public class SqlDiagnosticIntegrationTest extends AbstractBasicIntegrationTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); + // Clear log throttle. + LT.clear(); + cleanPersistenceDir(); log = new ListeningTestLogger(log()); @@ -874,7 +884,6 @@ public void testBigResultSet() throws Exception { assertTrue(logLsnr2.check(1000L)); } - /** */ @Test @WithSystemProperty(key = IGNITE_STARVATION_CHECK_INTERVAL, value = "100") @@ -924,7 +933,7 @@ private void checkStarvation() throws Exception { /** */ @Test - public void testUdfQueryDeadlockDetectionStripedExecutor() throws Exception { + public void testUdfQueryDeadlockDetectionStripedExecutor() { IgniteEx ignite = grid(0); assertTrue(queryProcessor(ignite).taskExecutor() instanceof StripedQueryTaskExecutor); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java index e2d0671b86983..54369aabf2e84 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java @@ -45,29 +45,34 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.QueryEngineConfigurationEx; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.spi.systemview.view.SqlPlanHistoryView; import org.apache.ignite.spi.systemview.view.SystemView; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.AssumptionViolatedException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.opentest4j.TestAbortedException; import static org.apache.ignite.configuration.SqlConfiguration.DFLT_SQL_PLAN_HISTORY_SIZE; import static org.apache.ignite.internal.processors.performancestatistics.AbstractPerformanceStatisticsTest.startCollectStatistics; import static org.apache.ignite.internal.processors.query.running.RunningQueryManager.SQL_PLAN_HIST_VIEW; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** Tests for SQL plan history. */ -@RunWith(Parameterized.class) -public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "sqlEngine={0}, isClient={1} loc={2}, isFullyFetched={3}, isPerfStatsEnabled={4}") +@MethodSource("params") +public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractWrapperTest { /** SQL plan history size excess. */ private static final int PLAN_HISTORY_EXCESS = 2; @@ -119,30 +124,29 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest { private int planHistorySize = 10; /** SQL engine. */ - @Parameterized.Parameter + @Parameter(0) public String sqlEngine; /** Client mode flag. */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean isClient; /** Local query flag. */ - @Parameterized.Parameter(2) + @Parameter(2) public boolean loc; /** Fully-fetched query flag. */ - @Parameterized.Parameter(3) + @Parameter(3) public boolean isFullyFetched; /** Flag indicating whether the collection of performance statistics is enabled. */ - @Parameterized.Parameter(4) + @Parameter(4) public boolean isPerfStatsEnabled; /** * @return Test parameters. */ - @Parameterized.Parameters(name = "sqlEngine={0}, isClient={1} loc={2}, isFullyFetched={3}, isPerfStatsEnabled={4}") - public static Collection params() { + private static Collection params() { return Arrays.stream(new Object[][]{ {CalciteQueryEngineConfiguration.ENGINE_NAME}, {IndexingQueryEngineConfiguration.ENGINE_NAME} @@ -151,8 +155,8 @@ public static Collection params() { .flatMap(isClient -> Arrays.stream(isClient ? new Boolean[]{false} : new Boolean[]{true, false}) .flatMap(loc -> Arrays.stream(new Boolean[]{true, false}) .flatMap(isFullyFetched -> Arrays.stream(new Boolean[]{true, false}) - .map(isPerfStatsEnabled -> new Object[]{sqlEngine[0], isClient, loc, isFullyFetched, isPerfStatsEnabled})))) - ).collect(Collectors.toList()); + .map(isPerfStatsEnabled -> Arguments.of(sqlEngine[0], isClient, loc, isFullyFetched, isPerfStatsEnabled)))) + )).collect(Collectors.toList()); } /** {@inheritDoc} */ @@ -241,10 +245,20 @@ protected void startTestGrid() throws Exception { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { stopAllGrids(); } + /** */ + @BeforeEach + public void setup() throws Exception { + isSqlEngineConfigured = true; + isSqlConfigured = true; + isPlanHistorySizeSet = true; + planHistorySize = 10; + } + /** Checks successful JDBC queries. */ @Test public void testJdbcQuery() throws Exception { @@ -262,7 +276,7 @@ public void testJdbcQueryFailed() throws Exception { jdbcQuery(SQL_FAILED); } catch (Exception e) { - if (e instanceof AssumptionViolatedException) + if (e instanceof TestAbortedException) throw e; } @@ -299,10 +313,10 @@ public void testSqlFieldsCrossCacheQueryFailed() throws Exception { */ @Test public void testSqlFieldsQueryWithReducePhase() throws Exception { - assumeTrue("Map/reduce queries are only applicable to H2 engine", - sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME); + assumeTrue(sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME, + "Map/reduce queries are only applicable to H2 engine"); - assumeFalse("Only distributed queries have map and reduce phases", loc); + assumeFalse(loc, "Only distributed queries have map and reduce phases"); startTestGrid(); @@ -510,8 +524,8 @@ public void testDefaultHistorySize() throws Exception { */ @Test public void testNoScanCountSuffix() throws Exception { - assumeTrue("ScanCount suffix can only be present in H2 local query plans", - sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME && loc); + assumeTrue(sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME && loc, + "ScanCount suffix can only be present in H2 local query plans"); assumeFalse(isPerfStatsEnabled); @@ -540,8 +554,8 @@ public void testNoScanCountSuffix() throws Exception { /** Tests that H2 query plans for UNION operations do not contain 'scanCount' suffix. */ @Test public void testNoScanCountSuffixForUNION() throws Exception { - assumeTrue("ScanCount suffix can only be present in H2 local query plans", - IndexingQueryEngineConfiguration.ENGINE_NAME.equals(sqlEngine) && loc); + assumeTrue(IndexingQueryEngineConfiguration.ENGINE_NAME.equals(sqlEngine) && loc, + "ScanCount suffix can only be present in H2 local query plans"); startTestGrid(); @@ -615,7 +629,7 @@ public void runQueryWithoutPlan(Query qry) throws Exception { * @param qryText Query text. */ private void jdbcQuery(String qryText) throws Exception { - assumeFalse("There is no 'local query' parameter for JDBC queries", loc); + assumeFalse(loc, "There is no 'local query' parameter for JDBC queries"); if (Ignition.allGrids().isEmpty()) startTestGrid(); @@ -655,7 +669,7 @@ public void cacheQuery(Query qry, String cacheName) { * @param qrysInfo DML commands info (command text, simple query flag). */ public void runJdbcDml(IgniteBiTuple, Boolean> qrysInfo) throws Exception { - assumeFalse("There is no 'local query' parameter for JDBC queries", loc); + assumeFalse(loc, "There is no 'local query' parameter for JDBC queries"); executeDml(qrysInfo, (cmds) -> { try ( @@ -687,7 +701,7 @@ public void runSqlFieldsDml(IgniteBiTuple, Boolean> qrysInfo) throw * @param task Task to be executed. */ public void executeDml(IgniteBiTuple, Boolean> qrysInfo, Consumer> task) throws Exception { - assumeTrue("There is no lazy mode for DML operations", isFullyFetched); + assumeTrue(isFullyFetched, "There is no lazy mode for DML operations"); startTestGrid(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StatisticsCommandDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StatisticsCommandDdlIntegrationTest.java index 3817d0131df3f..404ce207ae4f1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StatisticsCommandDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StatisticsCommandDdlIntegrationTest.java @@ -31,8 +31,8 @@ import org.apache.ignite.internal.processors.query.stat.StatisticsKey; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.MatcherAssert.assertThat; @@ -60,6 +60,7 @@ public class StatisticsCommandDdlIntegrationTest extends AbstractDdlIntegrationT private static final String NAME_FIELD = "NAME"; /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StdSqlOperatorsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StdSqlOperatorsTest.java index 2f78ee9c6f724..00ae12ff0eab1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StdSqlOperatorsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/StdSqlOperatorsTest.java @@ -29,7 +29,8 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.sql.fun.IgniteStdSqlOperatorTable; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Ignite's SQL dialect test. @@ -39,6 +40,7 @@ */ public class StdSqlOperatorsTest extends AbstractBasicIntegrationTest { /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemColumnsScanTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemColumnsScanTest.java index c62402703cc0a..956ce77e17127 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemColumnsScanTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemColumnsScanTest.java @@ -44,11 +44,13 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteCacheTable; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteIndex; import org.apache.ignite.internal.processors.query.calcite.util.Commons; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** Tests system columns returned by direct table and index scans. */ public class SystemColumnsScanTest extends AbstractBasicIntegrationTest { /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemViewsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemViewsIntegrationTest.java index 58f5989f661c3..c34ac41eb5921 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemViewsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SystemViewsIntegrationTest.java @@ -24,8 +24,7 @@ import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.util.IgniteResource; import org.hamcrest.Matcher; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CLIENT_MODE; /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java index a4ace5c795e5f..101b61945aadc 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java @@ -55,14 +55,13 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.hamcrest.CustomMatcher; import org.hamcrest.Matcher; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID; import static org.apache.ignite.internal.processors.query.calcite.TestUtils.hasSize; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** */ public class TableDdlIntegrationTest extends AbstractDdlIntegrationTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java index f94c45162fbaa..f194fe23b3fc1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java @@ -42,7 +42,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** */ public class TableDmlIntegrationTest extends AbstractBasicIntegrationTransactionalTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TestSuiteDeclarationArchTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TestSuiteDeclarationArchTest.java new file mode 100644 index 0000000000000..b2093e0696f1f --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TestSuiteDeclarationArchTest.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.query.calcite.integration; + +import java.util.Set; +import com.tngtech.archunit.core.domain.JavaClass; +import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.domain.JavaMethod; +import com.tngtech.archunit.core.domain.JavaModifier; +import com.tngtech.archunit.core.importer.ClassFileImporter; +import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.core.importer.Location; +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchTest; +import com.tngtech.archunit.junit.LocationProvider; +import com.tngtech.archunit.lang.ArchCondition; +import com.tngtech.archunit.lang.ArchRule; +import com.tngtech.archunit.lang.ConditionEvents; +import com.tngtech.archunit.lang.SimpleConditionEvent; +import org.junit.jupiter.api.Order; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods; + +/** */ +@AnalyzeClasses( + importOptions = ImportOption.OnlyIncludeTests.class, + locations = TestSuiteDeclarationArchTest.CalciteLocationProvider.class) +@Order(1) +public class TestSuiteDeclarationArchTest { + /** */ + private static JavaClasses allClassesCache; + + /** + * Resolves compiled test classes of the calcite module (i.e. {@code modules/calcite/target/test-classes}). + * The location is derived from the test class itself instead of the working directory, because with + * {@code forkCount=0} the working directory is the one Maven was started from (e.g. the repository root), + * which would make the rules scan every module. + */ + static class CalciteLocationProvider implements LocationProvider { + /** */ + @Override public Set get(Class testCls) { + return Set.of(calciteTestClassesLocation()); + } + } + + /** @return Location of the calcite module compiled test classes. */ + private static Location calciteTestClassesLocation() { + return Location.of(TestSuiteDeclarationArchTest.class.getProtectionDomain().getCodeSource().getLocation()); + } + + /** */ + @ArchTest + @SuppressWarnings("unused") + static final ArchRule CHECK_LEGACY_TESTS = + methods() + .that().areAnnotatedWith(org.junit.Test.class) + .should(new ArchCondition("Legacy JUnit defined test with: @org.junit.Test") { + @Override public void check(JavaMethod method, ConditionEvents events) { + events.add(SimpleConditionEvent.violated(method, "Unexpected test annotation: " + method.getFullName())); + } + }) + .allowEmptyShould(true); + + /** */ + @ArchTest + @SuppressWarnings("unused") + static final ArchRule CHECK_ALL_TEST_CLASSES_IN_SUITE = + methods() + .that().areAnnotatedWith(org.junit.jupiter.api.Test.class) + .should(new ArchCondition("be declared in a class listed in @SelectClasses of a @Suite") { + /** */ + @Override public void check(JavaMethod method, ConditionEvents events) { + // Lazy load all classes to avoid repeated scanning + if (allClassesCache == null) { + allClassesCache = new ClassFileImporter() + .importLocations(Set.of(calciteTestClassesLocation())); + } + + JavaClass ownerCls = method.getOwner(); + + if (ownerCls.getModifiers().stream().anyMatch(m -> m == JavaModifier.ABSTRACT)) + return; + + boolean isInSuite = allClassesCache.stream() + .filter(cls -> cls.isAnnotatedWith(Suite.class)) + .anyMatch(suite -> isClassReferencedInSuite(suite, ownerCls)); + + if (!isInSuite) { + String msg = String.format( + "Method %s#%s is in a class that is not listed in any @SelectClasses.", + ownerCls.getFullName(), method.getName() + ); + events.add(SimpleConditionEvent.violated(method, msg)); + } + } + + private boolean isClassReferencedInSuite(JavaClass suiteClass, JavaClass testClass) { + SelectClasses selectClasses = suiteClass.reflect().getAnnotation(SelectClasses.class); + if (selectClasses != null) { + for (Class selected : selectClasses.value()) { + if (selected.getName().equals(testClass.getFullName())) { + return true; + } + } + } + return false; + } + }); +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TimeoutIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TimeoutIntegrationTest.java index 6ef1f6bbff5f7..4800d181a1cc7 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TimeoutIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TimeoutIntegrationTest.java @@ -46,8 +46,7 @@ import org.apache.ignite.spi.metric.LongMetric; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.running.RunningQueryManager.SQL_USER_QUERIES_REG_NAME; /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnnestIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnnestIntegrationTest.java index bec275f95bb74..87c075570c70a 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnnestIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnnestIntegrationTest.java @@ -20,7 +20,7 @@ import java.util.Collections; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration test for UNNEST operator. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnstableTopologyIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnstableTopologyIntegrationTest.java index 120642ee2b17d..834e12839639e 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnstableTopologyIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UnstableTopologyIntegrationTest.java @@ -44,12 +44,16 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingSpi; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** Non-stable topology tests. */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "awaitExchange={0}, idxSlowDown={1}") +@MethodSource("parameters") public class UnstableTopologyIntegrationTest extends AbstractBasicIntegrationTest { /** */ private static final String POI_CACHE_NAME = "POI_CACHE"; @@ -78,26 +82,26 @@ public class UnstableTopologyIntegrationTest extends AbstractBasicIntegrationTes /** */ private static final int NUM_ENTITIES = 2_000; - /** Test parameters. */ - @Parameterized.Parameters(name = "awaitExchange={0}, idxSlowDown={1}") - public static List parameters() { + /** */ + private static List parameters() { return ImmutableList.of( - new Object[]{true, true}, - new Object[]{true, false}, - new Object[]{false, false}, - new Object[]{false, true} + Arguments.of(true, true), + Arguments.of(true, false), + Arguments.of(false, false), + Arguments.of(false, true) ); } /** */ - @Parameterized.Parameter() + @Parameter(0) public boolean awaitExchange; /** */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean idxSlowDown; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. We don't need to start anything. } @@ -144,8 +148,6 @@ private QueryEntity queryEntity() { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(true); - - super.afterTest(); } /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDdlIntegrationTest.java index b12ed29ad42c3..4a6d7a9585439 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDdlIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDdlIntegrationTest.java @@ -25,7 +25,7 @@ import org.apache.ignite.internal.processors.security.SecurityContext; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.authentication.AuthenticationProcessorSelfTest.authenticate; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java index e5f8e569c998e..4cca8aa472349 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTest.java @@ -41,14 +41,17 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.LogListener; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR; /** * Integration test for user defined functions. */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR, value = "true") public class UserDefinedFunctionsIntegrationTest extends AbstractBasicIntegrationTest { /** Log listener. */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTransactionalTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTransactionalTest.java index c1d9d1b5438e2..af86a09d85fc8 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTransactionalTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedFunctionsIntegrationTransactionalTest.java @@ -20,7 +20,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration test for user defined functions. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedTxAwareFunctionsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedTxAwareFunctionsIntegrationTest.java index e98245823885a..4813b35bd94e4 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedTxAwareFunctionsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/UserDefinedTxAwareFunctionsIntegrationTest.java @@ -32,20 +32,22 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; import org.apache.ignite.transactions.Transaction; -import org.junit.Test; - +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Integration test for user defined functions with tx aware. */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR, value = "true") public class UserDefinedTxAwareFunctionsIntegrationTest extends AbstractBasicIntegrationTest { /** */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ViewsIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ViewsIntegrationTest.java index f6a284baf9ba1..ae1ce38acb365 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ViewsIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ViewsIntegrationTest.java @@ -27,7 +27,8 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.G; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** */ public class ViewsIntegrationTest extends AbstractMultiEngineIntegrationTest { @@ -51,9 +52,19 @@ public class ViewsIntegrationTest extends AbstractMultiEngineIntegrationTest { } /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); + @BeforeEach + @Override protected void beforeTest() throws Exception { + persistenceEnabled = false; + + assert G.allGrids().isEmpty() : "Not all Ignite instances stopped before tests execution:" + G.allGrids(); + + super.beforeTest(); + + cleanPersistenceDir(); + } + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { stopAllGrids(); cleanPersistenceDir(); @@ -244,7 +255,7 @@ public void testInMemory() throws Exception { * Tests view after persistent grid restart. */ @Test - public void testPersistance() throws Exception { + public void testPersistence() throws Exception { persistenceEnabled = true; initGrids(3); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/WindowIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/WindowIntegrationTest.java index 43ff9fa0eb50b..6a0a9fc93c205 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/WindowIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/WindowIntegrationTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration; import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration test for WINDOW operator. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/AbstractTpchTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/AbstractTpchTest.java index 8f0e410bb9fb7..1e3d46a3ae1e5 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/AbstractTpchTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/AbstractTpchTest.java @@ -18,32 +18,39 @@ package org.apache.ignite.internal.processors.query.calcite.integration.tpch; import java.util.Collection; +import java.util.concurrent.TimeUnit; import org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "queryId={0}") +@MethodSource("parameters") public abstract class AbstractTpchTest extends AbstractBasicIntegrationTest { /** */ protected static final Collection USED_TESTS = F.asList(15, 16, 17, 19, 20); /** Query ID. */ - @Parameterized.Parameter + @Parameter(0) public int qryId; /** */ protected abstract double scale(); /** */ - @Parameterized.Parameters(name = "queryId={0}") - public static Collection params() { + @MethodSource("parameters") + public static Collection parameters() { return USED_TESTS; } - /** {@inheritDoc} */ + /** */ + @BeforeAll + @Timeout(value = 10, unit = TimeUnit.MINUTES) @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale001Test.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale001Test.java index 205cdea33392f..23182a9f994f4 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale001Test.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale001Test.java @@ -17,11 +17,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration.tpch; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - /** */ -@RunWith(Parameterized.class) public class TpchScale001Test extends AbstractTpchTest { /** {@inheritDoc} */ @Override protected double scale() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale010Test.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale010Test.java index b6d39f13f5dca..e957ff7f5b55c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale010Test.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/tpch/TpchScale010Test.java @@ -17,11 +17,7 @@ package org.apache.ignite.internal.processors.query.calcite.integration.tpch; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - /** */ -@RunWith(Parameterized.class) public class TpchScale010Test extends AbstractTpchTest { /** */ @Override protected double scale() { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java index 0f956beb5ee3b..22f50fae58a5b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java @@ -24,12 +24,12 @@ import java.util.ArrayList; import java.util.List; import org.apache.ignite.IgniteException; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; /** * Abstract JDBC test. */ -public abstract class AbstractJdbcTest extends GridCommonAbstractTest { +public abstract class AbstractJdbcTest extends GridCommonAbstractWrapperTest { /** URL. */ protected static final String URL = "jdbc:ignite:thin://127.0.0.1"; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcConnectionEnabledPropertyTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcConnectionEnabledPropertyTest.java index b6cce49c10b8b..d84a9754d0030 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcConnectionEnabledPropertyTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcConnectionEnabledPropertyTest.java @@ -22,16 +22,17 @@ import java.sql.SQLException; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; - +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.cluster.DistributedConfigurationUtils.CONN_DISABLED_BY_ADMIN_ERR_MSG; import static org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.toMetaStorageKey; import static org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcThinTransactionalSelfTest.URL; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** */ -public class JdbcConnectionEnabledPropertyTest extends GridCommonAbstractTest { +public class JdbcConnectionEnabledPropertyTest extends GridCommonAbstractWrapperTest { /** */ private static final String JDBC_CONN_ENABLED_PROP = "newJdbcConnectionsEnabled"; @@ -45,12 +46,21 @@ public class JdbcConnectionEnabledPropertyTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); startGrid(); } + /** {@inheritDoc} */ + @AfterAll + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + /** */ @Test public void testConnectionEnabledProperty() throws Exception { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java index e3d7865d1f402..e725a0be6e675 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java @@ -32,7 +32,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Cross check queries on SQL engines. @@ -64,6 +66,7 @@ public class JdbcCrossEngineTest extends AbstractJdbcTest { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { startGrids(nodesCnt); @@ -78,6 +81,7 @@ public class JdbcCrossEngineTest extends AbstractJdbcTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { for (int i = 0; i < engineNames.length; i++) { if (stmts[i] != null && !stmts[i].isClosed()) { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java index 687de37a8a2d2..1b1b46fc4a2e6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java @@ -25,7 +25,8 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; /** */ public class JdbcLocalFlagTest extends AbstractJdbcTest { @@ -40,6 +41,7 @@ public class JdbcLocalFlagTest extends AbstractJdbcTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() { stopAllGrids(); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java index a22e1c896439c..3f2e582585f3d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java @@ -52,17 +52,22 @@ import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.query.QueryUtils; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.WithSystemProperty; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.apache.ignite.testframework.junit.SystemPropertiesExtension; +import org.apache.ignite.testframework.junit.WithSystemProperty; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * */ +@ExtendWith(SystemPropertiesExtension.class) @WithSystemProperty(key = "calcite.debug", value = "true") -public class JdbcQueryTest extends GridCommonAbstractTest { +public class JdbcQueryTest extends GridCommonAbstractWrapperTest { /** URL. */ private final String url = "jdbc:ignite:thin://127.0.0.1?queryEngine=" + CalciteQueryEngineConfiguration.ENGINE_NAME; @@ -87,8 +92,9 @@ public class JdbcQueryTest extends GridCommonAbstractTest { .setCacheConfiguration(ccfg); } - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + /** */ + @BeforeEach + void setup() throws Exception { startGrids(nodesCnt); connect(url); @@ -112,6 +118,7 @@ private void connect(String url) throws Exception { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { if (stmt != null && !stmt.isClosed()) { stmt.close(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoCacheInterceptorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoCacheInterceptorTest.java index 300b10679d837..699b38dc32590 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoCacheInterceptorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoCacheInterceptorTest.java @@ -21,8 +21,8 @@ import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import javax.cache.Cache; import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheAtomicityMode; @@ -34,22 +34,24 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.resources.SessionContextProviderResource; import org.apache.ignite.session.SessionContextProvider; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.junit.Assume.assumeFalse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assumptions.assumeFalse; /** */ -@RunWith(Parameterized.class) -public class JdbcSetClientInfoCacheInterceptorTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "runInTx={0}, mode={1}") +@MethodSource("data") +public class JdbcSetClientInfoCacheInterceptorTest extends GridCommonAbstractWrapperTest { /** */ private static final String SESSION_ID = "sessionId"; @@ -57,19 +59,19 @@ public class JdbcSetClientInfoCacheInterceptorTest extends GridCommonAbstractTes private static final String URL = "jdbc:ignite:thin://127.0.0.1"; /** */ - @Parameterized.Parameter + @Parameter(0) public boolean runInTx; /** */ - @Parameterized.Parameter(1) + @Parameter(1) public CacheAtomicityMode cacheMode; /** */ - @Parameterized.Parameters(name = "runInTx={0}, mode={1}") - public static Collection data() { + public static Stream data() { return GridTestUtils.cartesianProduct( - F.asList(false, true), - F.asList(CacheAtomicityMode.TRANSACTIONAL, CacheAtomicityMode.ATOMIC)); + List.of(false, true), + List.of(CacheAtomicityMode.TRANSACTIONAL, CacheAtomicityMode.ATOMIC) + ).stream().map(Arguments::of); } /** */ @@ -101,6 +103,7 @@ public static Collection data() { } /** */ + @BeforeEach @Override protected void beforeTest() { assumeFalse(runInTx && cacheMode == CacheAtomicityMode.ATOMIC); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoTest.java index 5119b1f1c6894..e48befa37fce6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcSetClientInfoTest.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.stream.Stream; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -36,22 +37,26 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.resources.SessionContextProviderResource; import org.apache.ignite.session.SessionContext; import org.apache.ignite.session.SessionContextProvider; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import static org.junit.Assume.assumeFalse; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assumptions.assumeFalse; /** */ -@RunWith(Parameterized.class) -public class JdbcSetClientInfoTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "runInTx={0}, mode={1}") +@MethodSource("data") +public class JdbcSetClientInfoTest extends GridCommonAbstractWrapperTest { /** */ private static final String SESSION_ID = "sessionId"; @@ -59,19 +64,21 @@ public class JdbcSetClientInfoTest extends GridCommonAbstractTest { private static final String URL = "jdbc:ignite:thin://127.0.0.1"; /** */ - @Parameterized.Parameter + @Parameter(0) public boolean runInTx; /** */ - @Parameterized.Parameter(1) + @Parameter(1) public CacheAtomicityMode cacheMode; /** */ - @Parameterized.Parameters(name = "runInTx={0}, mode={1}") - public static Collection data() { - return GridTestUtils.cartesianProduct( - F.asList(false, true), - F.asList(CacheAtomicityMode.TRANSACTIONAL, CacheAtomicityMode.ATOMIC)); + private static Stream data() { + Stream res = GridTestUtils.cartesianProduct( + List.of(false, true), + List.of(CacheAtomicityMode.TRANSACTIONAL, CacheAtomicityMode.ATOMIC) + ).stream().map(Arguments::of); + + return res; } /** {@inheritDoc} */ @@ -102,15 +109,17 @@ public static Collection data() { return cfg; } - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + /** */ + @BeforeEach + public void setup() throws Exception { assumeFalse(runInTx && cacheMode == CacheAtomicityMode.ATOMIC); startGrids(3); } - /** {@inheritDoc} */ - @Override protected void afterTest() { + /** */ + @AfterEach + public void cleanUp() { stopAllGrids(); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinConnectionSavepointTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinConnectionSavepointTest.java index 8e470ccab39e6..d6594aca87cfc 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinConnectionSavepointTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinConnectionSavepointTest.java @@ -22,25 +22,29 @@ import java.sql.SQLException; import java.sql.Savepoint; import java.sql.Statement; -import java.util.Arrays; +import java.util.Collection; import java.util.List; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.transactions.TransactionConcurrency; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; /** Savepoint tests for thin JDBC connection. */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "{0}") +@MethodSource("testData") public class JdbcThinConnectionSavepointTest extends AbstractJdbcTest { /** */ private static final String TBL = "SAVEPOINT_TEST_TABLE"; @@ -55,12 +59,11 @@ public class JdbcThinConnectionSavepointTest extends AbstractJdbcTest { /** * @return Test parameters. */ - @Parameters(name = "{0}") - public static Iterable testData() { - return Arrays.asList(new Object[][] { - {PESSIMISTIC}, - {OPTIMISTIC} - }); + private static Collection testData() { + return List.of( + Arguments.of(PESSIMISTIC), + Arguments.of(OPTIMISTIC) + ); } /** {@inheritDoc} */ @@ -73,6 +76,7 @@ public static Iterable testData() { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -80,6 +84,7 @@ public static Iterable testData() { } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() throws Exception { stopAllGrids(); @@ -87,6 +92,7 @@ public static Iterable testData() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -287,6 +293,6 @@ private void assertQuery(Connection conn, Object... exp) throws SQLException { assertEquals(exp.length / 2, rows.size()); for (int i = 0; i < exp.length; i += 2) - assertEqualsCollections(Arrays.asList(exp[i], exp[i + 1]), rows.get(i / 2)); + assertEqualsCollections(List.of(exp[i], exp[i + 1]), rows.get(i / 2)); } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java index 7120f15e2e0aa..98212b37bc409 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java @@ -24,19 +24,22 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.Arrays; +import java.util.Collection; import java.util.List; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest.TestRunnable; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.TransactionConcurrency; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.sql.Connection.TRANSACTION_NONE; import static java.sql.Connection.TRANSACTION_READ_COMMITTED; import static java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; @@ -49,16 +52,16 @@ import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** */ -@RunWith(Parameterized.class) -public class JdbcThinTransactionalSelfTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "partitionAwareness={0}") +@MethodSource("parameters") +public class JdbcThinTransactionalSelfTest extends GridCommonAbstractWrapperTest { /** */ - @Parameterized.Parameter + @Parameter public boolean partitionAwareness; /** */ - @Parameterized.Parameters(name = "partitionAwareness={0}") - public static Object[] parameters() { - return new Object[] {false, true}; + private static Collection parameters() { + return List.of(Arguments.of(false), Arguments.of(true)); } /** URL. */ @@ -75,12 +78,21 @@ public static Object[] parameters() { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); startGrid(); } + /** {@inheritDoc} */ + @AfterAll + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + /** */ @Test public void testDatabaseMetadata() throws Exception { @@ -103,7 +115,7 @@ public void testDatabaseMetadata() throws Exception { @Test public void testInvalidHoldability() throws Exception { try (Connection conn = DriverManager.getConnection(url())) { - List checks = Arrays.asList( + List checks = List.of( () -> conn.setHoldability(HOLD_CURSORS_OVER_COMMIT), () -> conn.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT), () -> conn.prepareStatement("SELECT * FROM T", TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT) diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/logical/ScriptTestRunner.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/logical/ScriptTestRunner.java deleted file mode 100644 index 24899ef5489c0..0000000000000 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/logical/ScriptTestRunner.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.query.calcite.logical; - -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Pattern; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.Ignition; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.IgnitionEx; -import org.apache.ignite.internal.processors.query.QueryEngine; -import org.apache.ignite.internal.processors.query.calcite.util.Commons; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; -import org.apache.ignite.thread.IgniteThread; -import org.junit.runner.Description; -import org.junit.runner.Runner; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunNotifier; - -/** - * - */ -public class ScriptTestRunner extends Runner { - /** Filesystem. */ - private static final FileSystem FS = FileSystems.getDefault(); - - /** Shared finder. */ - private static final TcpDiscoveryVmIpFinder sharedFinder = new TcpDiscoveryVmIpFinder().setShared(true); - - /** */ - private static IgniteLogger log; - - static { - try { - log = new GridTestLog4jLogger(U.resolveIgnitePath("modules/core/src/test/config/log4j2-test.xml")); - } - catch (Exception e) { - e.printStackTrace(System.err); - - log = null; - - assert false : "Cannot init logger"; - } - } - - /** */ - private final Class testCls; - - /** Scripts root directory. */ - private final Path scriptsRoot; - - /** Regex to filter test path to run only specified tests. */ - private final Pattern testRegex; - - /** Nodes count. */ - private final int nodes; - - /** Restart cluster for each test group. */ - private final boolean restartCluster; - - /** Test script timeout. */ - private final long timeout; - - /** */ - public ScriptTestRunner(Class testCls) { - this.testCls = testCls; - ScriptRunnerTestsEnvironment env = testCls.getAnnotation(ScriptRunnerTestsEnvironment.class); - - assert !F.isEmpty(env.scriptsRoot()); - - nodes = env.nodes(); - scriptsRoot = FS.getPath(U.resolveIgnitePath(env.scriptsRoot()).getPath()); - testRegex = F.isEmpty(env.regex()) ? null : Pattern.compile(env.regex()); - restartCluster = env.restart(); - timeout = env.timeout(); - } - - /** {@inheritDoc} */ - @Override public Description getDescription() { - return Description.createSuiteDescription(testCls.getName(), "scripts"); - } - - /** {@inheritDoc} */ - @Override public void run(final RunNotifier notifier) { - try { - Files.walk(scriptsRoot).sorted().forEach((p) -> { - if (p.equals(scriptsRoot)) - return; - - if (Files.isDirectory(p)) { - if (!F.isEmpty(Ignition.allGrids()) && restartCluster) { - log.info(">>> Restart cluster"); - - Ignition.stopAll(false); - } - - return; - } - - runTest(p, notifier); - }); - } - catch (Exception e) { - throw new RuntimeException(e); - } - finally { - Ignition.stopAll(false); - } - } - - /** */ - private void runTest(Path test, RunNotifier notifier) { - String dirName; - if (test.getNameCount() - 1 > scriptsRoot.getNameCount()) - dirName = test.subpath(scriptsRoot.getNameCount(), test.getNameCount() - 1).toString(); - else - dirName = scriptsRoot.subpath(scriptsRoot.getNameCount() - 1, scriptsRoot.getNameCount()).toString(); - - String fileName = test.getFileName().toString(); - - Description desc = Description.createTestDescription(dirName, fileName); - - if (testRegex != null && !testRegex.matcher(test.toString()).find()) - return; - - if (testRegex == null && !fileName.endsWith(".test") && !fileName.endsWith(".test_slow")) { - if (fileName.endsWith(".test_ignore")) - notifier.fireTestIgnored(desc); - - return; - } - - beforeTest(); - - notifier.fireTestStarted(desc); - - try { - Ignite ign = F.first(Ignition.allGrids()); - - QueryEngine engine = Commons.lookupComponent( - ((IgniteEx)ign).context(), - QueryEngine.class - ); - - SqlScriptRunner scriptTestRunner = new SqlScriptRunner(test, engine, log); - - log.info(">>> Start: " + dirName + "/" + fileName); - - runScript(scriptTestRunner); - } - catch (Throwable e) { - notifier.fireTestFailure(new Failure(desc, e)); - } - finally { - log.info(">>> Finish: " + dirName + "/" + fileName); - notifier.fireTestFinished(desc); - } - } - - /** */ - private void beforeTest() { - if (F.isEmpty(Ignition.allGrids())) - startCluster(); - else { - Ignite ign = F.first(Ignition.allGrids()); - - for (String cacheName : ign.cacheNames()) - ign.destroyCache(cacheName); - } - } - - /** */ - private void startCluster() { - for (int i = 0; i < nodes; ++i) { - Ignition.start( - new IgniteConfiguration() - .setIgniteInstanceName("srv" + i) - .setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(sharedFinder) - ) - .setGridLogger(log) - ); - } - } - - /** */ - private void runScript(SqlScriptRunner scriptRunner) throws Throwable { - final AtomicReference ex = new AtomicReference<>(); - - Thread runner = new IgniteThread("srv0", "test-runner", new Runnable() { - @Override public void run() { - try { - scriptRunner.run(); - } - catch (Throwable e) { - ex.set(e); - } - } - }); - - runner.start(); - - runner.join(timeout); - - if (runner.isAlive()) { - U.error(log, - "Test has been timed out and will be interrupted"); - - List nodes = IgnitionEx.allGridsx(); - - for (Ignite node : nodes) - ((IgniteKernal)node).dumpDebugInfo(); - - // We dump threads to stdout, because we can loose logs in case - // the build is cancelled on TeamCity. - U.dumpThreads(null); - - U.dumpThreads(log); - - // Try to interrupt runner several times for case when InterruptedException is handled invalid. - for (int i = 0; i < 100 && runner.isAlive(); ++i) { - U.interrupt(runner); - - U.sleep(10); - } - - U.join(runner, log); - - // Restart cluster - Ignition.stopAll(true); - startCluster(); - - throw new TimeoutException("Test has been timed out"); - } - - Throwable t = ex.get(); - - if (t != null) - throw t; - } -} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java index 4b5493be2be51..ca3aec83c26e9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java @@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import org.apache.ignite.internal.processors.query.calcite.exec.task.AbstractQueryTaskExecutor; import org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verifies that payload of calcite messages is unmarshalled on the query task executor, not on a NIO thread: probe diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java index 6c29252f6bd64..797c1169e8486 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java @@ -55,6 +55,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.failure.FailureProcessor; import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; import org.apache.ignite.internal.processors.query.calcite.exec.task.StripedQueryTaskExecutor; import org.apache.ignite.internal.processors.query.calcite.externalize.RelJsonReader; @@ -81,12 +82,10 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.ListeningTestLogger; import org.apache.ignite.testframework.junits.GridTestKernalContext; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.After; -import org.junit.Before; - +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import static org.apache.calcite.tools.Frameworks.createRootSchema; import static org.apache.ignite.internal.processors.query.calcite.externalize.RelJsonWriter.toJson; @@ -95,7 +94,7 @@ */ //@WithSystemProperty(key = "calcite.debug", value = "true") @SuppressWarnings({"TooBroadScope", "FieldCanBeLocal", "TypeMayBeWeakened"}) -public abstract class AbstractPlannerTest extends GridCommonAbstractTest { +public abstract class AbstractPlannerTest extends GridCommonAbstractWrapperTest { /** */ private static final RelDataTypeSystem TYPE_SYSTEM = CalciteQueryProcessor.FRAMEWORK_CONFIG.getTypeSystem(); @@ -124,7 +123,7 @@ public abstract class AbstractPlannerTest extends GridCommonAbstractTest { protected ListeningTestLogger lsnrLog = new ListeningTestLogger(log); /** */ - @Before + @BeforeEach public void setup() { nodes = new ArrayList<>(4); @@ -133,7 +132,7 @@ public void setup() { } /** */ - @After + @AfterEach public void tearDown() throws Throwable { if (!F.isEmpty(executors)) executors.forEach(StripedQueryTaskExecutor::tearDown); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerUtilityTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerUtilityTest.java index 303591fdb4fe8..20b24d3bd2c6f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerUtilityTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerUtilityTest.java @@ -37,8 +37,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.jetbrains.annotations.NotNull; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; /** {@link AbstractPlannerTest} inner utility methods test. */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregateDistinctPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregateDistinctPlannerTest.java index 410207ebe8b14..11252a7cf425d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregateDistinctPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregateDistinctPlannerTest.java @@ -36,24 +36,25 @@ import org.apache.ignite.internal.processors.query.calcite.rel.agg.IgniteReduceSortAggregate; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "Algorithm = {0}") +@MethodSource("parameters") public class AggregateDistinctPlannerTest extends AbstractAggregatePlannerTest { /** Algorithm. */ - @Parameterized.Parameter + @Parameter public AggregateAlgorithm algo; /** */ - @Parameterized.Parameters(name = "Algorithm = {0}") - public static List parameters() { - return Stream.of(AggregateAlgorithm.values()).map(a -> new Object[]{a}).collect(Collectors.toList()); + private static List parameters() { + return Stream.of(AggregateAlgorithm.values()).map(Arguments::of).collect(Collectors.toList()); } /** @@ -84,11 +85,11 @@ public void mapReduceDistinctWithIndex() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys, SqlExplainLevel.ALL_ATTRIBUTES), rdcAgg); assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), mapAgg); - Assert.assertTrue( + assertTrue( "Invalid plan\n" + RelOptUtil.toString(phys), F.isEmpty(rdcAgg.getAggregateCalls())); - Assert.assertTrue( + assertTrue( "Invalid plan\n" + RelOptUtil.toString(phys), F.isEmpty(mapAgg.getAggCallList())); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregatePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregatePlannerTest.java index 19395f014c40d..9cd942a2229b6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregatePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AggregatePlannerTest.java @@ -48,24 +48,27 @@ import org.apache.ignite.internal.processors.query.calcite.trait.TraitUtils; import org.apache.ignite.internal.util.typedef.F; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.hamcrest.MatcherAssert.assertThat; /** * */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "Algorithm = {0}") +@MethodSource("parameters") public class AggregatePlannerTest extends AbstractAggregatePlannerTest { /** Algorithm. */ - @Parameterized.Parameter + @Parameter public AggregateAlgorithm algo; /** */ - @Parameterized.Parameters(name = "Algorithm = {0}") - public static List parameters() { - return Stream.of(AggregateAlgorithm.values()).map(a -> new Object[]{a}).collect(Collectors.toList()); + private static List parameters() { + return Stream.of(AggregateAlgorithm.values()).map(Arguments::of).collect(Collectors.toList()); } /** @@ -93,7 +96,7 @@ public void singleWithoutIndex() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), agg); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(agg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); @@ -127,7 +130,7 @@ public void singleWithIndex() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), agg); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(agg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); @@ -163,12 +166,12 @@ public void mapReduceGroupBy() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys, SqlExplainLevel.ALL_ATTRIBUTES), rdcAgg); assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), mapAgg); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(rdcAgg.getAggregateCalls()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(mapAgg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedNestedLoopJoinPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedNestedLoopJoinPlannerTest.java index 55ad49ace4c93..5429d67598b49 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedNestedLoopJoinPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedNestedLoopJoinPlannerTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.function.Predicate; - import org.apache.calcite.plan.RelOptUtil; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.core.JoinRelType; @@ -33,8 +32,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedSubqueryPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedSubqueryPlannerTest.java index 202bdef4aa0cf..11c36e47e4722 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedSubqueryPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/CorrelatedSubqueryPlannerTest.java @@ -50,7 +50,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.util.RexUtils; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** Tests to verify correlated subquery planning. */ public class CorrelatedSubqueryPlannerTest extends AbstractPlannerTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DataTypesPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DataTypesPlannerTest.java index 140665b4ca4ce..57a5da6d38b57 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DataTypesPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DataTypesPlannerTest.java @@ -34,7 +34,7 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Planner test various types, casts and coercions. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DynamicParametersPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DynamicParametersPlannerTest.java index e27d9eb468c07..f797d456f35e1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DynamicParametersPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/DynamicParametersPlannerTest.java @@ -20,7 +20,7 @@ import java.math.BigInteger; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.single; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashAggregatePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashAggregatePlannerTest.java index bb629b2e5d28d..f6d9d9f5e02b5 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashAggregatePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashAggregatePlannerTest.java @@ -42,10 +42,10 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.util.typedef.F; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.trait.TraitUtils.createFieldCollation; +import static org.hamcrest.MatcherAssert.assertThat; /** * @@ -245,12 +245,12 @@ public void subqueryWithAggregate() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), rdcAgg); assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), mapAgg); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(rdcAgg.getAggregateCalls()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(mapAgg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class)); @@ -282,12 +282,12 @@ public void noGroupByAggregate() throws Exception { assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), rdcAgg); assertNotNull("Invalid plan\n" + RelOptUtil.toString(phys), mapAgg); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(rdcAgg.getAggregateCalls()).getAggregation(), IsInstanceOf.instanceOf(SqlCountAggFunction.class)); - Assert.assertThat( + assertThat( "Invalid plan\n" + RelOptUtil.toString(phys), F.first(mapAgg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlCountAggFunction.class)); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashIndexSpoolPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashIndexSpoolPlannerTest.java index 44b05e243358b..28951ce65af2c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashIndexSpoolPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashIndexSpoolPlannerTest.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashJoinPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashJoinPlannerTest.java index 55140639755bd..1acdbe25105fb 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashJoinPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/HashJoinPlannerTest.java @@ -29,7 +29,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.calcite.rel.RelFieldCollation.Direction.ASCENDING; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexRebuildPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexRebuildPlannerTest.java index 14c100a887127..333f0e75c8b8b 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexRebuildPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexRebuildPlannerTest.java @@ -30,8 +30,8 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.SqlKind.COUNT; import static org.apache.calcite.sql.SqlKind.MAX; import static org.apache.calcite.sql.SqlKind.MIN; @@ -48,6 +48,7 @@ public class IndexRebuildPlannerTest extends AbstractPlannerTest { private TestTable tbl; /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexSearchBoundsPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexSearchBoundsPlannerTest.java index 3311a8361e08e..96e4561fa9eaa 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexSearchBoundsPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/IndexSearchBoundsPlannerTest.java @@ -39,7 +39,8 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.processors.query.calcite.util.RexUtils; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Planner test for indexed fields scans. @@ -52,6 +53,7 @@ public class IndexSearchBoundsPlannerTest extends AbstractPlannerTest { private TestTable tbl; /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/InlineIndexScanPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/InlineIndexScanPlannerTest.java index a434da809e4a1..b0fe07aa9815c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/InlineIndexScanPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/InlineIndexScanPlannerTest.java @@ -22,7 +22,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.AbstractIndexScan; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Planner test for index inline scan. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinColocationPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinColocationPlannerTest.java index 0b06c0ddd75fc..b194a7836d7b8 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinColocationPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinColocationPlannerTest.java @@ -31,11 +31,11 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test suite to verify join colocation. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinCommutePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinCommutePlannerTest.java index 8e704c047c535..0342f38fcd49f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinCommutePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinCommutePlannerTest.java @@ -42,7 +42,8 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** Tests correctness applying of JOIN_COMMUTE* and {@link IgniteMultiJoinOptimizeRule} rules. */ public class JoinCommutePlannerTest extends AbstractPlannerTest { @@ -50,6 +51,7 @@ public class JoinCommutePlannerTest extends AbstractPlannerTest { private static IgniteSchema publicSchema; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinWithUsingPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinWithUsingPlannerTest.java index 66683b7553925..ae9c89feda2c7 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinWithUsingPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/JoinWithUsingPlannerTest.java @@ -26,8 +26,8 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for JOIN with USING and NATURAL JOIN. @@ -37,7 +37,7 @@ public class JoinWithUsingPlannerTest extends AbstractPlannerTest { private final Collection schemas = new ArrayList<>(); /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/LimitOffsetPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/LimitOffsetPlannerTest.java index 98a91eb61def3..c6a27eb54850d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/LimitOffsetPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/LimitOffsetPlannerTest.java @@ -41,7 +41,7 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.util.RexUtils.doubleFromRex; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java index c15009fca3372..c49cd50c27a15 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java @@ -30,8 +30,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.rel.RelFieldCollation.Direction.ASCENDING; import static org.apache.calcite.rel.RelFieldCollation.Direction.DESCENDING; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanExecutionTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanExecutionTest.java index 45d6309653078..bd102cf2bc719 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanExecutionTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanExecutionTest.java @@ -67,11 +67,12 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider; import org.apache.ignite.testframework.junits.GridTestKernalContext; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.tools.Frameworks.createRootSchema; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_THREAD_KEEP_ALIVE_TIME; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * @@ -79,6 +80,7 @@ @SuppressWarnings({"TooBroadScope", "FieldCanBeLocal", "TypeMayBeWeakened"}) public class PlanExecutionTest extends AbstractPlannerTest { /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -165,8 +167,8 @@ public void testPhysicalPlan() throws Exception { assertFalse(res.isEmpty()); - Assert.assertArrayEquals(new Object[]{0, "Igor", 0, "Calcite", 1}, res.get(0)); - Assert.assertArrayEquals(new Object[]{1, "Roman", 0, "Calcite", 1}, res.get(1)); + assertArrayEquals(new Object[]{0, "Igor", 0, "Calcite", 1}, res.get(0)); + assertArrayEquals(new Object[]{1, "Roman", 0, "Calcite", 1}, res.get(1)); } /** @@ -227,7 +229,7 @@ public void testPhysicalPlan2() throws Exception { int pos = 0; for (Object obj : checkRes.get()) - Assert.assertArrayEquals((Object[])obj, res.get(pos++)); + assertArrayEquals((Object[])obj, res.get(pos++)); } /** */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java index 72cf2738a512a..44438554d2b2d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java @@ -34,8 +34,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlannerTimeoutTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlannerTimeoutTest.java index 408926bb53cb0..8715d026d6666 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlannerTimeoutTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlannerTimeoutTest.java @@ -33,13 +33,24 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.trait.TraitUtils; +import org.apache.ignite.internal.util.CommonUtils; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; /** * Test planner timeout. */ +@Order(1) public class PlannerTimeoutTest extends AbstractPlannerTest { + /** */ + @BeforeAll + static void init() { + // Additional check for val correctness: GridTestClockTimer#startTestTimer + assertEquals(1, (int)GridTestUtils.getFieldValue(CommonUtils.class, "gridCnt")); + } + /** */ private static final long PLANNER_TIMEOUT = 1_000; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/ProjectFilterScanMergePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/ProjectFilterScanMergePlannerTest.java index 95b0b3c2700c2..1e672ccd531f6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/ProjectFilterScanMergePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/ProjectFilterScanMergePlannerTest.java @@ -28,8 +28,8 @@ import org.apache.ignite.internal.processors.query.calcite.rel.IgniteTableScan; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; @@ -41,7 +41,7 @@ public class ProjectFilterScanMergePlannerTest extends AbstractPlannerTest { private IgniteSchema publicSchema; /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RecursiveCtePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RecursiveCtePlannerTest.java index d1700071af147..1c5e557a1feed 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RecursiveCtePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RecursiveCtePlannerTest.java @@ -42,7 +42,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** Planner tests for recursive common table expressions. */ public class RecursiveCtePlannerTest extends AbstractPlannerTest { diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java index 49ea85823e93e..14e72023230ed 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java @@ -35,8 +35,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.processors.query.calcite.util.RexUtils; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.single; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SerializationPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SerializationPlannerTest.java index bc2ff7e89fe40..11eb9a7e077e7 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SerializationPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SerializationPlannerTest.java @@ -25,8 +25,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.single; /** diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SetOpPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SetOpPlannerTest.java index 55b52240b446b..e83248160488a 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SetOpPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SetOpPlannerTest.java @@ -20,8 +20,6 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.ignite.internal.processors.query.calcite.rel.IgniteExchange; @@ -40,31 +38,27 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.EnumSource; /** * Test to verify set op (EXCEPT, INTERSECT). */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "SetOp = {0}") +@EnumSource(value = SetOpPlannerTest.SetOp.class) public class SetOpPlannerTest extends AbstractPlannerTest { /** Algorithm. */ - @Parameterized.Parameter + @Parameter public SetOp setOp; - /** */ - @Parameterized.Parameters(name = "SetOp = {0}") - public static List parameters() { - return Stream.of(SetOp.values()).map(a -> new Object[]{a}).collect(Collectors.toList()); - } - /** Public schema. */ private IgniteSchema publicSchema; /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java index 2f0e13cc24c4a..4dfbddba67339 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java @@ -45,8 +45,7 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.random; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.single; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortedIndexSpoolPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortedIndexSpoolPlannerTest.java index 63ed1c6a8d6b5..eef82676ef049 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortedIndexSpoolPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortedIndexSpoolPlannerTest.java @@ -35,8 +35,8 @@ import org.apache.ignite.internal.processors.query.calcite.trait.TraitUtils; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @@ -229,7 +229,7 @@ public void testDescFields() throws Exception { * Check sorted spool without input collation. */ @Test - @Ignore("https://issues.apache.org/jira/browse/IGNITE-16430") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-16430") public void testRestoreCollation() throws Exception { IgniteSchema publicSchema = createSchema( createTable("T0", 100, IgniteDistributions.random(), diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/StatisticsPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/StatisticsPlannerTest.java index 59409e1be0e2f..ad330d849008f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/StatisticsPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/StatisticsPlannerTest.java @@ -37,8 +37,8 @@ import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; import org.apache.ignite.internal.processors.query.stat.ColumnStatistics; import org.apache.ignite.internal.processors.query.stat.ObjectStatisticsImpl; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.stat.StatisticsUtils.toDecimal; @@ -86,7 +86,7 @@ public class StatisticsPlannerTest extends AbstractPlannerTest { private IgniteStatisticsImpl tbl1stat; /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableDmlPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableDmlPlannerTest.java index 1694b8d7773a2..864512dfe5450 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableDmlPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableDmlPlannerTest.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; import static org.apache.calcite.sql.type.SqlTypeName.OTHER; @@ -41,7 +41,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Table spool test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableFunctionPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableFunctionPlannerTest.java index 227a95b5a2c67..7f49d1558eb5d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableFunctionPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableFunctionPlannerTest.java @@ -27,8 +27,8 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test table functions. @@ -39,7 +39,7 @@ public class TableFunctionPlannerTest extends AbstractPlannerTest { /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableSpoolPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableSpoolPlannerTest.java index 04eeb95cc858b..9cb0e42400ab9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableSpoolPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/TableSpoolPlannerTest.java @@ -26,7 +26,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Table spool test. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UncollectPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UncollectPlannerTest.java index 435d4d41607e4..ee38c3d682937 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UncollectPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UncollectPlannerTest.java @@ -27,8 +27,8 @@ import org.apache.ignite.internal.processors.query.calcite.rel.IgniteUncollect; import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.broadcast; import static org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions.single; @@ -41,7 +41,7 @@ public class UncollectPlannerTest extends AbstractPlannerTest { private IgniteSchema publicSchema; /** {@inheritDoc} */ - @Before + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UnionPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UnionPlannerTest.java index 19eddfe5ce083..667a99b89d643 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UnionPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UnionPlannerTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.query.calcite.planner; import java.util.Arrays; - import org.apache.calcite.rel.core.Union; import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup; @@ -30,7 +29,7 @@ import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory; import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeSystem; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UserDefinedViewsPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UserDefinedViewsPlannerTest.java index 9976074e86c64..67b3717091d78 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UserDefinedViewsPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/UserDefinedViewsPlannerTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; import org.apache.ignite.testframework.GridTestUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.calcite.sql.type.SqlTypeName.INTEGER; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/WindowPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/WindowPlannerTest.java index c38512955f032..9ee548cf13fb6 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/WindowPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/WindowPlannerTest.java @@ -45,7 +45,7 @@ import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.internal.util.typedef.F; import org.jetbrains.annotations.Nullable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static java.util.function.Predicate.not; import static org.apache.calcite.rex.RexWindowBounds.CURRENT_ROW; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/CommonHintsPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/CommonHintsPlannerTest.java index e268f61fb948d..728d521c3bbc4 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/CommonHintsPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/CommonHintsPlannerTest.java @@ -26,7 +26,9 @@ import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.logging.log4j.Level; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Common test for SQL hints. @@ -39,6 +41,7 @@ public class CommonHintsPlannerTest extends AbstractPlannerTest { private TestTable tbl; /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); @@ -49,6 +52,7 @@ public class CommonHintsPlannerTest extends AbstractPlannerTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/ForceIndexHintPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/ForceIndexHintPlannerTest.java index fa88732a1b611..904cb9a9a824d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/ForceIndexHintPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/ForceIndexHintPlannerTest.java @@ -25,7 +25,9 @@ import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.logging.log4j.Level; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Planner test for force index hint. @@ -41,6 +43,7 @@ public class ForceIndexHintPlannerTest extends AbstractPlannerTest { private TestTable tbl2; /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); @@ -64,6 +67,7 @@ public class ForceIndexHintPlannerTest extends AbstractPlannerTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/HintsTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/HintsTestSuite.java index aaddbc3d95391..946d238b59045 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/HintsTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/HintsTestSuite.java @@ -17,14 +17,14 @@ package org.apache.ignite.internal.processors.query.calcite.planner.hints; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * SQL hints tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ CommonHintsPlannerTest.class, NoIndexHintPlannerTest.class, ForceIndexHintPlannerTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinOrderHintsPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinOrderHintsPlannerTest.java index 18971d79faf44..c807e0b2a54b1 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinOrderHintsPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinOrderHintsPlannerTest.java @@ -30,7 +30,9 @@ import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.logging.log4j.Level; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Planner test for join order hints. @@ -40,6 +42,7 @@ public class JoinOrderHintsPlannerTest extends AbstractPlannerTest { private IgniteSchema schema; /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); @@ -47,6 +50,7 @@ public class JoinOrderHintsPlannerTest extends AbstractPlannerTest { } /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinTypeHintPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinTypeHintPlannerTest.java index 692e3a9f6bd41..1465b6c38e3dc 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinTypeHintPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/JoinTypeHintPlannerTest.java @@ -41,8 +41,9 @@ import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.logging.log4j.Level; -import org.junit.Test; - +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition.CNL_JOIN; import static org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition.HASH_JOIN; import static org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition.MERGE_JOIN; @@ -67,6 +68,7 @@ public class JoinTypeHintPlannerTest extends AbstractPlannerTest { private IgniteSchema schema; /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); @@ -74,6 +76,7 @@ public class JoinTypeHintPlannerTest extends AbstractPlannerTest { } /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/NoIndexHintPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/NoIndexHintPlannerTest.java index e79a766f7a559..36daf8b11bcb0 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/NoIndexHintPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/hints/NoIndexHintPlannerTest.java @@ -26,7 +26,9 @@ import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.logging.log4j.Level; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Planner test for index hints. @@ -42,6 +44,7 @@ public class NoIndexHintPlannerTest extends AbstractPlannerTest { private TestTable tbl2; /** {@inheritDoc} */ + @BeforeEach @Override public void setup() { super.setup(); @@ -63,6 +66,7 @@ public class NoIndexHintPlannerTest extends AbstractPlannerTest { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/tpc/TpchQueryPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/tpc/TpchQueryPlannerTest.java index 70125f6d4e830..8751cf718ed10 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/tpc/TpchQueryPlannerTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/tpc/TpchQueryPlannerTest.java @@ -25,26 +25,29 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collection; import java.util.Comparator; import java.util.regex.Pattern; -import java.util.stream.Collectors; +import java.util.stream.Stream; import com.google.common.io.CharStreams; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest; import org.apache.ignite.internal.processors.query.calcite.integration.tpch.TpchHelper; import org.apache.ignite.internal.util.typedef.internal.U; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests ensures a planner generates optimal plan for TPC-H queries. * * @code org.apache.ignite.internal.sql.engine.benchmarks.TpchParseBenchmark */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "queryId={0}") +@MethodSource("parameters") public class TpchQueryPlannerTest extends AbstractBasicIntegrationTest { /** Set to {@code true} to write plan files, instead of checking. */ private static final boolean UPDATE_PLAN = false; @@ -62,18 +65,17 @@ public class TpchQueryPlannerTest extends AbstractBasicIntegrationTest { public static final String RSRC_DIR = "modules/calcite/src/test/resources/" + TPCH; /** */ - @Parameterized.Parameters(name = "queryId={0}") - public static Collection params() throws IOException { + public static Stream parameters() throws IOException { return Files.list(FileSystems.getDefault().getPath(U.resolveIgnitePath(RSRC_DIR).getPath())) .map(p -> p.getFileName().toString()) .filter(p -> p.endsWith(".sql") && !p.endsWith("ddl.sql")) .map(p -> p.replace(".sql", "")) .sorted(Comparator.comparingInt(p -> Integer.parseInt(p.replace("variant_q", "").replace("q", "")))) - .collect(Collectors.toList()); + .map(Arguments::of); } /** Query id. */ - @Parameterized.Parameter + @Parameter public String qryId; /** {@inheritDoc} */ @@ -86,6 +88,7 @@ public static Collection params() throws IOException { } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinCommuteRulesTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinCommuteRulesTest.java index 8292f99749d10..e418524e8e4eb 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinCommuteRulesTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinCommuteRulesTest.java @@ -21,19 +21,21 @@ import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.QueryEngine; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.util.Commons; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsSubPlan; import static org.apache.ignite.internal.processors.query.calcite.QueryChecker.containsTableScan; /** Tests correctness applying of JOIN_COMMUTE* rules. */ -public class JoinCommuteRulesTest extends GridCommonAbstractTest { +public class JoinCommuteRulesTest extends GridCommonAbstractWrapperTest { /** */ private static QueryEngine qryEngine; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(2); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinOrderOptimizationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinOrderOptimizationTest.java index c5396eb3767e4..90b69cf8b468c 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinOrderOptimizationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/JoinOrderOptimizationTest.java @@ -20,16 +20,19 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import org.apache.calcite.rel.rules.JoinToMultiJoinRule; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.RuleApplyListener; import org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest; import org.apache.ignite.internal.processors.query.calcite.rule.logical.IgniteMultiJoinOptimizeRule; import org.apache.ignite.internal.util.typedef.F; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition.ENFORCE_JOIN_ORDER; /** @@ -38,19 +41,22 @@ * @see JoinToMultiJoinRule * @see IgniteMultiJoinOptimizeRule */ -@RunWith(Parameterized.class) +@ParameterizedClass +@MethodSource("runConfig") public class JoinOrderOptimizationTest extends AbstractBasicIntegrationTest { /** Test query. */ - @Parameterized.Parameter + @Parameter public String qry; /** Test queries. */ - @Parameterized.Parameters - public static Collection runConfig() { - return testQueries(); + private static Collection runConfig() { + return testQueries().stream() + .map(Arguments::of) + .collect(Collectors.toList()); } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/OrToUnionRuleTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/OrToUnionRuleTest.java index 926d288a38431..64e9a55cd4e1e 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/OrToUnionRuleTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/OrToUnionRuleTest.java @@ -25,11 +25,12 @@ import org.apache.ignite.cache.QueryIndexType; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.QueryEngine; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.util.Commons; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -53,7 +54,7 @@ * SELECT * FROM products * WHERE subcategory ='Camera Media' AND LNNVL(category, 'Photo'); */ -public class OrToUnionRuleTest extends GridCommonAbstractTest { +public class OrToUnionRuleTest extends GridCommonAbstractWrapperTest { /** */ public static final String IDX_SUBCAT_ID = "IDX_SUBCAT_ID"; @@ -67,6 +68,7 @@ public class OrToUnionRuleTest extends GridCommonAbstractTest { public static final String IDX_CAT_ID = "IDX_CAT_ID"; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { Ignite grid = startGridsMultiThreaded(2); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/ProjectScanMergeRuleTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/ProjectScanMergeRuleTest.java index 8dae4da851ac0..59241cb846954 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/ProjectScanMergeRuleTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/ProjectScanMergeRuleTest.java @@ -25,11 +25,12 @@ import org.apache.ignite.cache.QueryIndexType; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.QueryEngine; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.QueryChecker; import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -46,11 +47,12 @@ * sql execution: SELECT t1.f11, t2.f21 FROM T1 t1 INNER JOIN T2 t2 on t1.f11 = t2.f22" * need to eleminate all unused coluns and take into account only: f11, f21 and f22 cols. */ -public class ProjectScanMergeRuleTest extends GridCommonAbstractTest { +public class ProjectScanMergeRuleTest extends GridCommonAbstractWrapperTest { /** */ public static final String IDX_CAT_ID = "IDX_CAT_ID"; /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { Ignite grid = startGridsMultiThreaded(2); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/ParserCodegenResourcesTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/ParserCodegenResourcesTest.java index eb34431d7774f..80f22d66064a9 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/ParserCodegenResourcesTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/ParserCodegenResourcesTest.java @@ -18,14 +18,15 @@ package org.apache.ignite.internal.processors.query.calcite.sql; import org.apache.ignite.internal.processors.query.calcite.sql.generated.IgniteSqlParserImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertNotNull; /** Verifies that parser code generation inputs are published as module resources. */ public class ParserCodegenResourcesTest { /** Verifies resources required to extend the Ignite SQL grammar. */ - @Test public void testParserCodegenResourcesAvailable() { + @Test + public void testParserCodegenResourcesAvailable() { assertResourceAvailable("/codegen/config.fmpp"); assertResourceAvailable("/codegen/includes/parserImpls.ftl"); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlCustomParserTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlCustomParserTest.java index 165c5c2804e89..3af3b90193803 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlCustomParserTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlCustomParserTest.java @@ -41,6 +41,7 @@ import org.apache.calcite.sql.parser.SqlParseException; import org.apache.calcite.sql.parser.SqlParser; import org.apache.calcite.sql.validate.SqlValidatorException; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.sql.generated.IgniteSqlParserImpl; import org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillComputeTask; import org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillContinuousQuery; @@ -55,12 +56,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.hamcrest.CustomMatcher; import org.hamcrest.Matcher; import org.jetbrains.annotations.Nullable; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static java.util.Collections.singleton; import static org.apache.ignite.internal.processors.query.calcite.sql.stat.IgniteSqlStatisticsAnalyzeOptionEnum.DISTINCT; import static org.apache.ignite.internal.processors.query.calcite.sql.stat.IgniteSqlStatisticsAnalyzeOptionEnum.MAX_CHANGED_PARTITION_ROWS_PERCENT; @@ -72,12 +71,12 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test suite to verify parsing of the custom (DDL and others) command. */ -public class SqlCustomParserTest extends GridCommonAbstractTest { +public class SqlCustomParserTest extends GridCommonAbstractWrapperTest { /** * Very simple case where only table name and a few columns are presented. */ diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlReservedWordsTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlReservedWordsTest.java index 4137028bf7976..daaeb50f91e45 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlReservedWordsTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlReservedWordsTest.java @@ -22,14 +22,14 @@ import java.util.Set; import java.util.TreeSet; import org.apache.calcite.sql.parser.SqlAbstractParserImpl; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.processors.query.calcite.sql.generated.IgniteSqlParserImpl; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test reserved keywords. */ -public class SqlReservedWordsTest extends GridCommonAbstractTest { +public class SqlReservedWordsTest extends GridCommonAbstractWrapperTest { /** List of keywords reserved in Ignite SQL. */ private static final Set RESERVED_WORDS = new HashSet<>(Arrays.asList( "ALL", // UNION ALL diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlSelectForUpdateParserTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlSelectForUpdateParserTest.java index 9ddf12ab27771..2d94f80ecea50 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlSelectForUpdateParserTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlSelectForUpdateParserTest.java @@ -27,7 +27,7 @@ import org.apache.ignite.internal.processors.query.calcite.sql.generated.IgniteSqlParserImpl; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/thin/MultiLineQueryTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/thin/MultiLineQueryTest.java index 5af3d58e7fc2a..145324f6b8e60 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/thin/MultiLineQueryTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/thin/MultiLineQueryTest.java @@ -16,6 +16,7 @@ */ package org.apache.ignite.internal.processors.query.calcite.thin; +import java.util.Collection; import java.util.List; import org.apache.ignite.IgniteException; import org.apache.ignite.Ignition; @@ -26,19 +27,22 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** * Tests proper exception is thrown when multiline expressions are executed on thin client on both engines. */ -@RunWith(Parameterized.class) -public class MultiLineQueryTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "engine={0}") +@MethodSource("parameters") +public class MultiLineQueryTest extends GridCommonAbstractWrapperTest { /** */ private static final String H2_ENGINE = IndexingQueryEngineConfiguration.ENGINE_NAME; @@ -49,13 +53,15 @@ public class MultiLineQueryTest extends GridCommonAbstractTest { private IgniteClient cli; /** */ - @Parameterized.Parameter + @Parameter public String queryEngine; /** */ - @Parameterized.Parameters(name = "engine={0}") - public static List parameters() { - return F.asList(H2_ENGINE, CALCITE_ENGINE); + private static Collection parameters() { + return List.of( + Arguments.of(H2_ENGINE), + Arguments.of(CALCITE_ENGINE) + ); } /** {@inheritDoc} */ @@ -69,6 +75,7 @@ public static List parameters() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -80,6 +87,7 @@ public static List parameters() { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { if (cli != null) { cli.close(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/AbstractQueryTransactionIsolationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/AbstractQueryTransactionIsolationTest.java new file mode 100644 index 0000000000000..8a833f5c7be81 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/AbstractQueryTransactionIsolationTest.java @@ -0,0 +1,707 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.tx; + +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteException; +import org.apache.ignite.Ignition; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.QueryIndex; +import org.apache.ignite.client.ClientTransaction; +import org.apache.ignite.client.Config; +import org.apache.ignite.client.IgniteClient; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.odbc.ClientMessage; +import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.query.QueryUtils; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; +import org.apache.ignite.internal.util.lang.RunnableX; +import org.apache.ignite.internal.util.nio.GridNioServer; +import org.apache.ignite.internal.util.nio.GridNioSession; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; + +import static org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.CONN_CTX_META_KEY; +import static org.apache.ignite.internal.processors.tx.AbstractQueryTransactionIsolationTest.ModifyApi.CACHE; +import static org.apache.ignite.internal.processors.tx.AbstractQueryTransactionIsolationTest.ModifyApi.ENTRY_PROCESSOR; +import static org.apache.ignite.internal.processors.tx.AbstractQueryTransactionIsolationTest.ModifyApi.QUERY; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; + +/** Copy paste from code module with removed legacy junit stuff. */ +public abstract class AbstractQueryTransactionIsolationTest extends GridCommonAbstractWrapperTest { + /** */ + public static final String USERS = "USERS"; + + /** */ + public static final int TX_TIMEOUT = 60_000; + + /** */ + public static final int TX_SIZE = 10; + + /** */ + public static final User JOHN = new User(1, 0, "John Connor"); + + /** */ + public static final User SARAH = new User(2, 0, "Sarah Connor"); + + /** */ + public static final User KYLE = new User(3, 0, "Kyle Reese"); + + /** */ + @Parameter(0) + public int gridCnt; + + /** */ + @Parameter(1) + public int backups; + + /** */ + @Parameter(2) + public boolean partitionAwareness; + + /** */ + @Parameter(3) + public CacheMode mode; + + /** */ + @Parameter(4) + public ExecutorType type; + + /** */ + @Parameter(5) + public ModifyApi modify; + + /** */ + @Parameter(6) + public boolean commit; + + /** */ + @Parameter(7) + public boolean multi; + + /** */ + @Parameter(8) + public TransactionConcurrency txConcurrency; + + /** */ + protected static IgniteEx srv; + + /** */ + protected static IgniteEx cli; + + /** */ + protected static IgniteClient thinCli; + + /** */ + protected static ClientConfiguration thinCliCfg; + + /** */ + private final TransactionIsolation txIsolation = READ_COMMITTED; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.getTransactionConfiguration().setTxAwareQueriesEnabled(true); + + return cfg; + } + + /** */ + private void startAllGrids() throws Exception { + srv = startGrids(gridCnt); + cli = startClientGrid("client"); + } + + /** */ + private void startThinClient() { + thinCliCfg = new ClientConfiguration() + .setAddresses(Config.SERVER) + .setPartitionAwarenessEnabled(partitionAwareness); + thinCli = Ignition.startClient(thinCliCfg); + } + + /** {@inheritDoc} */ + @AfterAll + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + if (gridCnt != Ignition.allGrids().size() - 1) { + stopAllGrids(); + + startAllGrids(); + + startThinClient(); + + createCaches(); + } + + if (partitionAwareness != thinCliCfg.isPartitionAwarenessEnabled()) + startThinClient(); + + boolean recreate = cli.cacheNames().stream() + .map(name -> cli.cache(name).getConfiguration(CacheConfiguration.class)) + .filter(ccfg -> ccfg.getCacheMode() == CacheMode.PARTITIONED) + .anyMatch(ccfg -> backups != ccfg.getBackups()); + + if (recreate) { + cli.cacheNames().forEach(cli::destroyCache); + + createCaches(); + } + + cli.cacheNames().forEach(name -> cli.cache(name).removeAll()); + + insert(F.t(1, JOHN)); + + assertEquals(gridCnt + 1, Ignition.allGrids().size()); + assertEquals(partitionAwareness, thinCliCfg.isPartitionAwarenessEnabled()); + cli.cacheNames().stream() + .map(name -> cli.cache(name).getConfiguration(CacheConfiguration.class)) + .filter(ccfg -> ccfg.getCacheMode() == CacheMode.PARTITIONED) + .forEach(ccfg -> assertEquals(ccfg.getName(), backups, ccfg.getBackups())); + } + + /** {@inheritDoc} */ + @AfterEach + @Override protected void afterTest() throws Exception { + for (int i = 0; i < gridCnt + 1; i++) { + IgniteEx srv = i == gridCnt ? cli : grid(i); + + assertTrue(srv.context().cache().context().tm().activeTransactions().isEmpty()); + + GridNioServer nioSrv = GridTestUtils.getFieldValue(srv.context().clientListener(), "srv"); + + for (GridNioSession ses : nioSrv.sessions()) { + Object meta = ses.meta(CONN_CTX_META_KEY); + + if (meta instanceof ClientConnectionContext) + assertTrue(GridTestUtils.>getFieldValue(meta, "txs").isEmpty()); + else if (meta instanceof JdbcConnectionContext) + assertNull(GridTestUtils.getFieldValue(meta, "txCtx")); + else if (meta != null) + throw new IllegalStateException("Unknown context"); + } + } + } + + /** */ + @Test + public void testInsert() { + ensureModeSupported(); + + Runnable checkBefore = () -> { + for (int i = 4; i <= (multi ? 6 : 4); i++) { + if (type != ExecutorType.THIN_JDBC) + assertNull(CACHE.name(), select(i, CACHE)); + assertNull(QUERY.name(), select(i, QUERY)); + } + }; + + Runnable checkAfter = () -> { + for (int i = 4; i <= (multi ? 6 : 4); i++) { + if (type != ExecutorType.THIN_JDBC) + assertEquals(CACHE.name(), JOHN, select(i, CACHE)); + assertEquals(QUERY.name(), JOHN, select(i, QUERY)); + } + }; + + checkBefore.run(); + + insideTx(() -> { + checkBefore.run(); + + if (multi) + insert(F.t(4, JOHN), F.t(5, JOHN), F.t(6, JOHN)); + else + insert(F.t(4, JOHN)); + + if (modify == QUERY) { + GridTestUtils.assertThrows( + log, + () -> doInsert(false, F.t(4, JOHN)), + IgniteException.class, + "Failed to INSERT some keys because they are already in cache" + ); + } + + checkAfter.run(); + }, commit); + + if (commit) + checkAfter.run(); + else + checkBefore.run(); + } + + /** */ + @Test + public void testUpdate() { + ensureModeSupported(); + + if (multi) + insert(F.t(2, JOHN), F.t(3, JOHN)); + + Runnable checkBefore = () -> { + for (int i = 1; i <= (multi ? 3 : 1); i++) { + if (type != ExecutorType.THIN_JDBC) + assertEquals(JOHN, select(i, CACHE)); + assertEquals(JOHN, select(i, QUERY)); + } + }; + + Runnable checkAfter = () -> { + for (int i = 1; i <= (multi ? 3 : 1); i++) { + if (type != ExecutorType.THIN_JDBC) + assertEquals(KYLE, select(i, CACHE)); + assertEquals(KYLE, select(i, QUERY)); + } + }; + + checkBefore.run(); + + insideTx(() -> { + checkBefore.run(); + + if (multi) + update(F.t(1, SARAH), F.t(2, SARAH), F.t(3, SARAH)); + else + update(F.t(1, SARAH)); + + for (int i = 1; i <= (multi ? 3 : 1); i++) { + if (type != ExecutorType.THIN_JDBC) + assertEquals(SARAH, select(i, CACHE)); + assertEquals(SARAH, select(i, QUERY)); + } + + if (multi) + update(F.t(1, KYLE), F.t(2, KYLE), F.t(3, KYLE)); + else + update(F.t(1, KYLE)); + + checkAfter.run(); + }, commit); + + if (commit) + checkAfter.run(); + else + checkBefore.run(); + } + + /** */ + @Test + public void testDelete() { + ensureModeSupported(); + + if (multi) + insert(F.t(2, JOHN), F.t(3, JOHN)); + + Runnable checkBefore = () -> { + for (int i = 1; i <= (multi ? 3 : 1); i++) { + if (type != ExecutorType.THIN_JDBC) + assertEquals(JOHN, select(i, CACHE)); + assertEquals(JOHN, select(i, QUERY)); + } + }; + + Runnable checkAfter = () -> { + for (int i = 1; i <= (multi ? 3 : 1); i++) { + if (type != ExecutorType.THIN_JDBC) + assertNull(select(i, CACHE)); + assertNull(select(i, QUERY)); + } + }; + + checkBefore.run(); + + insideTx(() -> { + checkBefore.run(); + + if (multi) + delete(1, 2, 3); + else + delete(1); + + checkAfter.run(); + }, commit); + + if (commit) + checkAfter.run(); + else + checkBefore.run(); + } + + /** */ + protected void createCaches() { + cli.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(mode) + .setBackups(backups)); + + for (CacheMode mode : CacheMode.values()) { + String users = tableName(USERS, mode); + + LinkedHashMap userFlds = new LinkedHashMap<>(); + + userFlds.put("id", Integer.class.getName()); + userFlds.put("userId", Integer.class.getName()); + userFlds.put("departmentId", Integer.class.getName()); + userFlds.put("fio", String.class.getName()); + + cli.createCache(new CacheConfiguration<>() + .setName(users) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(mode) + .setBackups(backups) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setSqlSchema(QueryUtils.DFLT_SCHEMA) + .setQueryEntities(Collections.singleton(new QueryEntity() + .setTableName(users) + .setKeyType(Integer.class.getName()) + .setValueType(User.class.getName()) + .setKeyFieldName("id") + .setFields(userFlds) + .setIndexes(Arrays.asList( + new QueryIndex() + .setName("IDX_FIO_" + users) + .setFieldNames(Collections.singleton("fio"), true).setInlineSize(Character.BYTES * 20), + new QueryIndex() + .setName("IDX_USERID_" + users) + .setFieldNames(Collections.singleton("userId"), true) + ))))); + } + } + + /** */ + protected void insideTx(RunnableX test, boolean commit) { + if (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) { + try (ClientTransaction tx = thinCli.transactions().txStart(txConcurrency, txIsolation, TX_TIMEOUT)) { + for (int i = 0; i < 3; i++) + thinCli.cache(DEFAULT_CACHE_NAME).put(i, i); + + test.run(); + + if (commit) { + for (int i = 0; i < 3; i++) + thinCli.cache(DEFAULT_CACHE_NAME).remove(i, i); + + tx.commit(); + } + else + tx.rollback(); + } + } + else if (type == ExecutorType.SERVER || type == ExecutorType.CLIENT) { + Ignite initiator = node(); + + assertNotNull(initiator); + + try (Transaction tx = initiator.transactions().txStart(txConcurrency, txIsolation, TX_TIMEOUT, TX_SIZE)) { + for (int i = 0; i < 3; i++) + initiator.cache(DEFAULT_CACHE_NAME).put(i, i); + + test.run(); + + if (commit) { + for (int i = 0; i < 3; i++) + initiator.cache(DEFAULT_CACHE_NAME).remove(i, i); + + tx.commit(); + } + else + tx.rollback(); + } + } + else + fail("Unknown executor type: " + type); + } + + /** */ + protected User select(Integer id, ModifyApi api) { + if (api == CACHE) + return (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + ? (User)thinCli.cache(users()).get(id) + : (User)node().cache(users()).get(id); + + fail("Unknown select: " + api); + + return null; + } + + /** */ + protected void insert(IgniteBiTuple... entries) { + doInsert(false, entries); + } + + /** */ + protected void doInsert(boolean update, IgniteBiTuple... entries) { + if (modify == CACHE) { + if (multi) { + Map data = Arrays.stream(entries).collect(Collectors.toMap(IgniteBiTuple::get1, IgniteBiTuple::get2)); + + if (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + thinCli.cache(users()).putAll(data); + else + node().cache(users()).putAll(data); + } + else { + for (IgniteBiTuple data : entries) { + if (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + thinCli.cache(users()).put(data.get1(), data.get2()); + else + node().cache(users()).put(data.get1(), data.get2()); + } + } + } + else if (modify == ENTRY_PROCESSOR) { + if (multi) { + Set keys = Arrays.stream(entries).map(IgniteBiTuple::get1).collect(Collectors.toSet()); + Map data = Arrays.stream(entries).collect(Collectors.toMap(IgniteBiTuple::get1, IgniteBiTuple::get2)); + + if (type == ExecutorType.THIN_VIA_QUERY || type == ExecutorType.THIN_VIA_CACHE_API) + thinCli.cache(users()).invokeAll(keys, new UpdateEntryProcessor<>(update), data); + else + node().cache(users()).invokeAll(keys, new UpdateEntryProcessor<>(update), data); + } + else { + for (IgniteBiTuple data : entries) { + if (type == ExecutorType.THIN_VIA_QUERY || type == ExecutorType.THIN_VIA_CACHE_API) + thinCli.cache(users()).invoke(data.get1(), new UpdateEntryProcessor<>(update), data.get2()); + else + node().cache(users()).invoke(data.get1(), new UpdateEntryProcessor<>(update), data.get2()); + } + } + } + else + fail("Unknown insert: " + modify); + } + + /** */ + protected void update(IgniteBiTuple...entries) { + if (modify == CACHE || modify == ENTRY_PROCESSOR) + doInsert(true, entries); + else + fail("Unknown update: " + modify); + } + + /** */ + protected void delete(int... keys) { + if (modify == CACHE) { + if (multi) { + Set toRemove = Arrays.stream(keys).boxed().collect(Collectors.toSet()); + + if (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + thinCli.cache(users()).removeAll(toRemove); + else + node().cache(users()).removeAll(toRemove); + } + else { + for (int id : keys) { + if (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + thinCli.cache(users()).remove(id); + else + node().cache(users()).remove(id); + } + } + } + else if (modify == ENTRY_PROCESSOR) { + if (multi) { + Set toRemove = Arrays.stream(keys).boxed().collect(Collectors.toSet()); + + if (type == ExecutorType.THIN_VIA_QUERY || type == ExecutorType.THIN_VIA_CACHE_API) + thinCli.cache(users()).invokeAll(toRemove, new RemoveEntryProcessor<>()); + else + node().cache(users()).invokeAll(toRemove, new RemoveEntryProcessor<>()); + } + else { + for (int id : keys) { + if (type == ExecutorType.THIN_VIA_QUERY || type == ExecutorType.THIN_VIA_CACHE_API) + thinCli.cache(users()).invoke(id, new RemoveEntryProcessor<>()); + else + node().cache(users()).invoke(id, new RemoveEntryProcessor<>()); + } + } + } + else + fail("Unknown delete: " + modify); + } + + /** */ + protected IgniteEx node() { + assertTrue(type == ExecutorType.CLIENT || type == ExecutorType.SERVER); + + return type == ExecutorType.CLIENT ? cli : srv; + } + + /** */ + protected String users() { + return tableName(USERS, mode); + } + + /** */ + protected static String tableName(String tbl, CacheMode mode) { + return tbl + "_" + mode; + } + + /** */ + protected void ensureModeSupported() { + // No-op. + } + + /** */ + public enum ExecutorType { + /** */ + SERVER, + + /** */ + CLIENT, + + /** */ + THIN_VIA_CACHE_API, + + /** */ + THIN_VIA_QUERY, + + /** */ + THIN_JDBC + } + + /** */ + public enum ModifyApi { + /** */ + CACHE, + + /** */ + ENTRY_PROCESSOR, + + /** */ + QUERY + } + + /** */ + public static class User { + /** */ + @GridToStringInclude + public final int userId; + + /** */ + @GridToStringInclude + public final int departmentId; + + /** */ + @GridToStringInclude + public final String fio; + + /** */ + public User(int userId, int departmentId, String fio) { + this.userId = userId; + this.departmentId = departmentId; + this.fio = fio; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + User user = (User)o; + return userId == user.userId && departmentId == user.departmentId && Objects.equals(fio, user.fio); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return Objects.hash(userId, departmentId, fio); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(User.class, this); + } + } + + /** */ + public static class RemoveEntryProcessor implements EntryProcessor { + /** {@inheritDoc} */ + @Override public T process(MutableEntry entry, Object... arguments) throws EntryProcessorException { + entry.remove(); + + return null; + } + } + + /** */ + public static class UpdateEntryProcessor implements EntryProcessor { + /** */ + private final boolean update; + + /** */ + public UpdateEntryProcessor() { + this(true); + } + + /** */ + public UpdateEntryProcessor(boolean update) { + this.update = update; + } + + /** {@inheritDoc} */ + @Override public T process(MutableEntry entry, Object... arguments) throws EntryProcessorException { + assertEquals("Expect entry " + (update ? "" : "not") + " exists", update, entry.exists()); + + if (arguments[0] instanceof User) + entry.setValue((V)arguments[0]); + else + entry.setValue((V)((Map)arguments[0]).get((Integer)entry.getKey())); + + return null; + } + } +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsIsolationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsIsolationTest.java index fa6fe9603c56c..ea0d790e565ec 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsIsolationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsIsolationTest.java @@ -52,24 +52,30 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.query.AbstractQueryTransactionIsolationTest; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.lang.RunnableX; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.transactions.TransactionConcurrency; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.lang.String.format; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.internal.jdbc.thin.ConnectionPropertiesImpl.PROP_PREFIX; -import static org.apache.ignite.internal.processors.cache.query.AbstractQueryTransactionIsolationTest.ModifyApi.CACHE; -import static org.apache.ignite.internal.processors.cache.query.AbstractQueryTransactionIsolationTest.ModifyApi.QUERY; +import static org.apache.ignite.internal.processors.tx.AbstractQueryTransactionIsolationTest.ModifyApi.CACHE; +import static org.apache.ignite.internal.processors.tx.AbstractQueryTransactionIsolationTest.ModifyApi.QUERY; import static org.apache.ignite.testframework.GridTestUtils.runAsync; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; /** */ +@ParameterizedClass(name = "gridCnt={0}, backups={1}, partitionAwareness={2}, mode={3}, execType={4}, " + + "modify={5}, commit={6}, multi={7}, txConcurrency={8}") +@MethodSource("parameters") public class SqlTransactionsIsolationTest extends AbstractQueryTransactionIsolationTest { /** */ public static final String DEPARTMENTS = "DEPARTMENTS"; @@ -78,32 +84,14 @@ public class SqlTransactionsIsolationTest extends AbstractQueryTransactionIsolat public static final String TBL = "TBL"; /** */ - private ThreadLocal jdbcThinConn = ThreadLocal.withInitial(() -> { - try { - String addrs = partitionAwareness - ? Ignition.allGrids().stream() - .filter(n -> !n.configuration().isClientMode()) - .map(n -> "127.0.0.1:" + ((IgniteEx)n).context().clientListener().port()) - .collect(Collectors.joining(",")) - : "127.0.0.1:10800"; - - return DriverManager.getConnection("jdbc:ignite:thin://" + addrs + "?" - + PROP_PREFIX + "partitionAwareness=" + partitionAwareness + "&" - + PROP_PREFIX + "transactionConcurrency=" + txConcurrency); - } - catch (SQLException e) { - throw new RuntimeException(e); - } - }); + private ThreadLocal jdbcThinConn; /** */ private final Map> partsToKeys = new HashMap<>(); /** @return Test parameters. */ - @Parameterized.Parameters( - name = "gridCnt={0},backups={1},partitionAwareness={2},mode={3},execType={4},modify={5},commit={6},multi={7},txConcurrency={8}") - public static Collection parameters() { - List params = new ArrayList<>(); + private static Collection parameters() { + Collection params = new ArrayList<>(); for (int gridCnt : new int[]{1, 3}) { int[] backups = gridCnt > 1 @@ -133,7 +121,7 @@ public static Collection parameters() { } for (ExecutorType execType : nodeExecTypes) { - params.add(new Object[]{ + params.add(Arguments.of( gridCnt, backup, false, //partitionAwareness @@ -143,12 +131,12 @@ public static Collection parameters() { commit, mutli, txConcurrency - }); + )); } for (ExecutorType execType : thinExecTypes) { for (boolean partitionAwareness : new boolean[]{false, true}) { - params.add(new Object[]{ + params.add(Arguments.of( gridCnt, backup, partitionAwareness, @@ -158,7 +146,7 @@ public static Collection parameters() { commit, mutli, txConcurrency - }); + )); } } } @@ -222,12 +210,39 @@ public static Collection parameters() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { + partsToKeys.clear(); + + jdbcThinConn = ThreadLocal.withInitial(() -> { + try { + String addrs = partitionAwareness + ? Ignition.allGrids().stream() + .filter(n -> !n.configuration().isClientMode()) + .map(n -> "127.0.0.1:" + ((IgniteEx)n).context().clientListener().port()) + .collect(Collectors.joining(",")) + : "127.0.0.1:10800"; + + return DriverManager.getConnection("jdbc:ignite:thin://" + addrs + "?" + + PROP_PREFIX + "partitionAwareness=" + partitionAwareness + "&" + + PROP_PREFIX + "transactionConcurrency=" + txConcurrency); + } + catch (SQLException e) { + throw new RuntimeException(e); + } + }); + super.beforeTest(); assertEquals(mode, cli.cache(tbl()).getConfiguration(CacheConfiguration.class).getCacheMode()); } + /** {@inheritDoc} */ + @BeforeAll + @Override protected void beforeTestsStarted() throws Exception { + // No-op. + } + /** */ @Test public void testIndexScan() { @@ -763,9 +778,7 @@ else if (type == ExecutorType.THIN_VIA_CACHE_API) else if (type == ExecutorType.THIN_JDBC) { assertTrue("Partition filter not supported", F.isEmpty(parts)); - try { - PreparedStatement stmt = jdbcThinConn.get().prepareStatement(sqlText); - + try (PreparedStatement stmt = jdbcThinConn.get().prepareStatement(sqlText)) { if (!F.isEmpty(args)) { for (int i = 0; i < args.length; i++) stmt.setObject(i + 1, args[i]); @@ -823,8 +836,8 @@ private String tbl() { /** {@inheritDoc} */ @Override protected void ensureModeSupported() { assumeFalse( - "Thin client doesn't support multiple statements for SQL", - multi && modify == QUERY && (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY) + multi && modify == QUERY && (type == ExecutorType.THIN_VIA_CACHE_API || type == ExecutorType.THIN_VIA_QUERY), + "Thin client doesn't support multiple statements for SQL" ); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsSavepointTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsSavepointTest.java index 195d538c3e94f..9a7f96628f145 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsSavepointTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsSavepointTest.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.tx; -import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; @@ -32,12 +32,13 @@ import org.apache.ignite.internal.processors.query.calcite.util.Commons; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal.SAVEPOINTS_EXPLICIT_TX_ONLY; import static org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTransactionalTest.SqlTransactionMode.ALL; @@ -46,7 +47,8 @@ import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** Tests SQL savepoint commands executed by Calcite. */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "{0}") +@MethodSource("parameters") public class SqlTransactionsSavepointTest extends AbstractBasicIntegrationTest { /** */ private static final String TBL = "SAVEPOINT_TEST_TABLE"; @@ -56,12 +58,11 @@ public class SqlTransactionsSavepointTest extends AbstractBasicIntegrationTest { public TransactionConcurrency txConcurrency; /** */ - @Parameters(name = "{0}") - public static Iterable testData() { - return Arrays.asList(new Object[][] { - {PESSIMISTIC}, - {OPTIMISTIC} - }); + private static Stream parameters() { + return Stream.of( + Arguments.arguments(PESSIMISTIC), + Arguments.arguments(OPTIMISTIC) + ); } /** {@inheritDoc} */ @@ -74,6 +75,7 @@ public static Iterable testData() { } /** {@inheritDoc} */ + @AfterAll @Override protected void afterTestsStopped() throws Exception { stopAllGrids(); @@ -81,6 +83,7 @@ public static Iterable testData() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsUnsupportedModesTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsUnsupportedModesTest.java index 970afaf456ee0..8df071ccd34e8 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsUnsupportedModesTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsUnsupportedModesTest.java @@ -26,17 +26,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** */ -public class SqlTransactionsUnsupportedModesTest extends GridCommonAbstractTest { +public class SqlTransactionsUnsupportedModesTest extends GridCommonAbstractWrapperTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxThreadLockingTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxThreadLockingTest.java index 6c451ac68db15..7ff07c7c46dca 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxThreadLockingTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxThreadLockingTest.java @@ -33,16 +33,21 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** */ -@RunWith(Parameterized.class) +@ParameterizedClass(name = "qryBlockingExecutor={0}") +@MethodSource("parameters") public class TxThreadLockingTest extends AbstractBasicIntegrationTest { /** */ private static final long TIMEOUT = 10_000L; @@ -57,21 +62,22 @@ public class TxThreadLockingTest extends AbstractBasicIntegrationTest { private static final int MODIFY_BATCH_SIZE = AbstractExecutionTest.MODIFY_BATCH_SIZE; /** Use query blocking executor. */ - @Parameterized.Parameter(0) + @Parameter(0) public boolean qryBlockingExecutor; /** */ - @Parameterized.Parameters(name = "qryBlockingExecutor={0}") - public static Collection parameters() { - return List.of(false, true); + private static Collection parameters() { + return List.of(Arguments.of(false), Arguments.of(true)); } /** {@inheritDoc} */ + @BeforeAll @Override protected void beforeTestsStarted() throws Exception { // No-op. } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { System.setProperty(IGNITE_CALCITE_USE_QUERY_BLOCKING_TASK_EXECUTOR, String.valueOf(qryBlockingExecutor)); diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxWithExceptionalInterceptorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxWithExceptionalInterceptorTest.java index c26425ec90661..724a789a23c1d 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxWithExceptionalInterceptorTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/TxWithExceptionalInterceptorTest.java @@ -43,33 +43,36 @@ import org.apache.ignite.internal.processors.cache.CacheLazyEntry; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.MapCacheStoreStrategy; +import org.apache.ignite.internal.processors.query.calcite.GridCommonAbstractWrapperTest; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** Check per node data consistency after exceptionally interceptor method call. */ -@RunWith(Parameterized.class) -public class TxWithExceptionalInterceptorTest extends GridCommonAbstractTest { +@ParameterizedClass(name = "txCoordRole={0}, persistence={1}, writeThrough={2}") +@MethodSource("parameters") +public class TxWithExceptionalInterceptorTest extends GridCommonAbstractWrapperTest { /** Node role. */ - @Parameterized.Parameter(0) + @Parameter(0) public TxCoordNodeRole txCoord; /** Persistence flag. */ - @Parameterized.Parameter(1) + @Parameter(1) public boolean persistence; /** Write through flag. */ - @Parameterized.Parameter(2) + @Parameter(2) public boolean writeThrough; /** */ @@ -94,8 +97,7 @@ public class TxWithExceptionalInterceptorTest extends GridCommonAbstractTest { private static final MapCacheStoreStrategy strategy = new MapCacheStoreStrategy(); /** */ - @Parameterized.Parameters(name = "txCoordRole={0}, persistence={1}, writeThrough={2}") - public static Collection parameters() { + private static Collection parameters() { return GridTestUtils.cartesianProduct( List.of(TxCoordNodeRole.PRIMARY, TxCoordNodeRole.BACKUP, TxCoordNodeRole.COORDINATOR_NO_DATA, TxCoordNodeRole.THICK_CLIENT), List.of(true, false), @@ -104,6 +106,7 @@ public static Collection parameters() { } /** {@inheritDoc} */ + @BeforeEach @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -116,6 +119,7 @@ public static Collection parameters() { } /** {@inheritDoc} */ + @AfterEach @Override protected void afterTest() throws Exception { super.afterTest(); diff --git a/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesExtension.java b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesExtension.java new file mode 100644 index 0000000000000..1f8b3ded51047 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesExtension.java @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.testframework.junit; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * JUnit rule that manages usage of {@link WithSystemProperty} annotations.
Should be used in {@link ExtendWith}. + * + * @see WithSystemProperty + * @see ExtendWith + */ +public class SystemPropertiesExtension implements + BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback { + /** JUnit namespace for the extension. */ + private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(SystemPropertiesExtension.class); + + /** {@inheritDoc} */ + @Override public void beforeAll(ExtensionContext ctx) { + List newProps = new ArrayList<>(); + + for (Class cls = ctx.getRequiredTestClass(); cls != null; cls = cls.getSuperclass()) { + WithSystemProperty[] props = cls.getAnnotationsByType(WithSystemProperty.class); + + if (props.length > 0) { + newProps.addAll(Arrays.asList(props)); + } + } + + if (newProps.isEmpty()) { + return; + } + + // Reverse the collected properties to set properties from the superclass first. This may be important + // if the same property gets overridden in a subclass. + Collections.reverse(newProps); + + List oldProps = replaceProperties(newProps); + + ctx.getStore(NAMESPACE).put(ctx.getUniqueId(), oldProps); + } + + /** {@inheritDoc} */ + @Override public void afterAll(ExtensionContext ctx) { + resetProperties(ctx); + } + + /** {@inheritDoc} */ + @Override public void beforeEach(ExtensionContext ctx) { + WithSystemProperty[] newProps = ctx.getRequiredTestMethod().getAnnotationsByType(WithSystemProperty.class); + + if (newProps.length == 0) { + return; + } + + List oldProps = replaceProperties(Arrays.asList(newProps)); + + ctx.getStore(NAMESPACE).put(ctx.getUniqueId(), oldProps); + } + + /** {@inheritDoc} */ + @Override public void afterEach(ExtensionContext ctx) { + resetProperties(ctx); + } + + /** + * Replaces the system properties with the given properties. + * + * @return List of the previous property values. + */ + private static List replaceProperties(List newProps) { + // List of system properties to set when test is finished. + var oldProps = new ArrayList(newProps.size()); + + for (WithSystemProperty prop : newProps) { + String oldVal = System.setProperty(prop.key(), prop.value()); + + oldProps.add(new Property(prop.key(), oldVal)); + } + + return oldProps; + } + + /** + * Resets the system properties to the pre-test state. + */ + private static void resetProperties(ExtensionContext ctx) { + List oldProps = ctx.getStore(NAMESPACE).remove(ctx.getUniqueId(), List.class); + + if (oldProps == null) { + return; // Nothing to do. + } + + // Bring back the old properties in the reverse order + Collections.reverse(oldProps); + + for (Property prop : oldProps) { + if (prop.val == null) + System.clearProperty(prop.key); + else + System.setProperty(prop.key, prop.val); + } + } + + /** Property. */ + private static class Property { + /** Property key. */ + final String key; + + /** Property value. */ + @Nullable + final String val; + + /** + * Constructor. + * + * @param key Property key. + * @param val Property value. + */ + Property(String key, @Nullable String val) { + this.key = key; + this.val = val; + } + } +} + diff --git a/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesList.java b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesList.java new file mode 100644 index 0000000000000..170f5d7d4e5a8 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/SystemPropertiesList.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.testframework.junit; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * {@link Repeatable} for the {@link WithSystemProperty}.
Not intended for direct usage. Use multiple {@link WithSystemProperty} + * annotation instead. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface SystemPropertiesList { + /** Array of underlying annotations. */ + WithSystemProperty[] value(); +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/WithSystemProperty.java b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/WithSystemProperty.java new file mode 100644 index 0000000000000..0c117acb4a327 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/testframework/junit/WithSystemProperty.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.testframework.junit; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +/** + * Annotation that defines a scope with specific system property configured.
+ *
+ * Might be used on class level or on method level. Multiple annotations might be applied to the same class/method.
+ *
+ * In short, these two approaches are basically equivalent:
+ *
+ * Short: + *
 {@literal @}WithSystemProperty(key = "name", value = "val")
+ * public class SomeTest {
+ * }
+ * Long: + *
  public class SomeTest {
+ *      private static Object oldVal;
+ *
+ *     {@literal @}BeforeClass
+ *      public static void beforeClass() {
+ *          oldVal = System.getProperty("name");
+ *
+ *          System.setProperty("name", "val");
+ *      }
+ *
+ *     {@literal @}AfterClass
+ *      public static void afterClass() {
+ *          if (oldVal == null)
+ *              System.clearProperty("name");
+ *          else
+ *              System.setProperty("name", oldVal);
+ *      }
+ *  }
+ * + *

Same applies to methods with the difference that annotation translates into something like {@link BeforeEach} and {@link AfterEach}. + *

+ *

  public class SomeTest {
+ *     {@literal @}Test
+ *     {@literal @}WithSystemProperty(key = "name", value = "val")
+ *      public void test() {
+ *          // ...
+ *      }
+ *  }
+ * 
+ * is equivalent to: + *
  public class SomeTest {
+ *     {@literal @}Test
+ *      public void test() {
+ *          Object oldVal = System.getProperty("name");
+ *
+ *          try {
+ *              // ...
+ *          }
+ *          finally {
+ *              if (oldVal == null)
+ *                  System.clearProperty("name");
+ *              else
+ *                  System.setProperty("name", oldVal);
+ *          }
+ *      }
+ *  }
+ * 
+ * For class level annotation it applies system properties for the whole class hierarchy (ignoring interfaces, there's no linearization + * implemented). More specific classes have higher priority and set their properties last. It all starts with {@link Object} which, of + * course, is not annotated.
+ *
+ * Test methods do not inherit their annotations from overridden methods of super class.
+ *
+ * If more than one annotation is presented on class/method then they will be applied in the same order as they appear in code. It is + * achieved with the help of {@link Repeatable} feature of Java annotations - {@link SystemPropertiesList} is automatically generated in + * such cases. For that reason it is not recommended using {@link SystemPropertiesList} directly. + * + * @see System#setProperty(String, String) + * @see SystemPropertiesExtension + * @see SystemPropertiesList + */ +@Repeatable(SystemPropertiesList.class) +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface WithSystemProperty { + /** The name of the system property. */ + String key(); + + /** The value of the system property. */ + String value(); +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/ExecutionTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/ExecutionTestSuite.java index 6b01981684987..2c62be0aff780 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/ExecutionTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/ExecutionTestSuite.java @@ -37,14 +37,14 @@ import org.apache.ignite.internal.processors.query.calcite.exec.rel.TimeCalculationExecutionTest; import org.apache.ignite.internal.processors.query.calcite.exec.rel.UncollectExecutionTest; import org.apache.ignite.internal.processors.query.calcite.exec.rel.WindowExecutionTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite execution tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ ExecutionTest.class, ContinuousExecutionTest.class, MergeJoinExecutionTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java index d1417c7d124dc..2de7fb9938346 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.tx.SqlTransactionsIsolationTest; import org.apache.ignite.internal.processors.tx.SqlTransactionsSavepointTest; import org.apache.ignite.internal.processors.tx.SqlTransactionsUnsupportedModesTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ UtilTestSuite.class, ParserCodegenResourcesTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite2.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite2.java index 68002b4563535..abbcf2f185766 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite2.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite2.java @@ -17,14 +17,16 @@ package org.apache.ignite.testsuites; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.apache.ignite.internal.processors.query.calcite.integration.TestSuiteDeclarationArchTest; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ + TestSuiteDeclarationArchTest.class, PlannerTestSuite.class, ExecutionTestSuite.class, JdbcTestSuite.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite3.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite3.java index 4d9074ecfc8cc..3832c3469f115 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite3.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite3.java @@ -17,14 +17,15 @@ package org.apache.ignite.testsuites; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + /** * Calcite tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ IntegrationTestSuite.class }) public class IgniteCalciteTestSuite3 { diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java index c9605a431cd29..833729b5e0b60 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java @@ -104,14 +104,14 @@ import org.apache.ignite.internal.processors.query.calcite.thin.MultiLineQueryTest; import org.apache.ignite.internal.processors.tx.TxThreadLockingTest; import org.apache.ignite.internal.processors.tx.TxWithExceptionalInterceptorTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ OrToUnionRuleTest.class, ProjectScanMergeRuleTest.class, CalciteQueryProcessorTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java index b69f3cf83470d..2e2a21ff77008 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java @@ -25,14 +25,14 @@ import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcSetClientInfoTest; import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcThinConnectionSavepointTest; import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcThinTransactionalSelfTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite JDBC tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ JdbcQueryTest.class, JdbcCrossEngineTest.class, JdbcThinConnectionSavepointTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/PlannerTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/PlannerTestSuite.java index bac3237c6360e..66c7335d27073 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/PlannerTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/PlannerTestSuite.java @@ -55,14 +55,14 @@ import org.apache.ignite.internal.processors.query.calcite.planner.WindowPlannerTest; import org.apache.ignite.internal.processors.query.calcite.planner.hints.HintsTestSuite; import org.apache.ignite.internal.processors.query.calcite.planner.tpc.TpchQueryPlannerTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ PlanExecutionTest.class, PlanSplitterTest.class, CorrelatedNestedLoopJoinPlannerTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/ScriptTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/ScriptTestSuite.java index fbed0087a3aeb..de42dee731541 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/ScriptTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/ScriptTestSuite.java @@ -17,9 +17,35 @@ package org.apache.ignite.testsuites; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Pattern; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.IgnitionEx; +import org.apache.ignite.internal.processors.query.QueryEngine; import org.apache.ignite.internal.processors.query.calcite.logical.ScriptRunnerTestsEnvironment; -import org.apache.ignite.internal.processors.query.calcite.logical.ScriptTestRunner; -import org.junit.runner.RunWith; +import org.apache.ignite.internal.processors.query.calcite.logical.SqlScriptRunner; +import org.apache.ignite.internal.processors.query.calcite.util.Commons; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; +import org.apache.ignite.thread.IgniteThread; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.TestFactory; /** * Test suite to run SQL test scripts. @@ -71,7 +97,253 @@ * @see Extended format documentation. * */ -@RunWith(ScriptTestRunner.class) @ScriptRunnerTestsEnvironment(scriptsRoot = "modules/calcite/src/test/sql", timeout = 180000) public class ScriptTestSuite { + /** Filesystem. */ + private static final FileSystem FS = FileSystems.getDefault(); + + /** Suffix of the scripts that are reported as ignored. */ + private static final String IGNORED_SUFFIX = ".test_ignore"; + + /** Shared finder. */ + private static final TcpDiscoveryVmIpFinder sharedFinder = new TcpDiscoveryVmIpFinder().setShared(true); + + /** */ + private static IgniteLogger log; + + static { + try { + log = new GridTestLog4jLogger(U.resolveIgnitePath("modules/core/src/test/config/log4j2-test.xml")); + } + catch (Exception e) { + e.printStackTrace(System.err); + + log = null; + + assert false : "Cannot init logger"; + } + } + + /** Scripts root directory. */ + private final Path scriptsRoot; + + /** Regex to filter test path to run only specified tests. */ + private final Pattern testRegex; + + /** Nodes count. */ + private final int nodes; + + /** Restart cluster for each test group. */ + private final boolean restartCluster; + + /** Test script timeout. */ + private final long timeout; + + /** Directory (test group) of the last executed script. */ + private Path lastTestDir; + + /** */ + public ScriptTestSuite() { + ScriptRunnerTestsEnvironment env = ScriptTestSuite.class.getAnnotation(ScriptRunnerTestsEnvironment.class); + + assert !F.isEmpty(env.scriptsRoot()); + + nodes = env.nodes(); + scriptsRoot = FS.getPath(U.resolveIgnitePath(env.scriptsRoot()).getPath()); + testRegex = F.isEmpty(env.regex()) ? null : Pattern.compile(env.regex()); + restartCluster = env.restart(); + timeout = env.timeout(); + } + + /** + * Generates dynamic tests for each script file in the configured directory. + * + * @return Stream of dynamic tests. + * @throws Exception If failed to walk the script directory. + */ + @TestFactory + public List generateTests() throws Exception { + // Start cluster if not already started + if (F.isEmpty(Ignition.allGrids())) { + startCluster(); + } + + return Files.walk(scriptsRoot) + .sorted() + .filter(p -> !p.equals(scriptsRoot)) + .filter(p -> !Files.isDirectory(p)) + .filter(p -> testRegex == null || testRegex.matcher(p.toString()).find()) + .filter(p -> { + String fileName = p.getFileName().toString(); + + return testRegex != null || fileName.endsWith(".test") || fileName.endsWith(".test_slow") + || fileName.endsWith(IGNORED_SUFFIX); + }) + .map(p -> { + String dirName; + if (p.getNameCount() - 1 > scriptsRoot.getNameCount()) + dirName = p.subpath(scriptsRoot.getNameCount(), p.getNameCount() - 1).toString(); + else + dirName = scriptsRoot.subpath(scriptsRoot.getNameCount() - 1, scriptsRoot.getNameCount()).toString(); + + String fileName = p.getFileName().toString(); + + // Ignored scripts are reported as skipped (only when no regex filter is set). + if (testRegex == null && fileName.endsWith(IGNORED_SUFFIX)) { + return DynamicTest.dynamicTest(dirName + "/" + fileName, + () -> Assumptions.abort("Script is ignored: " + dirName + "/" + fileName)); + } + + return DynamicTest.dynamicTest(dirName + "/" + fileName, () -> { + runSingleTest(p, dirName, fileName); + }); + }) + .toList(); + } + + /** */ + @AfterAll + public static void tearDown() { + IgnitionEx.stopAll(true, null); + } + + /** + * Runs a single test. + * + * @param test Test file path. + * @param dirName Directory name. + * @param fileName File name. + * @throws Exception If test fails. + */ + private void runSingleTest(Path test, String dirName, String fileName) { + beforeTest(test.getParent()); + + log.info(">>> Start: " + dirName + "/" + fileName); + + try { + Ignite ign = F.first(Ignition.allGrids()); + + QueryEngine engine = Commons.lookupComponent( + ((IgniteEx)ign).context(), + QueryEngine.class + ); + + SqlScriptRunner scriptTestRunner = new SqlScriptRunner(test, engine, log); + + try { + runScript(scriptTestRunner); + } + catch (Error | RuntimeException e) { + throw e; + } + catch (Throwable e) { + throw new RuntimeException(e); + } + } + finally { + log.info(">>> Finish: " + dirName + "/" + fileName); + } + } + + /** + * Cleanup before test. + * + * @param testDir Directory (test group) of the script to run. + */ + private void beforeTest(Path testDir) { + // Restart cluster only on a test group (directory) boundary. + if (restartCluster && lastTestDir != null && !lastTestDir.equals(testDir) && !F.isEmpty(Ignition.allGrids())) { + log.info(">>> Restart cluster"); + + Ignition.stopAll(false); + } + + lastTestDir = testDir; + + if (F.isEmpty(Ignition.allGrids())) + startCluster(); + else { + Ignite ign = F.first(Ignition.allGrids()); + + for (String cacheName : ign.cacheNames()) + ign.destroyCache(cacheName); + } + } + + /** + * Starts the cluster. + */ + private void startCluster() { + for (int i = 0; i < nodes; ++i) { + Ignition.start( + new IgniteConfiguration() + .setIgniteInstanceName("srv" + i) + .setDiscoverySpi( + new TcpDiscoverySpi() + .setIpFinder(sharedFinder) + ) + .setGridLogger(log) + ); + } + } + + /** + * Runs the script with timeout support. + * + * @param scriptRunner Script runner. + */ + private void runScript(SqlScriptRunner scriptRunner) throws Throwable { + final AtomicReference ex = new AtomicReference<>(); + + Thread runner = new IgniteThread("srv0", "test-runner", new Runnable() { + @Override public void run() { + try { + scriptRunner.run(); + } + catch (Throwable e) { + ex.set(e); + } + } + }); + + runner.start(); + + runner.join(timeout); + + if (runner.isAlive()) { + U.error(log, + "Test has been timed out and will be interrupted"); + + List nodes = IgnitionEx.allGridsx(); + + for (Ignite node : nodes) + ((IgniteKernal)node).dumpDebugInfo(); + + // We dump threads to stdout, because we can loose logs in case + // the build is cancelled on TeamCity. + U.dumpThreads(null); + + U.dumpThreads(log); + + // Try to interrupt runner several times for case when InterruptedException is handled invalid. + for (int i = 0; i < 100 && runner.isAlive(); ++i) { + U.interrupt(runner); + + U.sleep(10); + } + + U.join(runner, log); + + // Restart cluster + Ignition.stopAll(true); + startCluster(); + + throw new TimeoutException("Test has been timed out"); + } + + Throwable t = ex.get(); + + if (t != null) + throw t; + } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java index 527f0240060d6..8d8e0a477702a 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/UtilTestSuite.java @@ -24,14 +24,14 @@ import org.apache.ignite.internal.processors.query.calcite.exec.task.QueryBlockingTaskExecutorTest; import org.apache.ignite.internal.processors.query.calcite.exec.task.QueryTasksQueueTest; import org.apache.ignite.internal.processors.query.calcite.exec.tracker.MemoryTrackerTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Calcite utility classes tests. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ ClosableIteratorsHolderTest.class, MemoryTrackerTest.class, QueryCheckerTest.class, diff --git a/modules/calcite/src/test/resources/junit-platform.properties b/modules/calcite/src/test/resources/junit-platform.properties new file mode 100644 index 0000000000000..84e51f4627393 --- /dev/null +++ b/modules/calcite/src/test/resources/junit-platform.properties @@ -0,0 +1,14 @@ +# Catch-all fallback timeout for all test and lifecycle methods. +junit.jupiter.execution.timeout.default = 5m + +# Specific default timeout for standard @Test methods (overrides the catch-all). +junit.jupiter.execution.timeout.test.method.default = 5m + +# Specific default timeout for lifecycle methods (e.g., @BeforeEach, @AfterAll). +junit.jupiter.execution.timeout.lifecycle.method.default = 60s + +# Dump threads if test runs more than expected. +junit.jupiter.execution.timeout.threaddump.enabled = true + +# With random run GridTestClockTimer can never be initialized. +junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$OrderAnnotation diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index f6e1f1eb6777f..3fe32fe07bee5 100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -685,6 +685,11 @@ private void resolveWorkDirectory() throws Exception { sft.mkdirMarshaller(); } + /** */ + protected static void beforeFirstTest0() { + sharedStaticIpFinder = new TcpDiscoveryVmIpFinder(true); + } + /** */ protected void beforeFirstTest() throws Exception { sharedStaticIpFinder = new TcpDiscoveryVmIpFinder(true); @@ -779,7 +784,7 @@ private void runAfterTest() throws Exception { * @param afterTestFinished Boolean flag used to tell whether {@code afterTest()} finished execution. * @return Scheduled executor used when scheduling. */ - private ScheduledExecutorService scheduleThreadDumpOnAfterTestTimeOut(AtomicBoolean afterTestFinished) { + public ScheduledExecutorService scheduleThreadDumpOnAfterTestTimeOut(AtomicBoolean afterTestFinished) { // Compute class name as string to avoid holding reference to the test class instance in task. String testClsName = getClass().getName(); diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/junit/JUnitTeamcityReporter.java b/modules/tools/src/main/java/org/apache/ignite/tools/junit/JUnitTeamcityReporter.java index 463c41ab4c32d..9ddcc276cf6c0 100644 --- a/modules/tools/src/main/java/org/apache/ignite/tools/junit/JUnitTeamcityReporter.java +++ b/modules/tools/src/main/java/org/apache/ignite/tools/junit/JUnitTeamcityReporter.java @@ -220,8 +220,12 @@ private String fileName() { return "test-" + prevSuite + prevFlush + ".xml"; } - /** */ - private String escapeForTeamcity(String msg) { + /** + * @param msg Message. + * + * @return Escaped string. + */ + public static String escapeForTeamcity(String msg) { return (msg == null ? "null" : msg) .replace("|", "||") .replace("\r", "|r") diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/CheckAllTestsInSuites.java b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/CheckAllTestsInSuites.java index 6d6351b3bf64b..9398ec287b86f 100644 --- a/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/CheckAllTestsInSuites.java +++ b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/testsuites/CheckAllTestsInSuites.java @@ -113,6 +113,13 @@ private void processSuite(Description suite, Set suitedClasses, } } + /** Calcite module tests inherited from legacy junit4 related classes. */ + private static final Set CALCITE_TESTS = Set.of( + "org.apache.ignite.internal.processors.query.calcite.IndexWithSameNameCalciteTest", + "org.apache.ignite.internal.processors.cache.DdlTransactionCalciteSelfTest", + "org.apache.ignite.internal.processors.query.calcite.message.CalciteCommunicationMessageSerializationTest" + ); + /** * Check whether class is a test class or a suite. * @@ -121,11 +128,13 @@ private void processSuite(Description suite, Set suitedClasses, * Exclusion of the rule is Parameterized.class, so classes are marked with it are test classes. */ private boolean isTestClass(Description desc) { + if (CALCITE_TESTS.contains(desc.getDisplayName())) + return false; + RunWith runWith = desc.getAnnotation(RunWith.class); return runWith == null || runWith.value().equals(Parameterized.class) - || !(Suite.class.isAssignableFrom(runWith.value()) - || "org.scalatest.Suites".equals(desc.getTestClass().getSuperclass().getName())); + || !(Suite.class.isAssignableFrom(runWith.value())); } } diff --git a/parent/pom.xml b/parent/pom.xml index b50c31f2c48cb..ae8a698ea5dde 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -968,12 +968,15 @@ **/*.cmd **/*.ps1 **/*.json + **/apache-2.0.txt **/.dockerignore modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExpectedOutput/*.txt packaging/** src/test/sql/** + + src/test/resources/junit-platform.properties docs/_site/** docs/assets/images/**