Skip to content

Port windowing tests off WindowFnTestUtils.runWindowFn - #41724

Open
harshilv17 wants to merge 2 commits into
apache:masterfrom
harshilv17:fix/18458-windowfn-tests-off-runwindowfn
Open

harshilv17 wants to merge 2 commits into
apache:masterfrom
harshilv17:fix/18458-windowfn-tests-off-runwindowfn

Conversation

@harshilv17

Copy link
Copy Markdown
Contributor

Fixes #18458.

Ports the windowing tests off WindowFnTestUtils.runWindowFn, whose expected maps of windows to "T<timestamp>" strings made it hard to see what each test checks.

  • FixedWindowsTest, SlidingWindowsTest, CalendarWindowsTest: each test now asserts the windows assignedWindows returns for each timestamp. Timestamps that land in no window, like 3, 5 and 9 in SlidingWindowsTest.testElidings, are now asserted explicitly; the old map could only leave them out.
  • SessionsTest: merging is the behavior under test, so it keeps a small local helper that assigns each timestamp, merges after each one, and returns the sessions with the timestamps they hold, compared against an ImmutableMap of windows to timestamps.
  • runWindowFn, runWindowFnWithValue and set are public in beam-sdks-java-core, so they are marked @Deprecated (pointing at assignedWindows) rather than removed. No other module uses them.

The expected windows are the same as before: the per-timestamp assertions were generated from the old expected maps.

Ran FixedWindowsTest, SlidingWindowsTest, CalendarWindowsTest and SessionsTest (42 tests) locally with JDK 17; spotlessCheck, checkstyleMain and checkstyleTest are clean. Changing an expected window, or the timestamps of a session, makes the matching test fail.

  • Small/focused contribution (ICLA not required).
  • Mentions the issue (Fixes #18458).
  • CHANGES.md: deprecation entry added.

FixedWindowsTest, SlidingWindowsTest and CalendarWindowsTest now assert
the windows each timestamp is assigned to with assignedWindows, so each
test states where a timestamp lands, including timestamps that land in
no window. SessionsTest keeps a small local helper that merges after
each assignment, since merging is what it tests.

runWindowFn, runWindowFnWithValue and set are public in
beam-sdks-java-core, so they are deprecated rather than removed.

Fixes apache#18458

@github-actions github-actions Bot 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.

📋 Review Summary

This PR cleanly migrates FixedWindowsTest, SlidingWindowsTest, CalendarWindowsTest, and SessionsTest off WindowFnTestUtils.runWindowFn and deprecates the legacy helper methods in WindowFnTestUtils to address #18458. The refactored tests are much easier to read and explicitly assert edge cases (such as unassigned timestamps in SlidingWindowsTest.testElidings).

🔍 General Feedback

  • All expected window boundaries and assigned timestamps match the previous test cases while making the per-timestamp window assignments clear and direct.
  • Deprecating runWindowFn, runWindowFnWithValue, and set in WindowFnTestUtils (with a corresponding CHANGES.md entry) appropriately preserves public API compatibility in beam-sdks-java-core.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot added java core size/l L: 250-999 lines changed labels Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
Backup reviewer: chamikaramj (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

This pull request likely touches a core component ("core" label). Please review with scrutiny.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

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.

WindowFnTestUtils#runWindowFn should be removed

1 participant