This is an automated email from the ASF dual-hosted git repository. ilyak pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 00217f7 IGNITE-12934 Introduce JUnit/Surefire integration for runtime TC test reporting. 00217f7 is described below commit 00217f7f9f51a3d0f18aad355e1aa866f0781c2b Author: Ilya Kasnacheev <ilya.kasnach...@gmail.com> AuthorDate: Thu Jun 25 14:26:48 2020 +0300 IGNITE-12934 Introduce JUnit/Surefire integration for runtime TC test reporting. Also bump JUnit to 4.12, Surefire plugin to M4. Fix some dependencies between modules. Report tests in batches via XML reports to avoid system.out clobbering. --- examples/pom.xml | 13 + modules/aop/pom.xml | 7 + .../ignite/testsuites/IgniteAopSelfTestSuite.java | 3 + modules/aws/pom.xml | 7 + modules/camel/pom.xml | 7 + modules/cassandra/serializers/pom.xml | 7 + modules/cassandra/store/pom.xml | 7 + .../store/IgniteCassandraStoreTestSuite.java | 3 + modules/clients/pom.xml | 7 + modules/cloud/pom.xml | 7 + modules/compatibility/pom.xml | 7 + modules/compress/pom.xml | 7 + modules/control-utility/pom.xml | 7 + modules/core/pom.xml | 7 + .../testframework/junits/GridAbstractTest.java | 8 +- .../testsuites/IgniteLoggingSelfTestSuite.java | 8 + ...iteServiceConfigVariationsFullApiTestSuite.java | 8 + .../testsuites/IgniteServiceGridTestSuite.java | 7 + .../ignite/testsuites/SecurityTestSuite.java | 7 + modules/dev-utils/pom.xml | 7 + modules/direct-io/pom.xml | 7 + modules/extdata/p2p/pom.xml | 2 +- modules/extdata/platform/pom.xml | 7 + modules/gce/pom.xml | 7 + modules/geospatial/pom.xml | 7 + modules/hibernate-4.2/pom.xml | 7 + modules/hibernate-5.1/pom.xml | 7 + modules/hibernate-5.3/pom.xml | 7 + modules/ignored-tests/pom.xml | 7 + modules/indexing/pom.xml | 7 + modules/jcl/pom.xml | 7 + modules/jms11/pom.xml | 7 + modules/jta/pom.xml | 7 + modules/kafka/pom.xml | 7 + .../kafka/IgniteKafkaStreamerSelfTestSuite.java | 7 + modules/kubernetes/pom.xml | 7 + modules/log4j/pom.xml | 7 + modules/log4j2/pom.xml | 7 + modules/mesos/pom.xml | 11 +- modules/ml/h2o-model-parser/pom.xml | 7 + modules/ml/pom.xml | 7 + modules/ml/spark-model-parser/pom.xml | 7 + modules/ml/xgboost-model-parser/pom.xml | 7 + modules/opencensus/pom.xml | 7 + modules/osgi/pom.xml | 6 + modules/rest-http/pom.xml | 7 + modules/scalar-2.10/pom.xml | 7 + modules/scalar/pom.xml | 7 + modules/schedule/pom.xml | 7 + modules/slf4j/pom.xml | 7 + modules/spark-2.4/pom.xml | 7 + modules/spark/pom.xml | 7 + modules/spring-data-2.0/pom.xml | 7 + modules/spring-data-2.2/pom.xml | 7 + modules/spring-data/pom.xml | 7 + modules/spring/pom.xml | 7 + modules/ssh/pom.xml | 7 + modules/tools/pom.xml | 20 +- .../ignite/tools/junit/JUnitTeamcityReporter.java | 234 ++++++++++++++ .../main/java/org/apache/ignite/tools/junit/X.java | 335 +++++++++++++++++++++ .../surefire/TestSuiteAwareTestsetReporter.java | 67 +++++ modules/urideploy/pom.xml | 7 + modules/visor-console/pom.xml | 7 + modules/web/pom.xml | 7 + modules/yarn/pom.xml | 9 +- modules/zookeeper/pom.xml | 7 + parent/pom.xml | 19 +- 67 files changed, 1097 insertions(+), 13 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 592b8c1..b1cea5d 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -140,6 +140,19 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-core</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> <groupId>org.gridgain</groupId> <artifactId>ignite-shmem</artifactId> <version>1.0.0</version> diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml index afe2e8d..69bb571 100644 --- a/modules/aop/pom.xml +++ b/modules/aop/pom.xml @@ -92,6 +92,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java index f8a9acc..5603b63 100644 --- a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java +++ b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java @@ -23,6 +23,7 @@ import org.apache.ignite.gridify.GridifySetToXXXSpringAopSelfTest; import org.apache.ignite.gridify.NonSpringAopSelfTest; import org.apache.ignite.gridify.SpringAopSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -48,6 +49,8 @@ public class IgniteAopSelfTestSuite { /** */ @BeforeClass public static void init() { + JUnitTeamcityReporter.suite = IgniteAopSelfTestSuite.class.getName(); + // Examples System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteAopSelfTestSuite.class)); } diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml index 9661661..3ac50ec 100644 --- a/modules/aws/pom.xml +++ b/modules/aws/pom.xml @@ -149,6 +149,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>${mockito.version}</version> diff --git a/modules/camel/pom.xml b/modules/camel/pom.xml index cbed9e5..158a7af 100644 --- a/modules/camel/pom.xml +++ b/modules/camel/pom.xml @@ -74,6 +74,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> diff --git a/modules/cassandra/serializers/pom.xml b/modules/cassandra/serializers/pom.xml index 31159c3..418922c 100644 --- a/modules/cassandra/serializers/pom.xml +++ b/modules/cassandra/serializers/pom.xml @@ -78,6 +78,13 @@ <artifactId>objenesis</artifactId> <version>${objenesis.version}</version> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/cassandra/store/pom.xml b/modules/cassandra/store/pom.xml index b3eaa2a..f37af89 100644 --- a/modules/cassandra/store/pom.xml +++ b/modules/cassandra/store/pom.xml @@ -70,6 +70,13 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <!-- Cassandra and required dependencies --> <dependency> <groupId>com.datastax.cassandra</groupId> diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/testsuites/cassandra/store/IgniteCassandraStoreTestSuite.java b/modules/cassandra/store/src/test/java/org/apache/ignite/testsuites/cassandra/store/IgniteCassandraStoreTestSuite.java index ed3aa64..20a0fa1 100644 --- a/modules/cassandra/store/src/test/java/org/apache/ignite/testsuites/cassandra/store/IgniteCassandraStoreTestSuite.java +++ b/modules/cassandra/store/src/test/java/org/apache/ignite/testsuites/cassandra/store/IgniteCassandraStoreTestSuite.java @@ -24,6 +24,7 @@ import org.apache.ignite.tests.DDLGeneratorTest; import org.apache.ignite.tests.DatasourceSerializationTest; import org.apache.ignite.tests.IgnitePersistentStoreTest; import org.apache.ignite.tests.utils.CassandraHelper; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; import org.apache.log4j.Logger; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -51,6 +52,8 @@ public class IgniteCassandraStoreTestSuite { /** */ @BeforeClass public static void setUpClass() { + JUnitTeamcityReporter.suite = IgniteCassandraStoreTestSuite.class.getName(); + if (CassandraHelper.useEmbeddedCassandra()) { try { CassandraHelper.startEmbeddedCassandra(LOGGER); diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml index aa13102..447da37 100644 --- a/modules/clients/pom.xml +++ b/modules/clients/pom.xml @@ -100,6 +100,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons.io.version}</version> diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml index c6aac5b..bda4122 100644 --- a/modules/cloud/pom.xml +++ b/modules/cloud/pom.xml @@ -76,6 +76,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> diff --git a/modules/compatibility/pom.xml b/modules/compatibility/pom.xml index b4702b6..149793b 100644 --- a/modules/compatibility/pom.xml +++ b/modules/compatibility/pom.xml @@ -69,6 +69,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.4.8</version> diff --git a/modules/compress/pom.xml b/modules/compress/pom.xml index a9056d3..4647e21 100644 --- a/modules/compress/pom.xml +++ b/modules/compress/pom.xml @@ -90,6 +90,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> diff --git a/modules/control-utility/pom.xml b/modules/control-utility/pom.xml index 1e43a8f..88ca3f2 100644 --- a/modules/control-utility/pom.xml +++ b/modules/control-utility/pom.xml @@ -95,6 +95,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> diff --git a/modules/core/pom.xml b/modules/core/pom.xml index 29343a9..85984c1 100644 --- a/modules/core/pom.xml +++ b/modules/core/pom.xml @@ -75,6 +75,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>mx4j</groupId> <artifactId>mx4j-tools</artifactId> <version>3.0.1</version> 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 1b8d866..978f582 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 @@ -135,6 +135,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.After; import org.junit.AfterClass; +import org.junit.AssumptionViolatedException; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -2368,7 +2369,12 @@ public abstract class GridAbstractTest extends JUnitAssertAware { Throwable t = ex.get(); if (t != null) { - U.error(log, "Test failed.", t); + if (t instanceof AssumptionViolatedException) + U.quietAndInfo(log,"Test ignored [test=" + testDescription() + ", msg=" + t.getMessage() + "]"); + else { + U.error(log, "Test failed [test=" + testDescription() + + ", duration=" + (System.currentTimeMillis() - ts) + "]", t); + } throw t; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java index e108f48..93604f2 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java @@ -18,6 +18,8 @@ package org.apache.ignite.testsuites; import org.apache.ignite.logger.java.JavaLoggerTest; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -27,4 +29,10 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({JavaLoggerTest.class}) public class IgniteLoggingSelfTestSuite { + /** */ + @BeforeClass + public static void setUpClass() { + JUnitTeamcityReporter.suite = IgniteLoggingSelfTestSuite.class.getName(); + } + } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java index 35d6e55..fa3bcd8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java @@ -27,6 +27,8 @@ import org.apache.ignite.testframework.configvariations.ConfigParameter; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.configvariations.Parameters; import org.apache.ignite.testframework.junits.DynamicSuite; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.junit.BeforeClass; import org.junit.runner.RunWith; /** @@ -35,6 +37,12 @@ import org.junit.runner.RunWith; @RunWith(DynamicSuite.class) public class IgniteServiceConfigVariationsFullApiTestSuite { /** */ + @BeforeClass + public static void init() { + JUnitTeamcityReporter.suite = IgniteServiceConfigVariationsFullApiTestSuite.class.getName(); + } + + /** */ @SuppressWarnings("unchecked") private static final ConfigParameter<IgniteConfiguration>[][] PARAMS = new ConfigParameter[][] { Parameters.booleanParameters("setPeerClassLoadingEnabled") diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceGridTestSuite.java index 877417c..ef0c378 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceGridTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceGridTestSuite.java @@ -62,6 +62,8 @@ import org.apache.ignite.internal.processors.service.ServicePredicateAccessCache import org.apache.ignite.internal.processors.service.ServiceReassignmentFunctionSelfTest; import org.apache.ignite.internal.processors.service.SystemCacheNotConfiguredTest; import org.apache.ignite.services.ServiceThreadPoolSelfTest; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -119,4 +121,9 @@ import org.junit.runners.Suite; GridServiceClusterReadOnlyModeTest.class, }) public class IgniteServiceGridTestSuite { + /** */ + @BeforeClass + public static void init() { + JUnitTeamcityReporter.suite = IgniteServiceGridTestSuite.class.getName(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/SecurityTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/SecurityTestSuite.java index 94d31f2..ed2901a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/SecurityTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/SecurityTestSuite.java @@ -62,6 +62,8 @@ import org.apache.ignite.internal.processors.security.sandbox.SchedulerSandboxTe import org.apache.ignite.internal.processors.security.sandbox.SecuritySubjectPermissionsTest; import org.apache.ignite.internal.processors.security.scheduler.SchedulerRemoteSecurityContextCheckTest; import org.apache.ignite.ssl.MultipleSSLContextsTest; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -121,4 +123,9 @@ import org.junit.runners.Suite; MultipleSSLContextsTest.class }) public class SecurityTestSuite { + /** */ + @BeforeClass + public static void init() { + JUnitTeamcityReporter.suite = SecurityTestSuite.class.getName(); + } } diff --git a/modules/dev-utils/pom.xml b/modules/dev-utils/pom.xml index 5991c127..b27590e 100644 --- a/modules/dev-utils/pom.xml +++ b/modules/dev-utils/pom.xml @@ -56,6 +56,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> diff --git a/modules/direct-io/pom.xml b/modules/direct-io/pom.xml index 65d6118..ecad4b1 100644 --- a/modules/direct-io/pom.xml +++ b/modules/direct-io/pom.xml @@ -54,6 +54,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-indexing</artifactId> <version>${project.version}</version> </dependency> diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml index b6f19995..c3f8fa1 100644 --- a/modules/extdata/p2p/pom.xml +++ b/modules/extdata/p2p/pom.xml @@ -49,7 +49,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.12</version> </dependency> </dependencies> diff --git a/modules/extdata/platform/pom.xml b/modules/extdata/platform/pom.xml index 77d26a5..fc22d85 100644 --- a/modules/extdata/platform/pom.xml +++ b/modules/extdata/platform/pom.xml @@ -50,5 +50,12 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml index af717a6..4725061 100644 --- a/modules/gce/pom.xml +++ b/modules/gce/pom.xml @@ -74,6 +74,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml index 7cb6393..17bfc77 100644 --- a/modules/geospatial/pom.xml +++ b/modules/geospatial/pom.xml @@ -56,6 +56,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> diff --git a/modules/hibernate-4.2/pom.xml b/modules/hibernate-4.2/pom.xml index b11616f..eefa26c 100644 --- a/modules/hibernate-4.2/pom.xml +++ b/modules/hibernate-4.2/pom.xml @@ -98,6 +98,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/hibernate-5.1/pom.xml b/modules/hibernate-5.1/pom.xml index 15d76f9..b3bd6b6 100644 --- a/modules/hibernate-5.1/pom.xml +++ b/modules/hibernate-5.1/pom.xml @@ -98,6 +98,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/hibernate-5.3/pom.xml b/modules/hibernate-5.3/pom.xml index 8a1d354..bb9851c 100644 --- a/modules/hibernate-5.3/pom.xml +++ b/modules/hibernate-5.3/pom.xml @@ -98,6 +98,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/ignored-tests/pom.xml b/modules/ignored-tests/pom.xml index 73792b6..56515865 100644 --- a/modules/ignored-tests/pom.xml +++ b/modules/ignored-tests/pom.xml @@ -52,6 +52,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-clients</artifactId> <version>${project.version}</version> </dependency> diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml index 9d5cccc..5ec1a88 100644 --- a/modules/indexing/pom.xml +++ b/modules/indexing/pom.xml @@ -80,6 +80,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.4.8</version> diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml index 934a4f2..8ab0b25 100644 --- a/modules/jcl/pom.xml +++ b/modules/jcl/pom.xml @@ -54,6 +54,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/jms11/pom.xml b/modules/jms11/pom.xml index 660619f..8ef1005 100644 --- a/modules/jms11/pom.xml +++ b/modules/jms11/pom.xml @@ -82,6 +82,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml index bce97f2..38ff7f5 100644 --- a/modules/jta/pom.xml +++ b/modules/jta/pom.xml @@ -70,6 +70,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml index 791af20..8ea1285 100644 --- a/modules/kafka/pom.xml +++ b/modules/kafka/pom.xml @@ -127,6 +127,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.11</artifactId> <version>${kafka.version}</version> diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java index c88fba8..90da8f5 100644 --- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java +++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java @@ -19,6 +19,8 @@ package org.apache.ignite.stream.kafka; import org.apache.ignite.stream.kafka.connect.IgniteSinkConnectorTest; import org.apache.ignite.stream.kafka.connect.IgniteSourceConnectorTest; +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -35,4 +37,9 @@ import org.junit.runners.Suite; IgniteSourceConnectorTest.class }) public class IgniteKafkaStreamerSelfTestSuite { + /** */ + @BeforeClass + public static void setUpClass() { + JUnitTeamcityReporter.suite = IgniteKafkaStreamerSelfTestSuite.class.getName(); + } } diff --git a/modules/kubernetes/pom.xml b/modules/kubernetes/pom.xml index 54cde14..79705e8 100644 --- a/modules/kubernetes/pom.xml +++ b/modules/kubernetes/pom.xml @@ -68,6 +68,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml index d973e58..7d1fae9 100644 --- a/modules/log4j/pom.xml +++ b/modules/log4j/pom.xml @@ -53,6 +53,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml index 3cbeb43..9296484 100644 --- a/modules/log4j2/pom.xml +++ b/modules/log4j2/pom.xml @@ -50,6 +50,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>${log4j.version}</version> diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml index 0582804..6dcf940 100644 --- a/modules/mesos/pom.xml +++ b/modules/mesos/pom.xml @@ -60,7 +60,14 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.12</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> <scope>test</scope> </dependency> </dependencies> @@ -94,4 +101,4 @@ </plugins> </build> -</project> \ No newline at end of file +</project> diff --git a/modules/ml/h2o-model-parser/pom.xml b/modules/ml/h2o-model-parser/pom.xml index 269d3d4..97075c7 100644 --- a/modules/ml/h2o-model-parser/pom.xml +++ b/modules/ml/h2o-model-parser/pom.xml @@ -76,5 +76,12 @@ <artifactId>h2o-genmodel</artifactId> <version>${h2o.version}</version> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/ml/pom.xml b/modules/ml/pom.xml index f99ddf0..5a45bf9 100644 --- a/modules/ml/pom.xml +++ b/modules/ml/pom.xml @@ -74,6 +74,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-indexing</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/ml/spark-model-parser/pom.xml b/modules/ml/spark-model-parser/pom.xml index 1560666..8f42dad 100644 --- a/modules/ml/spark-model-parser/pom.xml +++ b/modules/ml/spark-model-parser/pom.xml @@ -78,6 +78,13 @@ <artifactId>hadoop-common</artifactId> <version>2.9.1</version> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/ml/xgboost-model-parser/pom.xml b/modules/ml/xgboost-model-parser/pom.xml index 9cdaf23..810f9e6 100644 --- a/modules/ml/xgboost-model-parser/pom.xml +++ b/modules/ml/xgboost-model-parser/pom.xml @@ -75,6 +75,13 @@ <artifactId>antlr4-runtime</artifactId> <version>${antlr.version}</version> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/opencensus/pom.xml b/modules/opencensus/pom.xml index 6a93ee4..c9d8797 100644 --- a/modules/opencensus/pom.xml +++ b/modules/opencensus/pom.xml @@ -51,6 +51,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-log4j</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/osgi/pom.xml b/modules/osgi/pom.xml index c993c34..54942c0 100644 --- a/modules/osgi/pom.xml +++ b/modules/osgi/pom.xml @@ -97,6 +97,12 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml index 62de2c8..d64b4bd 100644 --- a/modules/rest-http/pom.xml +++ b/modules/rest-http/pom.xml @@ -140,6 +140,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring-5.0.version}</version> diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml index 2f6b07e..ccfd10e 100644 --- a/modules/scalar-2.10/pom.xml +++ b/modules/scalar-2.10/pom.xml @@ -57,6 +57,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml index 85c92f4..e46e8f2 100644 --- a/modules/scalar/pom.xml +++ b/modules/scalar/pom.xml @@ -57,6 +57,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-spring</artifactId> <version>${project.version}</version> <scope>test</scope> diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml index 07aff52..e01f4d0 100644 --- a/modules/schedule/pom.xml +++ b/modules/schedule/pom.xml @@ -63,6 +63,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml index f3bc4c7..217ec35 100644 --- a/modules/slf4j/pom.xml +++ b/modules/slf4j/pom.xml @@ -56,6 +56,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>${log4j.version}</version> diff --git a/modules/spark-2.4/pom.xml b/modules/spark-2.4/pom.xml index 809b82a..d3afded 100644 --- a/modules/spark-2.4/pom.xml +++ b/modules/spark-2.4/pom.xml @@ -160,6 +160,13 @@ </exclusion> </exclusions> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml index 6ae0a4c..4e913b9 100644 --- a/modules/spark/pom.xml +++ b/modules/spark/pom.xml @@ -50,6 +50,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.library.version}</version> diff --git a/modules/spring-data-2.0/pom.xml b/modules/spring-data-2.0/pom.xml index a09914d..3527539 100644 --- a/modules/spring-data-2.0/pom.xml +++ b/modules/spring-data-2.0/pom.xml @@ -142,6 +142,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/spring-data-2.2/pom.xml b/modules/spring-data-2.2/pom.xml index 0ce9ef3..6217e78 100644 --- a/modules/spring-data-2.2/pom.xml +++ b/modules/spring-data-2.2/pom.xml @@ -142,6 +142,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/spring-data/pom.xml b/modules/spring-data/pom.xml index fb877b7..3aacc0a 100644 --- a/modules/spring-data/pom.xml +++ b/modules/spring-data/pom.xml @@ -88,6 +88,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml index 994fbaf..8a57470 100644 --- a/modules/spring/pom.xml +++ b/modules/spring/pom.xml @@ -132,6 +132,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.4.8</version> diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml index 6e43e88..bc2283e 100644 --- a/modules/ssh/pom.xml +++ b/modules/ssh/pom.xml @@ -68,6 +68,13 @@ <type>test-jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml index 25930a5..d5469b7 100644 --- a/modules/tools/pom.xml +++ b/modules/tools/pom.xml @@ -34,8 +34,6 @@ <version>2.10.0-SNAPSHOT</version> <url>http://ignite.apache.org</url> - - <profiles> <profile> <id>java-9+</id> @@ -58,7 +56,6 @@ </profile> </profiles> - <build> <sourceDirectory>src/main/java</sourceDirectory> <plugins> @@ -84,9 +81,6 @@ </plugins> </build> - - - <dependencies> <dependency> <groupId>org.jodd</groupId> @@ -99,6 +93,20 @@ <artifactId>ant</artifactId> <version>1.8.2</version> </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>maven-surefire-common</artifactId> + <version>3.0.0-M4</version> + </dependency> + <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> 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 new file mode 100644 index 0000000..463c41a --- /dev/null +++ b/modules/tools/src/main/java/org/apache/ignite/tools/junit/JUnitTeamcityReporter.java @@ -0,0 +1,234 @@ +/* + * 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.tools.junit; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import org.junit.Ignore; +import org.junit.runner.Description; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; + +/** + * A JUnit RunListener that produces output conforming to the Teamcity messages specification. + * + * Inspired by https://github.com/mbruggmann/junit-teamcity-reporter/ + */ +public class JUnitTeamcityReporter extends RunListener { + /** */ + private static final long FLUSH_THRESHOLD = 5 * 60 * 1000; + + /** */ + public static volatile String suite; + + /** */ + private final Path reportDir; + + /** */ + private final XMLOutputFactory outputFactory; + + /** */ + private String prevSuite; + + /** */ + private String prevTestCls; + + /** */ + private long prevFlush; + + /** */ + private FileOutputStream curStream; + + /** */ + private XMLStreamWriter curXmlStream; + + /** */ + public JUnitTeamcityReporter() throws IOException { + reportDir = Files.createTempDirectory("ignite-tools-junit-reports"); + outputFactory = XMLOutputFactory.newInstance(); + } + + /** */ + @Override public synchronized void testAssumptionFailure(Failure failure) { + if (curXmlStream == null) + testStarted(failure.getDescription()); + + try { + curXmlStream.writeStartElement("skipped"); + + if (failure.getMessage() != null) + curXmlStream.writeAttribute("message", failure.getMessage()); + + curXmlStream.writeEndElement(); + } + catch (XMLStreamException ex) { + throw new RuntimeException(ex); + } + } + + /** */ + @Override public synchronized void testStarted(Description desc) { + if (!desc.getClassName().equals(prevTestCls)) + System.out.println(String.format("##teamcity[progressMessage 'Running %s']", + escapeForTeamcity(desc.getClassName()))); + + try { + if (afterFlush(desc.getClassName())) { + prevSuite = suite; + prevFlush = System.currentTimeMillis(); + + curStream = new FileOutputStream(reportDir.resolve(fileName()).toFile()); + + curXmlStream = outputFactory.createXMLStreamWriter(curStream); + + curXmlStream.writeStartDocument(); + curXmlStream.writeStartElement("testsuite"); + curXmlStream.writeAttribute("version", "3.0"); + curXmlStream.writeAttribute("name", suite != null ? suite : desc.getClassName()); + } + + prevTestCls = desc.getClassName(); + + curXmlStream.writeStartElement("testcase"); + curXmlStream.writeAttribute("name", desc.getMethodName() != null ? desc.getMethodName() : ""); + curXmlStream.writeAttribute("classname", desc.getClassName()); + + // Avoid doubling of run time after the surefire-generated full report is ingested: + curXmlStream.writeAttribute("time", "0"); + } + catch (XMLStreamException | FileNotFoundException ex) { + throw new RuntimeException(ex); + } + } + + /** */ + @Override public synchronized void testFinished(Description desc) { + if (curXmlStream == null) + testStarted(desc); + + try { + curXmlStream.writeEndElement(); + } + catch (XMLStreamException ex) { + throw new RuntimeException(ex); + } + } + + /** */ + @Override public synchronized void testFailure(Failure failure) { + if (curXmlStream == null) + testStarted(failure.getDescription()); + + try { + curXmlStream.writeStartElement("failure"); + + if (failure.getException() != null && failure.getException().getMessage() != null) + curXmlStream.writeAttribute("type", failure.getException().getMessage()); + + if (failure.getMessage() != null) + curXmlStream.writeCData(failure.getMessage()); + + curXmlStream.writeEndElement(); + + if (failure.getException() != null) { + curXmlStream.writeStartElement("system-out"); + curXmlStream.writeCData(X.getFullStackTrace(failure.getException())); + curXmlStream.writeEndElement(); + } + } + catch (XMLStreamException ex) { + throw new RuntimeException(ex); + } + } + + /** */ + @Override public synchronized void testIgnored(Description desc) { + testStarted(desc); + + Ignore annotation = desc.getAnnotation(Ignore.class); + + try { + curXmlStream.writeStartElement("skipped"); + + if (annotation != null) + curXmlStream.writeAttribute("message", annotation.value()); + + curXmlStream.writeEndElement(); + } + catch (XMLStreamException ex) { + throw new RuntimeException(ex); + } + + testFinished(desc); + } + + /** */ + private boolean afterFlush(String testCls) { + if (curStream == null) + return true; + + if ((prevSuite == null ? suite != null : !prevSuite.equals(suite)) || + (prevTestCls == null ? testCls != null : !prevTestCls.equals(testCls)) || + (System.currentTimeMillis() - prevFlush) > FLUSH_THRESHOLD) { + try { + curXmlStream.writeEndElement(); + curXmlStream.writeEndDocument(); + curXmlStream.close(); + curStream.close(); + } + catch (XMLStreamException | IOException ex) { + throw new RuntimeException(ex); + } + + File report = reportDir.resolve(fileName()).toFile(); + + assert report.exists(); + + System.out.println(String.format("##teamcity[importData type='surefire' path='%s']", + escapeForTeamcity(report.getAbsolutePath()))); + + return true; + } + + return false; + } + + /** */ + private String fileName() { + return "test-" + prevSuite + prevFlush + ".xml"; + } + + /** */ + private String escapeForTeamcity(String msg) { + return (msg == null ? "null" : msg) + .replace("|", "||") + .replace("\r", "|r") + .replace("\n", "|n") + .replace("'", "|'") + .replace("[", "|[") + .replace("]", "|]"); + } +} + diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/junit/X.java b/modules/tools/src/main/java/org/apache/ignite/tools/junit/X.java new file mode 100644 index 0000000..e696cd9 --- /dev/null +++ b/modules/tools/src/main/java/org/apache/ignite/tools/junit/X.java @@ -0,0 +1,335 @@ +/* + * 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.tools.junit; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * Defines global scope. + * <p> + * Contains often used utility functions allowing to cut down on code bloat. This + * is somewhat analogous to {@code Predef} in Scala. Note that this should only be used + * when this typedef <b>does not sacrifice</b> the code readability. + */ +final class X { + /** An empty immutable {@code Object} array. */ + public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; + + /** The names of methods commonly used to access a wrapped exception. */ + private static final String[] CAUSE_MTD_NAMES = new String[] { + "getCause", + "getNextException", + "getTargetException", + "getException", + "getSourceException", + "getRootCause", + "getCausedByException", + "getNested", + "getLinkedException", + "getNestedException", + "getLinkedCause", + "getThrowable" + }; + + /** The Method object for Java 1.4 getCause. */ + private static final Method THROWABLE_CAUSE_METHOD; + + static { + Method causeMtd; + + try { + causeMtd = Throwable.class.getMethod("getCause", null); + } + catch (Exception ignored) { + causeMtd = null; + } + + THROWABLE_CAUSE_METHOD = causeMtd; + } + + /** + * Ensures singleton. + */ + private X() { + // No-op. + } + + /** + * @param throwable The exception to examine. + * @return The wrapped exception, or {@code null} if not found. + */ + private static Throwable getCauseUsingWellKnownTypes(Throwable throwable) { + if (throwable instanceof SQLException) + return ((SQLException)throwable).getNextException(); + + if (throwable instanceof InvocationTargetException) + return ((InvocationTargetException)throwable).getTargetException(); + + return null; + } + + /** + * Finds a {@code Throwable} by method name. + * + * @param throwable The exception to examine. + * @param mtdName The name of the method to find and invoke. + * @return The wrapped exception, or {@code null} if not found. + */ + private static Throwable getCauseUsingMethodName(Throwable throwable, String mtdName) { + Method mtd = null; + + try { + mtd = throwable.getClass().getMethod(mtdName, null); + } + catch (NoSuchMethodException | SecurityException ignored) { + // exception ignored + } + + if (mtd != null && Throwable.class.isAssignableFrom(mtd.getReturnType())) { + try { + return (Throwable)mtd.invoke(throwable, EMPTY_OBJECT_ARRAY); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) { + // exception ignored + } + } + + return null; + } + + /** + * Finds a {@code Throwable} by field name. + * + * @param throwable The exception to examine. + * @param fieldName The name of the attribute to examine. + * @return The wrapped exception, or {@code null} if not found. + */ + private static Throwable getCauseUsingFieldName(Throwable throwable, String fieldName) { + Field field = null; + + try { + field = throwable.getClass().getField(fieldName); + } + catch (NoSuchFieldException | SecurityException ignored) { + // exception ignored + } + + if (field != null && Throwable.class.isAssignableFrom(field.getType())) { + try { + return (Throwable)field.get(throwable); + } + catch (IllegalAccessException | IllegalArgumentException ignored) { + // exception ignored + } + } + + return null; + } + + /** + * Checks if the Throwable class has a {@code getCause} method. + * + * This is true for JDK 1.4 and above. + * + * @return True if Throwable is nestable. + */ + private static boolean isThrowableNested() { + return THROWABLE_CAUSE_METHOD != null; + } + + /** + * Checks whether this {@code Throwable} class can store a cause. + * + * This method does not check whether it actually does store a cause. + * + * @param throwable The {@code Throwable} to examine, may be null. + * @return Boolean {@code true} if nested otherwise {@code false}. + */ + private static boolean isNestedThrowable(Throwable throwable) { + if (throwable == null) + return false; + + if (throwable instanceof SQLException || throwable instanceof InvocationTargetException) + return true; + + if (isThrowableNested()) + return true; + + Class<?> cls = throwable.getClass(); + for (String CAUSE_MTD_NAME : CAUSE_MTD_NAMES) { + try { + Method mtd = cls.getMethod(CAUSE_MTD_NAME, null); + + if (mtd != null && Throwable.class.isAssignableFrom(mtd.getReturnType())) + return true; + } + catch (NoSuchMethodException | SecurityException ignored) { + // exception ignored + } + } + + try { + Field field = cls.getField("detail"); + + if (field != null) + return true; + } + catch (NoSuchFieldException | SecurityException ignored) { + // exception ignored + } + + return false; + } + + /** + * Introspects the {@code Throwable} to obtain the cause. + * + * The method searches for methods with specific names that return a {@code Throwable} object. + * This will pick up most wrapping exceptions, including those from JDK 1.4. + * + * The default list searched for are:</p> <ul> <li>{@code getCause()}</li> + * <li>{@code getNextException()}</li> <li>{@code getTargetException()}</li> + * <li>{@code getException()}</li> <li>{@code getSourceException()}</li> + * <li>{@code getRootCause()}</li> <li>{@code getCausedByException()}</li> + * <li>{@code getNested()}</li> </ul> + * + * <p>In the absence of any such method, the object is inspected for a {@code detail} + * field assignable to a {@code Throwable}.</p> + * + * If none of the above is found, returns {@code null}. + * + * @param throwable The throwable to introspect for a cause, may be null. + * @return The cause of the {@code Throwable}, + * {@code null} if none found or null throwable input. + */ + private static Throwable getCause(Throwable throwable) { + return getCause(throwable, CAUSE_MTD_NAMES); + } + + /** + * Introspects the {@code Throwable} to obtain the cause. + * + * <ol> <li>Try known exception types.</li> + * <li>Try the supplied array of method names.</li> + * <li>Try the field 'detail'.</li> </ol> + * + * <p>A {@code null} set of method names means use the default set. + * A {@code null} in the set of method names will be ignored.</p> + * + * @param throwable The throwable to introspect for a cause, may be null. + * @param mtdNames The method names, null treated as default set. + * @return The cause of the {@code Throwable}, {@code null} if none found or null throwable input. + */ + private static Throwable getCause(Throwable throwable, String[] mtdNames) { + if (throwable == null) + return null; + + Throwable cause = getCauseUsingWellKnownTypes(throwable); + + if (cause == null) { + if (mtdNames == null) + mtdNames = CAUSE_MTD_NAMES; + + for (String mtdName : mtdNames) { + if (mtdName != null) { + cause = getCauseUsingMethodName(throwable, mtdName); + + if (cause != null) + break; + } + } + + if (cause == null) + cause = getCauseUsingFieldName(throwable, "detail"); + } + + return cause; + } + + /** + * Returns the list of {@code Throwable} objects in the exception chain. + * + * A throwable without cause will return a list containing one element - the input throwable. + * A throwable with one cause will return a list containing two elements - the input throwable + * and the cause throwable. A {@code null} throwable will return a list of size zero. + * + * This method handles recursive cause structures that might otherwise cause infinite loops. + * The cause chain is processed until the end is reached, or until the next item in the chain + * is already in the result set.</p> + * + * @param throwable The throwable to inspect, may be null. + * @return The list of throwables, never null. + */ + private static List<Throwable> getThrowableList(Throwable throwable) { + List<Throwable> list = new ArrayList<>(); + + while (throwable != null && !list.contains(throwable)) { + list.add(throwable); + throwable = getCause(throwable); + } + + return list; + } + + /** + * Returns the list of {@code Throwable} objects in the exception chain. + * + * A throwable without cause will return an array containing one element - the input throwable. + * A throwable with one cause will return an array containing two elements - the input throwable + * and the cause throwable. A {@code null} throwable will return an array of size zero. + * + * @param throwable The throwable to inspect, may be null. + * @return The array of throwables, never null. + */ + private static Throwable[] getThrowables(Throwable throwable) { + List<Throwable> list = getThrowableList(throwable); + + return list.toArray(new Throwable[list.size()]); + } + + /** + * A way to get the entire nested stack-trace of an throwable. + * + * The result of this method is highly dependent on the JDK version + * and whether the exceptions override printStackTrace or not. + * + * @param throwable The {@code Throwable} to be examined. + * @return The nested stack trace, with the root cause first. + */ + static String getFullStackTrace(Throwable throwable) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw, true); + Throwable[] ts = getThrowables(throwable); + + for (Throwable t : ts) { + t.printStackTrace(pw); + + if (isNestedThrowable(t)) + break; + } + + return sw.getBuffer().toString(); + } +} diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/surefire/TestSuiteAwareTestsetReporter.java b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/TestSuiteAwareTestsetReporter.java new file mode 100644 index 0000000..b49a54a --- /dev/null +++ b/modules/tools/src/main/java/org/apache/ignite/tools/surefire/TestSuiteAwareTestsetReporter.java @@ -0,0 +1,67 @@ +/* + * 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.tools.surefire; + +import org.apache.ignite.tools.junit.JUnitTeamcityReporter; +import org.apache.maven.plugin.surefire.extensions.SurefireStatelessTestsetInfoReporter; +import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; +import org.apache.maven.plugin.surefire.report.ConsoleReporter; +import org.apache.maven.plugin.surefire.report.TestSetStats; +import org.apache.maven.plugin.surefire.report.WrappedReportEntry; +import org.apache.maven.surefire.extensions.StatelessTestsetInfoConsoleReportEventListener; +import org.apache.maven.surefire.report.ReportEntry; +import org.apache.maven.surefire.report.TestSetReportEntry; +import org.apache.maven.surefire.shade.common.org.apache.maven.shared.utils.logging.MessageBuilder; +import org.apache.maven.surefire.shade.common.org.apache.maven.shared.utils.logging.MessageUtils; + +import static org.apache.maven.surefire.report.CategorizedReportEntry.GROUP_PREFIX; + +/** */ +public class TestSuiteAwareTestsetReporter extends SurefireStatelessTestsetInfoReporter { + /** */ + @Override public StatelessTestsetInfoConsoleReportEventListener<WrappedReportEntry, TestSetStats> createListener( + ConsoleLogger log) { + return new ConsoleReporter(log, false, false) { + /** */ + public void testSetStarting(TestSetReportEntry report) { + MessageBuilder builder = MessageUtils.buffer(); + + JUnitTeamcityReporter.suite = concatenateWithTestGroup(builder, report); + + super.testSetStarting(report); + } + }; + } + + /** + * @see TestSetStats#concatenateWithTestGroup(MessageBuilder, ReportEntry, boolean) + */ + private static String concatenateWithTestGroup(MessageBuilder builder, ReportEntry report) + { + String testCls = report.getNameWithGroup(); + + int idxOfGrp = testCls.indexOf(GROUP_PREFIX); + + int delim = testCls.lastIndexOf('.', idxOfGrp == -1 ? testCls.length() : idxOfGrp); + + String pkg = testCls.substring(0, 1 + delim); + String cls = testCls.substring(1 + delim); + + return builder.a(pkg).a(cls).toString(); + } +} diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml index c658ec5..57395ee 100644 --- a/modules/urideploy/pom.xml +++ b/modules/urideploy/pom.xml @@ -112,6 +112,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-io</artifactId> <version>${jetty.version}</version> diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml index 6d86dc7..40f95e9 100644 --- a/modules/visor-console/pom.xml +++ b/modules/visor-console/pom.xml @@ -99,6 +99,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_2.11</artifactId> <version>${scala.test.version}</version> diff --git a/modules/web/pom.xml b/modules/web/pom.xml index bbcb911..3585bcd 100644 --- a/modules/web/pom.xml +++ b/modules/web/pom.xml @@ -84,6 +84,13 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml index 53d40db..0889227 100644 --- a/modules/yarn/pom.xml +++ b/modules/yarn/pom.xml @@ -90,9 +90,16 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.12</version> <scope>test</scope> </dependency> </dependencies> diff --git a/modules/zookeeper/pom.xml b/modules/zookeeper/pom.xml index 26abc67..76989e0 100644 --- a/modules/zookeeper/pom.xml +++ b/modules/zookeeper/pom.xml @@ -159,6 +159,13 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-indexing</artifactId> <version>${project.version}</version> <type>test-jar</type> diff --git a/parent/pom.xml b/parent/pom.xml index 3903c50..069c9d3 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -44,6 +44,7 @@ <git.exec>git</git.exec> <javadoc.opts>-Xdoclint:none</javadoc.opts> <update.notifier.enabled.by.default>true</update.notifier.enabled.by.default> + <failIfNoTests>false</failIfNoTests> <!-- Dependency versions --> <activemq.version>5.12.0</activemq.version> @@ -212,7 +213,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.12</version> <scope>test</scope> </dependency> @@ -574,10 +575,24 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>3.0.0-M3</version> + <version>3.0.0-M4</version> <configuration> <forkCount>0</forkCount> + <statelessTestsetInfoReporter implementation="org.apache.ignite.tools.surefire.TestSuiteAwareTestsetReporter"/> + <properties> + <property> + <name>listener</name> + <value>org.apache.ignite.tools.junit.JUnitTeamcityReporter</value> + </property> + </properties> </configuration> + <dependencies> + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-tools</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> </plugin> <plugin>