Skip to content

Flink: Remove the MiniClusterWithClientResource dependency - #13021

Merged
pvary merged 5 commits into
apache:mainfrom
JeonDaehong:main
May 23, 2025
Merged

pvary merged 5 commits into
apache:mainfrom
JeonDaehong:main

Conversation

@JeonDaehong

Copy link
Copy Markdown
Contributor

Hello,

Regarding issue #12937, I am submitting a PR for v2.0 first.

I have removed the MiniClusterWithClientResource class, which was still dependent on JUnit4, and have also incorporated changes to the gradle and TestIcebergSink classes.

To build the project, it was necessary to modify the GenericAppenderHelper.java file.

Could you please provide feedback on this? If everything looks good, kindly approve the merge.

If this approach is correct and the merge is complete, I will proceed with backporting to versions 1.20 & 1.19 and submit a PR for those as well.

(I have completed the formatting and build as per the feedback provided on the previously closed PR.)

#12937

…( remove @deprecated annotations no longer needed after JUnit5 migration )
@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@nastra
Hello,
I've reopened the PR after incorporating the feedback you provided.
Thank you!

@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@tomtongue

Hello,
Apologies for the repeated question.....

I successfully ran ./gradlew spotlessApply and ./gradlew build -x test -x integrationTest, and then submitted a pull request.

However, the CI/CD pipeline is showing a failure. Is there possibly something wrong?

Should I have run ./gradlew build completely before submitting the PR, or should I wait for feedback from the maintainer?

I would sincerely appreciate any feedback regarding this and the code I submitted in the PR.

Thank you.

@tomtongue

tomtongue commented May 12, 2025 •

Copy link
Copy Markdown
Contributor

@tomtongue

Hello, Apologies for the repeated question.....

I successfully ran ./gradlew spotlessApply and ./gradlew build -x test -x integrationTest, and then submitted a pull request.

However, the CI/CD pipeline is showing a failure. Is there possibly something wrong?

Should I have run ./gradlew build completely before submitting the PR, or should I wait for feedback from the maintainer?

I would sincerely appreciate any feedback regarding this and the code I submitted in the PR.

Thank you.

The -x option in ./gradlew build -x test -x integrationTest skips the unit and integration tests. So if you check whether your changes works well on your local, please set a specific test first, like./gradlew :iceberg-flink:iceberg-flink-2.0:test --tests "org.apache.iceberg.flink.source.TestIcebergSourceFailover" etc. Then, run the whole or relevant flink tests.

And, Spark CI failure looks hitting #12889. You can check the error reason on your local or the CI runs. For the flink test, the test lookup seems to fail.

