Skip to content
Open

junit5 #13579

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions modules/calcite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,26 @@
<commons.math.version>3.6.1</commons.math.version>
<commons.text.version>1.15.0</commons.text.version>
<io.trino.tpch.version>1.2</io.trino.tpch.version>
<hamcrest.version>3.0</hamcrest.version>
<junit.version>6.1.3</junit.version>
<archunit.version>1.5.0</archunit.version>
</properties>

<url>https://ignite.apache.org</url>

<dependencyManagement>
<dependencies>
<!-- Aligns every org.junit.* artifact (including the ones pulled transitively by ArchUnit) to a single version. -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -211,6 +227,12 @@
<artifactId>ignite-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -253,6 +275,70 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>${archunit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- Runs the tests that still inherit JUnit 4 test methods from ignite-core test classes. -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino.tpch</groupId>
<artifactId>tpch</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,45 @@
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";

/** */
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<Object[]> parameters() {
List<Object[]> params = new ArrayList<>();
@MethodSource("parameters")
private static List<Arguments> parameters() {
List<Arguments> 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;
Expand All @@ -83,6 +88,7 @@ public static List<Object[]> parameters() {
}

/** {@inheritDoc} */
@BeforeEach
@Override protected void beforeTest() throws Exception {
ign = startGrids(3);

Expand All @@ -93,6 +99,7 @@ public static List<Object[]> parameters() {
}

/** {@inheritDoc} */
@AfterEach
@Override protected void afterTest() {
stopAllGrids();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -96,13 +100,15 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest {
}

/** {@inheritDoc} */
@BeforeAll
@Override protected void beforeTestsStarted() throws Exception {
startGrids(5);

client = startClientGrid();
}

/** {@inheritDoc} */
@AfterEach
@Override protected void afterTest() throws InterruptedException {
for (Ignite ign : G.allGrids()) {
for (String cacheName : ign.cacheNames())
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Integer, String> c = grid(0).cache("TEST");
Expand All @@ -57,6 +58,7 @@ public class CancelTest extends GridCommonAbstractTest {
}

/** {@inheritDoc} */
@AfterEach
@Override protected void afterTest() throws Exception {
stopAllGrids();

Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Loading
Loading