This is an automated email from the ASF dual-hosted git repository. echauchot pushed a commit to branch ci_utils in repository https://gitbox.apache.org/repos/asf/flink-connector-shared-utils.git
commit 5786a05331ec1916078c80117599869eccf0da37 Author: Etienne Chauchot <[email protected]> AuthorDate: Tue Nov 21 16:16:04 2023 +0100 [FLINK-34137] Add a simple non-violated test rule for production and test code and simplify dependencies --- module-with-no-tests/pom.xml | 1 + .../apache/flink/connector/testing/SomeClass.java | 4 +- ...bf549e => 09379350-830e-42a3-8b31-afde18cf1eb4} | 0 .../25d7c950-4d90-4419-b9af-78a9001796ce | 0 .../2c5e2ae5-0e19-423f-9501-d00b090b9d0e | 0 .../3e3429f1-b715-4057-91ce-f859c4c07245 | 0 .../662c8ab6-14a2-4f59-bacf-3e7a09427662 | 0 .../a2f52e44-eb11-4165-8a96-418e754ac1c6 | 0 .../b5a693ee-ab65-41b7-9764-cbe027c4ee12 | 0 .../f3351a4e-bc84-4164-aba1-3d729855e431 | 0 module-with-tests/archunit-violations/stored.rules | 11 +--- module-with-tests/pom.xml | 19 ++++++ .../connector/testing/SomeConnectorClass.java | 5 +- ...eClassTest.java => SomeConnectorClassTest.java} | 2 +- ...> ConnectorProductionCodeArchitectureTest.java} | 27 ++++---- ...java => ConnectorTestCodeArchitectureTest.java} | 25 ++++---- pom.xml | 75 ++++++++++------------ 17 files changed, 89 insertions(+), 80 deletions(-) diff --git a/module-with-no-tests/pom.xml b/module-with-no-tests/pom.xml index da0c156..ba65984 100644 --- a/module-with-no-tests/pom.xml +++ b/module-with-no-tests/pom.xml @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <parent> <groupId>org.apache.flink</groupId> <artifactId>test-project-parent</artifactId> diff --git a/module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java b/module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java similarity index 92% rename from module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java rename to module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java index f29e5e0..36da836 100644 --- a/module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java +++ b/module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass.java @@ -19,6 +19,4 @@ package org.apache.flink.connector.testing; /** A dummy class; only exists so that the compile/packaging plugins have something to do. */ -public class SomeClass { - public static void main(String[] args) {} -} +public class SomeClass {} diff --git a/module-with-tests/archunit-violations/1758f718-5b06-442d-8b5a-ad347bbf549e b/module-with-tests/archunit-violations/09379350-830e-42a3-8b31-afde18cf1eb4 similarity index 100% rename from module-with-tests/archunit-violations/1758f718-5b06-442d-8b5a-ad347bbf549e rename to module-with-tests/archunit-violations/09379350-830e-42a3-8b31-afde18cf1eb4 diff --git a/module-with-tests/archunit-violations/25d7c950-4d90-4419-b9af-78a9001796ce b/module-with-tests/archunit-violations/25d7c950-4d90-4419-b9af-78a9001796ce deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/2c5e2ae5-0e19-423f-9501-d00b090b9d0e b/module-with-tests/archunit-violations/2c5e2ae5-0e19-423f-9501-d00b090b9d0e deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/3e3429f1-b715-4057-91ce-f859c4c07245 b/module-with-tests/archunit-violations/3e3429f1-b715-4057-91ce-f859c4c07245 deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/662c8ab6-14a2-4f59-bacf-3e7a09427662 b/module-with-tests/archunit-violations/662c8ab6-14a2-4f59-bacf-3e7a09427662 deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/a2f52e44-eb11-4165-8a96-418e754ac1c6 b/module-with-tests/archunit-violations/a2f52e44-eb11-4165-8a96-418e754ac1c6 deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/b5a693ee-ab65-41b7-9764-cbe027c4ee12 b/module-with-tests/archunit-violations/b5a693ee-ab65-41b7-9764-cbe027c4ee12 deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/f3351a4e-bc84-4164-aba1-3d729855e431 b/module-with-tests/archunit-violations/f3351a4e-bc84-4164-aba1-3d729855e431 deleted file mode 100644 index e69de29..0000000 diff --git a/module-with-tests/archunit-violations/stored.rules b/module-with-tests/archunit-violations/stored.rules index e6fc6f1..bd30533 100644 --- a/module-with-tests/archunit-violations/stored.rules +++ b/module-with-tests/archunit-violations/stored.rules @@ -1,10 +1,3 @@ # -#Mon Nov 13 16:33:48 CET 2023 -Return\ and\ argument\ types\ of\ methods\ annotated\ with\ @Public\ must\ be\ annotated\ with\ @Public.=662c8ab6-14a2-4f59-bacf-3e7a09427662 -Connector\ production\ code\ must\ not\ depend\ on\ non-public\ API\ outside\ of\ connector\ packages=3e3429f1-b715-4057-91ce-f859c4c07245 -ITCASE\ tests\ should\ use\ a\ MiniCluster\ resource\ or\ extension=f3351a4e-bc84-4164-aba1-3d729855e431 -Production\ code\ must\ not\ call\ methods\ annotated\ with\ @VisibleForTesting=a2f52e44-eb11-4165-8a96-418e754ac1c6 -Tests\ inheriting\ from\ AbstractTestBase\ should\ have\ name\ ending\ with\ ITCase=b5a693ee-ab65-41b7-9764-cbe027c4ee12 -Options\ for\ connectors\ and\ formats\ should\ reside\ in\ a\ consistent\ package\ and\ be\ public\ API.=25d7c950-4d90-4419-b9af-78a9001796ce -Return\ and\ argument\ types\ of\ methods\ annotated\ with\ @PublicEvolving\ must\ be\ annotated\ with\ @Public(Evolving).=1758f718-5b06-442d-8b5a-ad347bbf549e -Classes\ in\ API\ packages\ should\ have\ at\ least\ one\ API\ visibility\ annotation.=2c5e2ae5-0e19-423f-9501-d00b090b9d0e +#Wed Nov 22 14:49:24 CET 2023 +classes\ that\ reside\ in\ a\ package\ 'org.apache.flink.connector..'\ should\ have\ simple\ name\ containing\ 'Connector'=09379350-830e-42a3-8b31-afde18cf1eb4 diff --git a/module-with-tests/pom.xml b/module-with-tests/pom.xml index c4e6084..75b9b02 100644 --- a/module-with-tests/pom.xml +++ b/module-with-tests/pom.xml @@ -11,4 +11,23 @@ <artifactId>module-with-tests</artifactId> + <dependencies> + + <dependency> + <groupId>com.tngtech.archunit</groupId> + <artifactId>archunit</artifactId> + </dependency> + + <dependency> + <groupId>com.tngtech.archunit</groupId> + <artifactId>archunit-junit5</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.flink</groupId> + <artifactId>flink-test-utils-junit</artifactId> + </dependency> + + </dependencies> + </project> diff --git a/module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass2.java b/module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeConnectorClass.java similarity index 92% rename from module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass2.java rename to module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeConnectorClass.java index 8429c55..7b9d700 100644 --- a/module-with-no-tests/src/main/java/org/apache/flink/connector/testing/SomeClass2.java +++ b/module-with-tests/src/main/java/org/apache/flink/connector/testing/SomeConnectorClass.java @@ -19,7 +19,4 @@ package org.apache.flink.connector.testing; /** A dummy class; only exists so that the compile/packaging plugins have something to do. */ -public class SomeClass2 { - - public static void main(String[] args) {} -} +public class SomeConnectorClass {} diff --git a/module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeClassTest.java b/module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeConnectorClassTest.java similarity index 96% rename from module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeClassTest.java rename to module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeConnectorClassTest.java index 57630b7..e8e11e6 100644 --- a/module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeClassTest.java +++ b/module-with-tests/src/test/java/org/apache/flink/connector/testing/SomeConnectorClassTest.java @@ -20,7 +20,7 @@ package org.apache.flink.connector.testing; import org.junit.jupiter.api.Test; -class SomeClassTest { +class SomeConnectorClassTest { @Test void someTest() {} diff --git a/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ProductionCodeArchitectureTest.java b/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorProductionCodeArchitectureTest.java similarity index 59% rename from module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ProductionCodeArchitectureTest.java rename to module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorProductionCodeArchitectureTest.java index 6f80e05..b7bc141 100644 --- a/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ProductionCodeArchitectureTest.java +++ b/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorProductionCodeArchitectureTest.java @@ -18,25 +18,30 @@ package org.apache.flink.connector.testing.architecture; -import org.apache.flink.architecture.ProductionCodeArchitectureBase; -import org.apache.flink.architecture.common.ImportOptions; - import com.tngtech.archunit.core.importer.ImportOption; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; -import com.tngtech.archunit.junit.ArchTests; +import com.tngtech.archunit.lang.ArchRule; +import com.tngtech.archunit.library.freeze.FreezingArchRule; + +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; -/** product code Architecture tests. */ +/** production code Architecture tests. */ @AnalyzeClasses( - packages = "org.apache.flink.connector", + packages = "org.apache.flink.connector.testing", importOptions = { ImportOption.DoNotIncludeTests.class, - ImportOption.DoNotIncludeArchives.class, - ImportOptions.ExcludeScalaImportOption.class, - ImportOptions.ExcludeShadedImportOption.class + ImportOption.DoNotIncludeArchives.class }) -public class ProductionCodeArchitectureTest { +public class ConnectorProductionCodeArchitectureTest { @ArchTest - public static final ArchTests COMMON_TESTS = ArchTests.in(ProductionCodeArchitectureBase.class); + // simple test rule that is not violated + public static final ArchRule SIMPLE_RULE = + FreezingArchRule.freeze( + classes() + .that() + .resideInAPackage("org.apache.flink.connector..") + .should() + .haveSimpleNameContaining("Connector")); } diff --git a/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/TestCodeArchitectureTest.java b/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorTestCodeArchitectureTest.java similarity index 63% rename from module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/TestCodeArchitectureTest.java rename to module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorTestCodeArchitectureTest.java index 5d8e4ed..ae495b5 100644 --- a/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/TestCodeArchitectureTest.java +++ b/module-with-tests/src/test/java/org/apache/flink/connector/testing/architecture/ConnectorTestCodeArchitectureTest.java @@ -18,24 +18,27 @@ package org.apache.flink.connector.testing.architecture; -import org.apache.flink.architecture.TestCodeArchitectureTestBase; -import org.apache.flink.architecture.common.ImportOptions; - import com.tngtech.archunit.core.importer.ImportOption; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; -import com.tngtech.archunit.junit.ArchTests; +import com.tngtech.archunit.lang.ArchRule; +import com.tngtech.archunit.library.freeze.FreezingArchRule; + +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; /** Architecture tests for test code. */ @AnalyzeClasses( packages = {"org.apache.flink.connector.testing"}, - importOptions = { - ImportOption.OnlyIncludeTests.class, - ImportOptions.ExcludeScalaImportOption.class, - ImportOptions.ExcludeShadedImportOption.class - }) -public class TestCodeArchitectureTest { + importOptions = {ImportOption.OnlyIncludeTests.class}) +public class ConnectorTestCodeArchitectureTest { @ArchTest - public static final ArchTests COMMON_TESTS = ArchTests.in(TestCodeArchitectureTestBase.class); + // simple test rule that is not violated + public static final ArchRule SIMPLE_RULE = + FreezingArchRule.freeze( + classes() + .that() + .resideInAPackage("org.apache.flink.connector..") + .should() + .haveSimpleNameContaining("Connector")); } diff --git a/pom.xml b/pom.xml index 6fbeb01..046c5e1 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ under the License. <artifactId>flink-connector-parent</artifactId> <version>1.0.0</version> </parent> + <modules> <module>module-with-no-tests</module> <module>module-with-tests</module> @@ -39,6 +40,8 @@ under the License. <properties> <flink.version>1.17.1</flink.version> <japicmp.referenceVersion>1.16.0</japicmp.referenceVersion> + <archunit.version>1.0.0</archunit.version> + <slf4j.version>1.7.36</slf4j.version> </properties> <dependencies> @@ -47,55 +50,45 @@ under the License. <artifactId>flink-core</artifactId> <version>${flink.version}</version> </dependency> - <dependency> - <groupId>org.apache.flink</groupId> - <artifactId>flink-test-utils-junit</artifactId> - <version>${flink.version}</version> - <scope>test</scope> - <!-- for dependency convergence --> - <exclusions> - <exclusion> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - </exclusion> - </exclusions> - </dependency> - - <!-- ArchUit test dependencies --> - <dependency> - <groupId>org.apache.flink</groupId> - <artifactId>flink-architecture-tests-test</artifactId> - <version>${flink.version}</version> - <scope>test</scope> - <!-- for dependency convergence --> - <exclusions> - <exclusion> - <groupId>com.esotericsoftware.kryo</groupId> - <artifactId>kryo</artifactId> - </exclusion> - <exclusion> - <groupId>org.junit.platform</groupId> - <artifactId>junit-platform-engine</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.flink</groupId> - <artifactId>flink-architecture-tests-production</artifactId> - <version>${flink.version}</version> - <scope>test</scope> - </dependency> - </dependencies> <dependencyManagement> <dependencies> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>1.7.36</version> + <version>${slf4j.version}</version> </dependency> + + <dependency> + <groupId>org.apache.flink</groupId> + <artifactId>flink-test-utils-junit</artifactId> + <version>${flink.version}</version> + <scope>test</scope> + <!-- for dependency convergence --> + <exclusions> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>com.tngtech.archunit</groupId> + <artifactId>archunit</artifactId> + <version>${archunit.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.tngtech.archunit</groupId> + <artifactId>archunit-junit5</artifactId> + <version>${archunit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> </dependencyManagement>
