This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new e3c6cefbb1 IGNITE-19249 Check that no muted tests with absent ticket mention (#1916) e3c6cefbb1 is described below commit e3c6cefbb18390247c541997c58220bc552cb1c6 Author: ygerzhedovich <41903880+ygerzhedov...@users.noreply.github.com> AuthorDate: Fri Apr 21 16:45:30 2023 +0300 IGNITE-19249 Check that no muted tests with absent ticket mention (#1916) --- modules/arch-test/build.gradle | 39 +++++++++++ .../internal/DisabledTestsHasTicketArchTest.java | 75 ++++++++++++++++++++++ .../ignite/internal}/IgniteExceptionArchTest.java | 24 ++----- .../apache/ignite/lang/IgniteTestImportOption.java | 35 ++++++++++ .../org/apache/ignite/lang/LocationProvider.java | 41 ++++++++++++ .../internal/cli/commands/PicocliBugTest.java | 2 +- .../org/apache/ignite/client/ConnectionTest.java | 2 +- .../testframework/WorkDirectoryExtensionTest.java | 2 +- .../ignite/jdbc/ItJdbcConnectionSelfTest.java | 2 +- .../metastorage/impl/ItMetaStorageServiceTest.java | 4 +- .../apache/ignite/raft/jraft/core/ItNodeTest.java | 2 +- .../internal/sql/engine/IgniteSqlApiTest.java | 2 +- .../org/apache/ignite/internal/table/Example.java | 19 +++--- .../apache/ignite/internal/table/TxLocalTest.java | 2 +- settings.gradle | 2 + 15 files changed, 219 insertions(+), 34 deletions(-) diff --git a/modules/arch-test/build.gradle b/modules/arch-test/build.gradle new file mode 100644 index 0000000000..ec43164df1 --- /dev/null +++ b/modules/arch-test/build.gradle @@ -0,0 +1,39 @@ +/* + * 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. + */ + +apply from: "$rootDir/buildscripts/java-core.gradle" +apply from: "$rootDir/buildscripts/java-junit5.gradle" + +description = 'ignite-arch-test' + +dependencies { + parent.subprojects { + if (it != this.project) { + testImplementation it + } + } + + testImplementation libs.archunit.core + testImplementation libs.archunit.junit5 +} + +tasks.withType(Test).configureEach { + parent.subprojects.forEach { + dependsOn it.getTasksByName("testClasses", true) + dependsOn it.getTasksByName("integrationTestClasses", true) + } +} diff --git a/modules/arch-test/src/test/java/org/apache/ignite/internal/DisabledTestsHasTicketArchTest.java b/modules/arch-test/src/test/java/org/apache/ignite/internal/DisabledTestsHasTicketArchTest.java new file mode 100644 index 0000000000..4c411cca0c --- /dev/null +++ b/modules/arch-test/src/test/java/org/apache/ignite/internal/DisabledTestsHasTicketArchTest.java @@ -0,0 +1,75 @@ +/* + * 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; + +import com.tngtech.archunit.core.domain.JavaClass; +import com.tngtech.archunit.core.domain.JavaMethod; +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchTest; +import com.tngtech.archunit.lang.ArchCondition; +import com.tngtech.archunit.lang.ArchRule; +import com.tngtech.archunit.lang.ConditionEvent; +import com.tngtech.archunit.lang.ConditionEvents; +import com.tngtech.archunit.lang.SimpleConditionEvent; +import com.tngtech.archunit.lang.syntax.ArchRuleDefinition; +import org.apache.ignite.lang.IgniteTestImportOption; +import org.apache.ignite.lang.LocationProvider.RootLocationProvider; +import org.junit.jupiter.api.Disabled; + +/** + * Tests that all muted test have appropriate tickets. + */ +@AnalyzeClasses( + packages = "org.apache.ignite", + importOptions = IgniteTestImportOption.class, + locations = RootLocationProvider.class) +public class DisabledTestsHasTicketArchTest { + @ArchTest + public static final ArchRule DISABLED_TEST_CLASS_HAS_TICKET_MENTION = ArchRuleDefinition + .classes().that().areAnnotatedWith(Disabled.class) + .should(new ArchCondition<>("test class have mention of IGNITE ticket") { + @Override + public void check(JavaClass javaClass, ConditionEvents events) { + checkAnnotation(javaClass.getName(), javaClass.getAnnotationOfType(Disabled.class), events); + } + }); + + @ArchTest + public static final ArchRule DISABLED_TEST_METHOD_HAS_TICKET_MENTION = ArchRuleDefinition + .methods().that().areAnnotatedWith(Disabled.class) + .should(new ArchCondition<>("test method have mention of IGNITE ticket") { + @Override + public void check(JavaMethod javaMethod, ConditionEvents events) { + checkAnnotation(javaMethod.getFullName(), javaMethod.getAnnotationOfType(Disabled.class), events); + } + }); + + static void checkAnnotation(String name, Disabled annotation, ConditionEvents events) { + String disableReason = annotation.value(); + + if (disableReason != null && disableReason.toUpperCase().contains("IGNITE-")) { + return; + } + + ConditionEvent event = SimpleConditionEvent.violated( + name, + name + " disabled but does not have a reference to a ticket"); + + events.add(event); + } +} diff --git a/modules/api/src/test/java/org/apache/ignite/lang/IgniteExceptionArchTest.java b/modules/arch-test/src/test/java/org/apache/ignite/internal/IgniteExceptionArchTest.java similarity index 82% rename from modules/api/src/test/java/org/apache/ignite/lang/IgniteExceptionArchTest.java rename to modules/arch-test/src/test/java/org/apache/ignite/internal/IgniteExceptionArchTest.java index 02c430b7cd..4f400de4ae 100644 --- a/modules/api/src/test/java/org/apache/ignite/lang/IgniteExceptionArchTest.java +++ b/modules/arch-test/src/test/java/org/apache/ignite/internal/IgniteExceptionArchTest.java @@ -15,42 +15,33 @@ * limitations under the License. */ -package org.apache.ignite.lang; +package org.apache.ignite.internal; import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaConstructor; -import com.tngtech.archunit.core.importer.Location; +import com.tngtech.archunit.core.importer.ImportOption; 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.ConditionEvent; import com.tngtech.archunit.lang.ConditionEvents; import com.tngtech.archunit.lang.SimpleConditionEvent; import com.tngtech.archunit.lang.syntax.ArchRuleDefinition; -import java.nio.file.Path; import java.util.Optional; -import java.util.Set; import java.util.UUID; +import org.apache.ignite.lang.IgniteCheckedException; +import org.apache.ignite.lang.IgniteException; +import org.apache.ignite.lang.LocationProvider.RootLocationProvider; /** * Tests that all public Ignite exceptions have correct definitions. */ @AnalyzeClasses( packages = "org.apache.ignite", - locations = IgniteExceptionArchTest.RootLocationProvider.class) + importOptions = ImportOption.DoNotIncludeTests.class, + locations = RootLocationProvider.class) public class IgniteExceptionArchTest { - static class RootLocationProvider implements LocationProvider { - @Override - public Set<Location> get(Class<?> testClass) { - // ignite-3/modules - Path modulesRoot = Path.of("").toAbsolutePath().getParent(); - - return Set.of(Location.of(modulesRoot)); - } - } - @SuppressWarnings("unused") @ArchTest public static final ArchRule IGNITE_EXCEPTIONS_HAVE_REQUIRED_CONSTRUCTORS = ArchRuleDefinition.classes() @@ -71,7 +62,6 @@ public class IgniteExceptionArchTest { javaClass.getName() + " does not have a standard constructor with " + "(UUID traceId, int code, String message, Throwable cause) signature."); - conditionEvents.add(event); } } diff --git a/modules/arch-test/src/test/java/org/apache/ignite/lang/IgniteTestImportOption.java b/modules/arch-test/src/test/java/org/apache/ignite/lang/IgniteTestImportOption.java new file mode 100644 index 0000000000..e89d89dcbf --- /dev/null +++ b/modules/arch-test/src/test/java/org/apache/ignite/lang/IgniteTestImportOption.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.lang; + +import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.core.importer.Location; +import java.util.regex.Pattern; + +/** + * Provide the ability to evaluate every class location, to determine if the class should be treated as a test class. + */ +public class IgniteTestImportOption implements ImportOption { + private final Pattern integrationTestPattern = Pattern.compile(".*/build/classes/([^/]+/)integrationTest/.*"); + + /** {@inheritDoc} */ + @Override + public boolean includes(Location location) { + return Predefined.ONLY_INCLUDE_TESTS.includes(location) || location.matches(integrationTestPattern); + } +} diff --git a/modules/arch-test/src/test/java/org/apache/ignite/lang/LocationProvider.java b/modules/arch-test/src/test/java/org/apache/ignite/lang/LocationProvider.java new file mode 100644 index 0000000000..8dc5483b69 --- /dev/null +++ b/modules/arch-test/src/test/java/org/apache/ignite/lang/LocationProvider.java @@ -0,0 +1,41 @@ +/* + * 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.lang; + +import com.tngtech.archunit.core.importer.Location; +import java.nio.file.Path; +import java.util.Set; + +/** + * Provide location providers for arch tests. + */ +public class LocationProvider { + + /** + * Location provider for a root. Include all modules. + */ + public static class RootLocationProvider implements com.tngtech.archunit.junit.LocationProvider { + @Override + public Set<Location> get(Class<?> testClass) { + // ignite-3/modules + Path modulesRoot = Path.of("").toAbsolutePath().getParent(); + + return Set.of(Location.of(modulesRoot)); + } + } +} diff --git a/modules/cli/src/test/java/org/apache/ignite/internal/cli/commands/PicocliBugTest.java b/modules/cli/src/test/java/org/apache/ignite/internal/cli/commands/PicocliBugTest.java index cee5a94edb..7969e225c7 100644 --- a/modules/cli/src/test/java/org/apache/ignite/internal/cli/commands/PicocliBugTest.java +++ b/modules/cli/src/test/java/org/apache/ignite/internal/cli/commands/PicocliBugTest.java @@ -35,7 +35,7 @@ import picocli.CommandLine.Spec; //TODO: Change org.apache.ignite.cli.commands.CliCommandTestBase after fix https://github.com/remkop/picocli/issues/1733 @MicronautTest -@Disabled +@Disabled("https://issues.apache.org/jira/browse/IGNITE-19296") class PicocliBugTest { @Inject private ApplicationContext context; diff --git a/modules/client/src/test/java/org/apache/ignite/client/ConnectionTest.java b/modules/client/src/test/java/org/apache/ignite/client/ConnectionTest.java index 58840ec84f..de16f6a8aa 100644 --- a/modules/client/src/test/java/org/apache/ignite/client/ConnectionTest.java +++ b/modules/client/src/test/java/org/apache/ignite/client/ConnectionTest.java @@ -70,7 +70,7 @@ public class ConnectionTest extends AbstractClientTest { testConnection("127.0.0.1:47500", "127.0.0.1:10801", "127.0.0.1:" + serverPort); } - @Disabled("IPv6 is not enabled by default on some systems.") + @Disabled("https://issues.apache.org/jira/browse/IGNITE-15611 . IPv6 is not enabled by default on some systems.") @Test public void testIpv6NodeAddresses() throws Exception { testConnection("[::1]:" + serverPort); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtensionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtensionTest.java index 0ab278b651..d41c80ac0c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtensionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/testframework/WorkDirectoryExtensionTest.java @@ -371,7 +371,7 @@ class WorkDirectoryExtensionTest { @WorkDirectory private Path workDir; - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-15799") @Test void test() { } diff --git a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionSelfTest.java b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionSelfTest.java index 052167a5ab..12e02ce9da 100644 --- a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionSelfTest.java +++ b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionSelfTest.java @@ -94,7 +94,7 @@ public class ItJdbcConnectionSelfTest extends AbstractJdbcSelfTest { } @SuppressWarnings({"EmptyTryBlock", "unused"}) - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-15611") @Test public void testDefaultsIpv6() throws Exception { var url = "jdbc:ignite:thin://[::1]:10800"; diff --git a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java index 804fba9a7f..d155f3119d 100644 --- a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java +++ b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java @@ -795,7 +795,7 @@ public class ItMetaStorageServiceTest { /** * Tests {@link MetaStorageService#get(ByteArray)}. */ - @Disabled // TODO: IGNITE-14693 Add tests for exception handling logic. + @Disabled("IGNITE-14693 Add tests for exception handling logic.") @Test public void testGetThatThrowsCompactedException() { Node node = startNodes(1).get(0); @@ -808,7 +808,7 @@ public class ItMetaStorageServiceTest { /** * Tests {@link MetaStorageService#get(ByteArray)}. */ - @Disabled // TODO: IGNITE-14693 Add tests for exception handling logic. + @Disabled("IGNITE-14693 Add tests for exception handling logic.") @Test public void testGetThatThrowsOperationTimeoutException() { Node node = startNodes(1).get(0); diff --git a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java index 0066219717..e6b2c637e7 100644 --- a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java +++ b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java @@ -496,7 +496,7 @@ public class ItNodeTest { // TODO asch Broken then using volatile log. A follower with empty log can become a leader IGNITE-14832. @Test - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-14832") public void testVoteTimedoutStepDown() throws Exception { List<TestPeer> peers = TestUtils.generatePeers(testInfo, 3); diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/IgniteSqlApiTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/IgniteSqlApiTest.java index f37f445801..e90c05d938 100644 --- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/IgniteSqlApiTest.java +++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/IgniteSqlApiTest.java @@ -344,7 +344,7 @@ public class IgniteSqlApiTest { Mockito.verify(transaction).commitAsync(); } - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19299") @Test public void testMetadata() { ResultSet<SqlRow> rs = igniteSql.createSession() diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java b/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java index 26224fea9a..53a0cf9a06 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/Example.java @@ -59,7 +59,7 @@ public class Example { * Use case 1: a simple one. The table has the structure [ [id int, orgId int] // key [name varchar, lastName varchar, decimal salary, * int department] // value ] We show how to use the raw TableRow and a mapped class. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase1(Table t) { @@ -118,7 +118,7 @@ public class Example { * Use case 2: using simple KV mappings The table has structure is [ [id int, orgId int] // key [name varchar, lastName varchar, decimal * salary, int department] // value ]. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase2(Table t) { @@ -158,7 +158,7 @@ public class Example { * Use case 3: Single table strategy for inherited objects. The table has structure is [ [id long] // key [owner varchar, cardNumber * long, expYear int, expMonth int, accountNum long, bankName varchar] // value ] */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase3(Table t) { @@ -218,7 +218,7 @@ public class Example { * Use case 4: Conditional serialization. The table has structure is [ [id int, orgId int] // key [owner varchar, type int, * conditionalDetails byte[]] // value ] */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase4(Table t) { @@ -305,7 +305,7 @@ public class Example { * upgradedObject byte[], int department] // value ] Where {@code originalObject} is some value that was originally put to the column, * {@code upgradedObject} is a version 2 of the object, and department is an extracted field. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase5(Table t) { @@ -403,7 +403,7 @@ public class Example { * Use case 6: a simple one. The table has the structure [ [id long] // key [name varchar, lastName varchar, decimal salary, int * department] // value ] We show how to use the raw TableRow and a mapped class. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase6(Table t) { @@ -439,7 +439,7 @@ public class Example { * Use case 7: a simple one. The table has the structure [ [byte[]] // key [name varchar, lastName varchar, decimal salary, int * department] // value ] We show how to use the raw TableRow and a mapped class. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase7(Table t) { @@ -461,7 +461,7 @@ public class Example { /** * Use case 8: Here we show how to use mapper to represent the same data in different ways. */ - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") @ParameterizedTest @MethodSource("tableFactory") public void useCase8(Table t) { @@ -645,6 +645,9 @@ public class Example { * * @param t Table. */ + @Disabled("https://issues.apache.org/jira/browse/IGNITE-19300") + @ParameterizedTest + @MethodSource("tableFactory") public void useCase9(Table t) { // Now assume that we have some POJO classes to deserialize the binary objects. class Emploee { diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java index fd112d02e2..42dc2d44a8 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java @@ -106,7 +106,7 @@ public class TxLocalTest extends TxAbstractTest { tables.put(table2.groupId(), table2); } - @Disabled + @Disabled("https://issues.apache.org/jira/browse/IGNITE-15928") @Override public void testScan() throws InterruptedException { // TODO asch IGNITE-15928 implement local scan diff --git a/settings.gradle b/settings.gradle index 5cb7e03f00..bb26c8f131 100644 --- a/settings.gradle +++ b/settings.gradle @@ -69,6 +69,7 @@ include(':ignite-placement-driver-api') include(':ignite-code-deployment') include(':ignite-security') include(':ignite-catalog') +include(":ignite-arch-test") project(":ignite-examples").projectDir = file('examples') project(":ignite-page-memory").projectDir = file('modules/page-memory') @@ -123,6 +124,7 @@ project(":ignite-placement-driver-api").projectDir = file('modules/placement-dri project(":ignite-code-deployment").projectDir = file('modules/code-deployment') project(":ignite-security").projectDir = file('modules/security') project(":ignite-catalog").projectDir = file('modules/catalog') +project(":ignite-arch-test").projectDir = file('modules/arch-test') ext.isCiServer = System.getenv().containsKey("IGNITE_CI")