void testErrorOnNullForRequiredField() throws Exception {
Assume.assumeFalse(
"ORC file format supports null values even for required fields.", format == FileFormat.ORC);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Plese remove this line.

Comment thread flink/v2.0/build.gradle Resolved
@nastra

nastra commented May 12, 2025

Copy link
Copy Markdown
Contributor

@JeonDaehong can you please remove the dependency in

testImplementation libs.junit.vintage.engine
?

throws Exception {
MiniClusterWithClientResource miniCluster = null;
try {
miniCluster = new MiniClusterWithClientResource(MINI_CLUSTER_RESOURCE_CONFIG);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to also inject MINI_CLUSTER_RESOURCE_CONFIG?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nastra I believe the MiniClusterExtension with the @RegisterExtension annotation sets the configuration to miniCluster via the @InjectMiniCluster annotation when I checked it (if I'm wrong, please correct me)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue is that the tests are timing out now without the config:

TestIcebergSourceFailover > testBoundedWithJobManagerFailover(MiniCluster) FAILED
    java.util.concurrent.TimeoutException: testBoundedWithJobManagerFailover(org.apache.flink.runtime.minicluster.MiniCluster) timed out after 120 seconds
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

TestIcebergSourceFailover > testBoundedWithTaskManagerFailover(MiniCluster) FAILED
    java.util.concurrent.TimeoutException: testBoundedWithTaskManagerFailover(org.apache.flink.runtime.minicluster.MiniCluster) timed out after 120 seconds
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

TestIcebergSourceFailoverWithWatermarkExtractor > testBoundedWithJobManagerFailover(MiniCluster) FAILED
    java.util.concurrent.TimeoutException: testBoundedWithJobManagerFailover(org.apache.flink.runtime.minicluster.MiniCluster) timed out after 120 seconds
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

TestIcebergSourceFailoverWithWatermarkExtractor > testBoundedWithTaskManagerFailover(MiniCluster) FAILED
    java.util.concurrent.TimeoutException: testBoundedWithTaskManagerFailover(org.apache.flink.runtime.minicluster.MiniCluster) timed out after 120 seconds
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
[IOManagerAsync shutdown hook] INFO org.apache.flink.runtime.io.disk.FileChannelManagerImpl - FileChannelManager removed spill file directory /tmp/flink-io-64570821-dedb-45dd-8180-5da4be9b26ac

@tomtongue tomtongue May 12, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, from my checking, I think the same mini cluster is used for task bounded and task contiunuous tests (as same as job manager tests). When I only run testBoundedWithTaskManagerFailover, it succeeds, but when I run testBoundedWithTaskManagerFailover and testContinuousWithTaskManagerFailover in the same test run, the testContinuousWithTaskManagerFailover is timed out.
For now, the numer of TaskManager is set to 1, so it seems that the other TaskManager failover test waits until the other TaskManager test releases its task manager. When I set the task manager number to 2, both tests for TaskManager succeed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nastra What do you think about adding this cluster start and close for each test?

  @BeforeEach
  protected void startMiniCluster(@InjectMiniCluster MiniCluster miniCluster) throws Exception {
    if (!miniCluster.isRunning()) {
      miniCluster.start();
    }
  }

  @AfterEach
  protected void stopMiniCluster(@InjectMiniCluster MiniCluster miniCluster) throws Exception {
    miniCluster.close();
  }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nastra

Since this is my first contribution, everything feels quite difficult...

I’m really sorry to keep asking questions, but I would really appreciate a bit more guidance.

From what I’ve checked, most of the code has already been migrated to JUnit 5. I'm currently a bit unsure about what exactly I should be working on (I’m struggling to figure out the right direction).

My understanding was that I should update the code so that the project can be built even after removing testImplementation libs.junit.vintage.engine from the Flink-related Gradle configuration. But now I’m wondering if I may have misunderstood something.

Since it’s my first contribution, I really want to do a good job — I’m sorry again for asking so many questions…! 😢

@nastra nastra May 16, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeonDaehong no worries at all. Basically your change here makes sense and we should get it in once tests are passing (they were timing out for me locally). The idea was also to exclude JUnit 4 from the Flink testing dependencies but I don't think this is currently possible, which you've already seen via the error in #13021 (comment).

Everything else was already handled in #12938 and I've opened #13049 as a long-term goal that we'd eventually like to have (but that's quite difficult right now because there are still some dependencies that pull in JUnit4 themselves)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nastra

Thank you for your response ! :D

In that case, should I leave the PR open as it is and wait, or would it be better for me to make additional changes to ensure the tests pass? 🤔

Also, regarding the issue of JUnit 4 dependencies being pulled in, I’ll continue to work on it as a long-term goal and discuss it further with the community going forward !! 😁

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeonDaehong it would be great to make the Flink tests pass (they are currently timing out due to the change in this PR). Without passing tests we won't be able to merge this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nastra
Thank you very much for your kind feedback and for patiently answering all my questions, especially since this is my first time contributing.

I now understand that the changes I made are causing the timeout issues in the Flink tests, and that I’ll need to address them directly to make the tests pass before the PR can be merged.

I’ll make the necessary fixes and submit an updated PR soon.
Thank you again for your support!

@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@nastra @tomtongue

Thank you both very much for your valuable feedback.

I will proceed with running the necessary tests and resubmit the PR once the build succeeds using ./gradlew build.

@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@nastra

Hello !
I’ve added the necessary code and successfully completed the build test in the local environment.
Please review it at your convenience.
Thank you! :D

@nastra
nastra requested a review from pvary May 21, 2025 14:36
@JeonDaehong

Copy link
Copy Markdown
Contributor Author

Thank you !

@nastra

nastra commented May 22, 2025

Copy link
Copy Markdown
Contributor

@pvary could you please take a look as well?

@mxm mxm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Guosmilesmile Guosmilesmile left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's about use @InjectMiniCluster to removing the MiniClusterWithClientResource . LGTM . Soft +1.

@nastra

nastra commented May 23, 2025

Copy link
Copy Markdown
Contributor

@JeonDaehong can you please backport the change to earlier Flink versions?

@JeonDaehong

JeonDaehong commented May 23, 2025 •

Copy link
Copy Markdown
Contributor Author

@JeonDaehong can you please backport the change to earlier Flink versions?

@nastra
Thank you all for the positive feedback! :D

Should I apply the same backport to versions 1.19 and 1.20 and push the changes to this PR?

Or will this PR be merged as-is, and I should open separate PRs for the backports?

@nastra

nastra commented May 23, 2025

Copy link
Copy Markdown
Contributor

@JeonDaehong you can do the backports as part of this PR

@JeonDaehong

Copy link
Copy Markdown
Contributor Author

@JeonDaehong you can do the backports as part of this PR

Yes, understood!

If it's possible to merge first, please go ahead and merge it.
If not, I’ll add the backports to this PR.

The backporting won’t take much time.

Thank you so much for all your help! :D

@pvary
pvary merged commit d32ba35 into apache:main May 23, 2025
@pvary

pvary commented May 23, 2025

Copy link
Copy Markdown
Contributor

Merged to main.
Thanks @JeonDaehong for the PR and @nastra, @tomtongue, @Guosmilesmile and @mxm for the review!

@JeonDaehong please proceed with the backport

@pvary pvary changed the title Flink 2.0: Remove the JUnit4 dependency Flink: Remove the MiniClusterWithClientResource dependency May 23, 2025
@JeonDaehong

Copy link
Copy Markdown
Contributor Author

Merged to main. Thanks @JeonDaehong for the PR and @nastra, @tomtongue, @Guosmilesmile and @mxm for the review!

@JeonDaehong please proceed with the backport

Thank you for merging the PR.
I'll proceed with the backporting shortly and submit a follow-up PR soon. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants