Skip to content

Port RampupThrottlingFnTest and SplitQueryFnIT off DoFnTester - #41730

Open
harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/41729-datastore-off-dofntester
Open

harshilv17 wants to merge 1 commit into
apache:masterfrom
harshilv17:fix/41729-datastore-off-dofntester

Conversation

@harshilv17

Copy link
Copy Markdown
Contributor

Fixes #41729.

Ports the last two Datastore tests in sdks/java/io/google-cloud-platform off the deprecated DoFnTester.

TestPipeline doesn't fit RampupThrottlingFnTest: the test fixes the Joda clock, injects a sleeper and a Mockito counter that can't be serialized, and checks how many elements of one bundle go through before the fn throttles. So, like the DatastoreV1Test port (#40866), it now runs RampupThrottlingFn through DoFnRunners.simpleRunner. What differs from that helper:

  • The fn reads a side input, so the runner gets a small SideInputReader that returns the fixed start time for the start-time view.
  • simpleRunner doesn't call @Setup, so the test calls setup() itself and then injects the sleeper and counter. This replaces the anonymous subclass that overrode setup().
  • simpleRunner wraps user exceptions in UserCodeException, so the throttling check now asserts a UserCodeException caused by RampupDelayException.

The rampup schedule and the expected counts are unchanged.

SplitQueryFnIT now uses TestPipeline + PAssert: Create the query, ParDo(SplitQueryFn), Count.globally(), and PAssert.thatSingleton on the expected number of splits, once without and once with readTime.

Ran locally (JDK 17): RampupThrottlingFnTest passes. I also changed one expected count to check the test fails, then reverted it. compileTestJava, checkstyleTest and spotlessApply are clean. SplitQueryFnIT needs real Datastore in apache-beam-testing, so I only compiled it.

  • Small/focused contribution (ICLA not required).
  • Mentions the issue (Fixes #41729).
  • CHANGES.md: not needed, test-only change.

RampupThrottlingFnTest fixes the Joda clock, injects a non-serializable
sleeper and counter, and checks throttling between elements of one
bundle, so it now runs the fn in-process through DoFnRunners.simpleRunner
(as DatastoreV1Test does) with a SideInputReader for the start time. It
calls setup() itself and expects the RampupDelayException wrapped in a
UserCodeException. The schedule and expected counts are unchanged.

SplitQueryFnIT now uses TestPipeline and PAssert to check the number of
splits, with and without readTime.

Fixes apache#41729
@github-actions github-actions Bot added java io gcp size/m M: 50-249 lines changed labels Nov 28, 2026

@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 RampupThrottlingFnTest and SplitQueryFnIT off the deprecated DoFnTester to DoFnRunners.simpleRunner and TestPipeline/PAssert respectively. The implementation aligns well with recent DoFnTester removal efforts (such as #40866) and preserves existing test behavior and assertions.

🔍 General Feedback

  • In RampupThrottlingFnTest, using DoFnRunners.simpleRunner with an in-memory SideInputReader and direct @Setup invocation is an appropriate choice given the fixed Joda clock and non-serializable mock injections.
  • In SplitQueryFnIT, combining the two testSplitQueryFn variants (with and without readTime) into distinct branches on the same TestPipeline with PAssert is idiomatic and avoids unnecessary pipeline runs.

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

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

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

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.

Port RampupThrottlingFnTest and SplitQueryFnIT off DoFnTester

1 participant