Repository navigation
Port RampupThrottlingFnTest and SplitQueryFnIT off DoFnTester - #41730
harshilv17 wants to merge 1 commit into
Conversation
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
There was a problem hiding this comment.
📋 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, usingDoFnRunners.simpleRunnerwith an in-memorySideInputReaderand direct@Setupinvocation is an appropriate choice given the fixed Joda clock and non-serializable mock injections. - In
SplitQueryFnIT, combining the twotestSplitQueryFnvariants (with and withoutreadTime) into distinct branches on the sameTestPipelinewithPAssertis idiomatic and avoids unnecessary pipeline runs.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @ahmedabu98 for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Fixes #41729.
Ports the last two Datastore tests in
sdks/java/io/google-cloud-platformoff the deprecatedDoFnTester.TestPipelinedoesn't fitRampupThrottlingFnTest: 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 theDatastoreV1Testport (#40866), it now runsRampupThrottlingFnthroughDoFnRunners.simpleRunner. What differs from that helper:SideInputReaderthat returns the fixed start time for the start-time view.simpleRunnerdoesn't call@Setup, so the test callssetup()itself and then injects the sleeper and counter. This replaces the anonymous subclass that overrodesetup().simpleRunnerwraps user exceptions inUserCodeException, so the throttling check now asserts aUserCodeExceptioncaused byRampupDelayException.The rampup schedule and the expected counts are unchanged.
SplitQueryFnITnow usesTestPipeline+PAssert:Createthe query,ParDo(SplitQueryFn),Count.globally(), andPAssert.thatSingletonon the expected number of splits, once without and once withreadTime.Ran locally (JDK 17):
RampupThrottlingFnTestpasses. I also changed one expected count to check the test fails, then reverted it.compileTestJava,checkstyleTestandspotlessApplyare clean.SplitQueryFnITneeds real Datastore inapache-beam-testing, so I only compiled it.Fixes #41729).CHANGES.md: not needed, test-only change.