Skip to content

[FLINK-39769][tests][JUnit5 migration] Module: flink-examples-streaming#28496

Open
spuru9 wants to merge 2 commits into
apache:masterfrom
spuru9:FLINK-39769
Open

[FLINK-39769][tests][JUnit5 migration] Module: flink-examples-streaming#28496
spuru9 wants to merge 2 commits into
apache:masterfrom
spuru9:FLINK-39769

Conversation

@spuru9

@spuru9 spuru9 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Migrate the remaining JUnit 4 tests in flink-examples/flink-examples-streaming to JUnit 5 (Jupiter). After this PR the module has zero JUnit 4 imports. Part of the umbrella JUnit 4 → 5 migration.

JIRA: FLINK-39769 (sub-task of FLINK-25325)

Brief change log

Three test classes migrated:

  • StreamingExamplesITCase and SocketWindowWordCountITCase (parameterized on asyncState):
    • @RunWith(Parameterized.class) → native JUnit 5 @ParameterizedTest + @ValueSource(booleans = {false, true}); the boolean arrives as a method argument rather than an injected field.
    • In StreamingExamplesITCase, only testWindowWordCount and testWordCount actually read asyncState, so only those are parameterized; testWindowJoin and testSessionWindowing become plain @Test instead of running redundantly under both values.
    • extends AbstractTestBaseJUnit4extends AbstractTestBase (the JUnit 5 sibling).
    • org.junit.Assert.failorg.assertj.core.api.Assertions.fail (SocketWindowWordCountITCase).
  • TopSpeedWindowingExampleITCase:
    • @ClassRule MiniClusterWithClientResource@RegisterExtension static MiniClusterExtension.
    • @ClassRule TemporaryFolder@TempDir static File; newFile()/newFolder()new File(tempDir, ...).
    • Drop extends TestLogger; org.junit.Testorg.junit.jupiter.api.Test.
  • Drop public on test classes and methods per the Flink JUnit 5 Migration Guide.

No production code is touched.

Verifying this change

This change is a test-only migration covered by the existing tests it migrates:

./mvnw -pl flink-examples/flink-examples-streaming test \
  -Dtest='StreamingExamplesITCase,TopSpeedWindowingExampleITCase,SocketWindowWordCountITCase'

Result: 9 tests run, 0 failures, 0 errors, 0 skipped (StreamingExamplesITCase 6, SocketWindowWordCountITCase 2, TopSpeedWindowingExampleITCase 1).

StreamingExamplesITCase runs 6 rather than the previous 8: testWindowJoin and testSessionWindowing never read asyncState, so they no longer execute once per value. No coverage is lost — the dropped runs were identical.

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)

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code

@flinkbot

flinkbot commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

CI report:

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

@spuru9

spuru9 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

cc: @raminqaf @snuyanzin Can you review this PR as well on JUnit5 migration.

Comment on lines 48 to 54
@Parameter private boolean asyncState;

@Parameterized.Parameters
public static Collection<Boolean> setup() {
return Arrays.asList(false, true);
@Parameters(name = "asyncState: {0}")
public static List<Boolean> parameters() {
return List.of(false, true);
}

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.

why do we need it?

can we just use

@ParameterizedTest
@Values(true, false)

?

same for others

…examples-streaming

Migrate the remaining JUnit 4 tests in flink-examples-streaming to JUnit 5:

- StreamingExamplesITCase and SocketWindowWordCountITCase: replace
  @RunWith(Parameterized.class) with native JUnit 5 @ParameterizedTest +
  @valuesource on the tests that read asyncState, and move the base class
  from AbstractTestBaseJUnit4 to AbstractTestBase. In StreamingExamplesITCase
  the two tests that don't use asyncState become plain @test.
- TopSpeedWindowingExampleITCase: drop TestLogger and replace the @ClassRule
  MiniClusterWithClientResource / TemporaryFolder with @RegisterExtension
  MiniClusterExtension and @tempdir.
- Convert the remaining org.junit.Assert.fail to AssertJ.
@spuru9

spuru9 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Done — switched both to native @ParameterizedTest + @ValueSource(booleans = {false, true}). I'd originally reached for ParameterizedTestExtension since it's the migration guide's drop-in for @RunWith(Parameterized.class), but you're right that native parameterization is cleaner here. Thanks!

@spuru9 spuru9 requested a review from snuyanzin June 22, 2026 18:22

/** Tests for {@link TopSpeedWindowing}. */
public class TopSpeedWindowingExampleITCase extends TestLogger {
class TopSpeedWindowingExampleITCase {

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.

why logger just disapeared?

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.

Fixed. Added the extension file taking reference from #19716,
Didnt add test-jar exclude, nothing consumes this module's test-jar, let me know if we want to add it for caution or another reason.

…for flink-examples-streaming

Restores per-test logging after dropping `extends TestLogger` in the JUnit5
migration; matches the pattern used by other migrated modules. No test-jar
exclude needed since this module's test-jar is not consumed elsewhere.
@spuru9 spuru9 requested a review from snuyanzin June 22, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants