Skip to content

Remove JUnit4 dependency from Flink #12937

Open
@nastra

Description

@nastra

Feature Request / Improvement

I started removing JUnit4 from Flink via the below diff

diff --git a/flink/v2.0/build.gradle b/flink/v2.0/build.gradle
index c0de408e98..ef4635e133 100644
--- a/flink/v2.0/build.gradle
+++ b/flink/v2.0/build.gradle
@@ -68,7 +68,9 @@ project(":iceberg-flink:iceberg-flink-${flinkMajorVersion}") {

     implementation libs.datasketches

-    testImplementation libs.flink20.connector.test.utils
+    testImplementation(libs.flink20.connector.test.utils) {
+      exclude group: 'junit'
+    }
     testImplementation libs.flink20.core
     testImplementation libs.flink20.runtime
     testImplementation(libs.flink20.test.utilsjunit) {
diff --git a/flink/v2.0/flink/src/test/java/org/apache/iceberg/flink/sink/TestIcebergSink.java b/flink/v2.0/flink/src/test/java/org/apache/iceberg/flink/sink/TestIcebergSink.java
index b02b3337dc..362d004cfe 100644
--- a/flink/v2.0/flink/src/test/java/org/apache/iceberg/flink/sink/TestIcebergSink.java
+++ b/flink/v2.0/flink/src/test/java/org/apache/iceberg/flink/sink/TestIcebergSink.java
@@ -21,6 +21,7 @@ package org.apache.iceberg.flink.sink;
 import static org.apache.iceberg.flink.TestFixtures.DATABASE;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assumptions.assumeThat;

 import java.io.IOException;
 import java.util.Collections;
@@ -55,7 +56,6 @@ import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.relocated.com.google.common.collect.Maps;
 import org.apache.iceberg.types.Types;
-import org.junit.Assume;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.TestTemplate;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -421,8 +421,9 @@ public class TestIcebergSink extends TestFlinkIcebergSinkBase {

   @TestTemplate
   void testErrorOnNullForRequiredField() throws Exception {
-    Assume.assumeFalse(
-        "ORC file format supports null values even for required fields.", format == FileFormat.ORC);
+    assumeThat(format)
+        .as("ORC file format supports null values even for required fields.")
+        .isEqualTo(FileFormat.ORC);

However, there is still TestIcebergSourceFailover that uses MiniClusterWithClientResource which requires JUnit4. This would be good to convert so that we can eventually remove all JUnit4 dependencies across the codebase.
We would also need to backport the fix to Flink 1.20 & 1.19.

Query engine

None

Willingness to contribute

  • I can contribute this improvement/feature independently
  • I would be willing to contribute this improvement/feature with guidance from the Iceberg community
  • I cannot contribute this improvement/feature at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersimprovementPR that improves existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions