Skip to content

Port DatastoreV1Test off DoFnTester - #40866

Open
Rishavbhattarai wants to merge 2 commits into
apache:masterfrom
Rishavbhattarai:port-datastorev1test-off-dofntester
Open

Rishavbhattarai wants to merge 2 commits into
apache:masterfrom
Rishavbhattarai:port-datastorev1test-off-dofntester

Conversation

@Rishavbhattarai

Copy link
Copy Markdown
Contributor

Fixes #18692.

Ports DatastoreV1Test off the deprecated DoFnTester.

TestPipeline doesn't fit here. DatastoreWriterFn, SplitQueryFn and ReadFn get their client from mockDatastoreFactory, a Mockito mock that can't be serialized, and the tests verify calls on that mock after the bundle. That's why every DoFnTester call used CloningBehavior.DO_NOT_CLONE.

So I added one helper to the test, processBundle(fn, inputs). It runs the fn in-process through DoFnRunners.simpleRunner (start bundle, process each input in the global window, finish bundle) and returns the main outputs. The 10 call sites now call it, and the comments about disabling cloning are gone since nothing gets cloned. :runners:core-java is already an implementation dependency of this module, so there's no build change.

Testing: ./gradlew :sdks:java:io:google-cloud-platform:test --tests 'org.apache.beam.sdk.io.gcp.datastore.DatastoreV1Test*' passes (62/62 across SingletonTests and ParameterizedTests), and spotlessCheck is clean.

The fns under test hold Mockito mocks that can't be serialized, so
TestPipeline doesn't fit. Add a small processBundle helper that runs
the fn in-process through DoFnRunners.simpleRunner and use it at the
10 DoFnTester call sites.

Fixes apache#18692
@github-actions github-actions Bot added java io gcp size/m M: 50-249 lines changed labels Oct 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 DatastoreV1Test off the deprecated DoFnTester by introducing an in-process processBundle helper built on DoFnRunners.simpleRunner. This approach is appropriate here because the DoFns under test hold non-serializable Mockito mocks and only rely on @StartBundle, @ProcessElement, and @FinishBundle lifecycle methods.

🔍 General Feedback

  • The processBundle helper accurately preserves the single-bundle, non-cloning execution semantics previously configured with CloningBehavior.DO_NOT_CLONE.
  • Minor cleanup needed: processBundle was inserted between FakeWriteBatcher and its Javadoc comment.

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

runner.finishBundle();
return outputs;
}

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.

🟢 Low: processBundle was inserted between FakeWriteBatcher and its Javadoc comment (lines 1359–1362), leaving a duplicate/dangling Javadoc block above processBundle. Please move the WriteBatcher Javadoc back down to FakeWriteBatcher.

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 in 994a46b, the Javadoc is back above FakeWriteBatcher.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
Backup reviewer: ahmedabu98 (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 DatastoreV1Test off DoFnTester

1 participant