Skip to content

[FLINK-39124][test] Migrate remaining flink-tests to JUnit 5#27669

Merged
RocMarshal merged 6 commits intoapache:masterfrom
mateczagany:FLINK-39124-5
Apr 13, 2026
Merged

[FLINK-39124][test] Migrate remaining flink-tests to JUnit 5#27669
RocMarshal merged 6 commits intoapache:masterfrom
mateczagany:FLINK-39124-5

Conversation

@mateczagany
Copy link
Copy Markdown
Contributor

What is the purpose of the change

Migrate some of the tests in module flink-tests from JUnit4 to JUnit5.

Brief change log

  • Migrate all test cases to use JUnit5.
  • Update all assertions to assertThat()
  • Limit scope for test classes where possible
  • Restrict visibility of fields where possible
  • Remove @SuppressWarnings where it was unnecessary

Verifying this change

  • I ran each updated tests one by one after migrating them
  • CI should pass

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@mateczagany mateczagany marked this pull request as draft February 25, 2026 07:49
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Feb 25, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@mateczagany mateczagany force-pushed the FLINK-39124-5 branch 2 times, most recently from 049115c to e29e50e Compare February 25, 2026 15:53
@RocMarshal RocMarshal self-assigned this Feb 26, 2026
@mateczagany mateczagany marked this pull request as ready for review February 26, 2026 16:17
Comment on lines 83 to 89
@@ -84,12 +84,12 @@ public String map(String value) throws Exception {
env.execute();
fail("this should fail due to null values.");
} catch (JobExecutionException e) {
assertTrue(findThrowable(e, NullPointerException.class).isPresent());
assertThat(findThrowable(e, NullPointerException.class)).isPresent();
}
}
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.

can we replace it with something like

        assertThatThrownBy(env::execute)
                .isInstanceOf(JobExecutionException.class)
                .hasRootCauseInstanceOf(NullPointerException.class);

same for other try catches in this PR

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.

Thank you, I've updated this and each other instance I found in the updated files. I also tried to look for other cases where improvement could be made.

.contains("broken serialization."))
.isPresent());
}
@Disabled("TODO: This needs to be investigated why no exception is thrown.")
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.

During rewriting this test, I found that these test cases don't even check if the exception is thrown. Only the 2nd test passes, so I've disabled the others.

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Mar 4, 2026
@RocMarshal
Copy link
Copy Markdown
Contributor

FYI, It would be better to merge it after #27902.

IntCounter simpleCounter = getRuntimeContext().getIntCounter("simple-counter");
simpleCounter.add(1);
Assert.assertEquals(simpleCounter.getLocalValue().intValue(), 1);
assertThat(simpleCounter.getLocalValue().intValue()).isEqualTo(1);
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.

Suggested change
assertThat(simpleCounter.getLocalValue().intValue()).isEqualTo(1);
assertThat(simpleCounter.getLocalValue().intValue()).isOne();

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.

Thank you for the comments! I've applied your suggestions, and rebased on the latest master, which already contains #27902

Sorry about that bug!

@RocMarshal
Copy link
Copy Markdown
Contributor

Reopen for triggering CI.

@RocMarshal RocMarshal closed this Apr 12, 2026
@RocMarshal RocMarshal reopened this Apr 12, 2026
@RocMarshal
Copy link
Copy Markdown
Contributor

@flinkbot run azure

@RocMarshal
Copy link
Copy Markdown
Contributor

Hi, @mateczagany The CI was failed.
Would you mind helping take a look or re-triggering the CI ?

@mateczagany
Copy link
Copy Markdown
Contributor Author

@flinkbot run azure

Copy link
Copy Markdown
Contributor

@RocMarshal RocMarshal left a comment

Choose a reason for hiding this comment

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

Thanks @mateczagany

@RocMarshal RocMarshal merged commit 43f81d3 into apache:master Apr 13, 2026
@RocMarshal
Copy link
Copy Markdown
Contributor

Hi, @mateczagany
I found a few of lines un-related to the migration need some minor polish during the review of the current PR.
And created a mini patch to follow it, Could you help take a look ?
Thank you~

#27910

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

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants