You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2022/04/07 19:25:07 UTC

[flink] 06/12: [FLINK-26011][hadoop-bulk][test] add ArchUnit tests for the test code

This is an automated email from the ASF dual-hosted git repository.

martijnvisser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 1617c56e6cf727f4cf03400709741579d3c9e09a
Author: Jing Ge <ge...@gmail.com>
AuthorDate: Mon Apr 4 17:08:51 2022 +0200

    [FLINK-26011][hadoop-bulk][test] add ArchUnit tests for the test code
---
 .../83371291-f688-4eaf-a207-24981f1067f3           |  3 ++
 .../db4de53e-d09e-4fb0-bdbc-429c1b64686f           |  0
 .../archunit-violations/stored.rules               |  4 ++
 flink-formats/flink-hadoop-bulk/pom.xml            |  8 ++++
 .../architecture/TestCodeArchitectureTest.java     | 43 ++++++++++++++++++++++
 .../src/test/resources/archunit.properties         | 31 ++++++++++++++++
 6 files changed, 89 insertions(+)

diff --git a/flink-formats/flink-hadoop-bulk/archunit-violations/83371291-f688-4eaf-a207-24981f1067f3 b/flink-formats/flink-hadoop-bulk/archunit-violations/83371291-f688-4eaf-a207-24981f1067f3
new file mode 100644
index 00000000000..478fde0985b
--- /dev/null
+++ b/flink-formats/flink-hadoop-bulk/archunit-violations/83371291-f688-4eaf-a207-24981f1067f3
@@ -0,0 +1,3 @@
+simple name of org.apache.flink.formats.hadoop.bulk.HadoopPathBasedPartFileWriterTest does not end with 'ITCase' in (HadoopPathBasedPartFileWriterTest.java:0)
+simple name of org.apache.flink.formats.hadoop.bulk.committer.HadoopRenameCommitterHDFSTest does not end with 'ITCase' in (HadoopRenameCommitterHDFSTest.java:0)
+simple name of org.apache.flink.formats.hadoop.bulk.committer.HadoopRenameCommitterLocalFSTest does not end with 'ITCase' in (HadoopRenameCommitterLocalFSTest.java:0)
\ No newline at end of file
diff --git a/flink-formats/flink-hadoop-bulk/archunit-violations/db4de53e-d09e-4fb0-bdbc-429c1b64686f b/flink-formats/flink-hadoop-bulk/archunit-violations/db4de53e-d09e-4fb0-bdbc-429c1b64686f
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/flink-formats/flink-hadoop-bulk/archunit-violations/stored.rules b/flink-formats/flink-hadoop-bulk/archunit-violations/stored.rules
new file mode 100644
index 00000000000..1eda729c68f
--- /dev/null
+++ b/flink-formats/flink-hadoop-bulk/archunit-violations/stored.rules
@@ -0,0 +1,4 @@
+#
+#Mon Apr 04 16:58:50 CEST 2022
+Tests\ inheriting\ from\ AbstractTestBase\ should\ have\ name\ ending\ with\ ITCase=83371291-f688-4eaf-a207-24981f1067f3
+ITCASE\ tests\ should\ use\ a\ MiniCluster\ resource\ or\ extension=db4de53e-d09e-4fb0-bdbc-429c1b64686f
diff --git a/flink-formats/flink-hadoop-bulk/pom.xml b/flink-formats/flink-hadoop-bulk/pom.xml
index 1ebf8569b67..90c1d4a76ed 100644
--- a/flink-formats/flink-hadoop-bulk/pom.xml
+++ b/flink-formats/flink-hadoop-bulk/pom.xml
@@ -117,6 +117,14 @@ under the License.
 				</exclusion>
 			</exclusions>
 		</dependency>
+
+		<!-- ArchUit test dependencies -->
+
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-architecture-tests-test</artifactId>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>
diff --git a/flink-formats/flink-hadoop-bulk/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java b/flink-formats/flink-hadoop-bulk/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java
new file mode 100644
index 00000000000..5db07db9b21
--- /dev/null
+++ b/flink-formats/flink-hadoop-bulk/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.flink.architecture;
+
+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;
+
+/** Architecture tests for test code. */
+@AnalyzeClasses(
+        packages = {
+            "org.apache.flink.formats.hadoop.bulk",
+            "org.apache.flink.streaming.api.functions.sink.filesystem"
+        },
+        importOptions = {
+            ImportOption.OnlyIncludeTests.class,
+            ImportOptions.ExcludeScalaImportOption.class,
+            ImportOptions.ExcludeShadedImportOption.class
+        })
+public class TestCodeArchitectureTest {
+
+    @ArchTest
+    public static final ArchTests COMMON_TESTS = ArchTests.in(TestCodeArchitectureTestBase.class);
+}
diff --git a/flink-formats/flink-hadoop-bulk/src/test/resources/archunit.properties b/flink-formats/flink-hadoop-bulk/src/test/resources/archunit.properties
new file mode 100644
index 00000000000..15be88c95ba
--- /dev/null
+++ b/flink-formats/flink-hadoop-bulk/src/test/resources/archunit.properties
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+# By default we allow removing existing violations, but fail when new violations are added.
+freeze.store.default.allowStoreUpdate=true
+
+# Enable this if a new (frozen) rule has been added in order to create the initial store and record the existing violations.
+#freeze.store.default.allowStoreCreation=true
+
+# Enable this to add allow new violations to be recorded.
+# NOTE: Adding new violations should be avoided when possible. If the rule was correct to flag a new
+#       violation, please try to avoid creating the violation. If the violation was created due to a
+#       shortcoming of the rule, file a JIRA issue so the rule can be improved.
+#freeze.refreeze=true
+
+freeze.store.default.path=archunit-violations