Repository navigation
[#18690] Port SolrIOTest off deprecated DoFnTester - #40819
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR ports SolrIOTest.testWriteWithMaxBatchSize off the deprecated DoFnTester to TestPipeline (resolving #18690). However, because DirectRunner partitions Create.of(...) elements into small bundles of only a few elements each, replacing DoFnTester with a standard Create.of + SolrIO.write() pipeline causes the batch size threshold (BATCH_SIZE = 200) to never be reached in @ProcessElement, leaving the mid-bundle flush logic in WriteFn completely untested.
🔍 General Feedback
- Consider either setting a very small
maxBatchSize(e.g.,1) so that the mid-bundle flush branch inWriteFn.processElementis guaranteed to execute even with small runner bundles, or forcing the test elements into a single bundle (for example via a precedingGroupByKeyandParDothat emits all documents within a single@ProcessElementinvocation) while asserting intermediate flush behavior.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
💬 Inline Findings
sdks/java/io/solr/src/test/java/org/apache/beam/sdk/io/solr/SolrIOTest.java(line 236): 🟠 High:DirectRunner'sCreate.Valuessplits the inputListinto many small bundles (typically ~1–4 elements per bundle). BecauseBATCH_SIZEis200,batch.size() >= spec.getMaxBatchSize()insideWriteFn.processElementis never triggered duringpipeline.run(); every bundle simply flushes in@FinishBundleinstead.
Additionally, the previous test specifically verified that documents were flushed to Solr before the bundle finished when maxBatchSize was reached. As written, testWriteWithMaxBatchSize is now nearly identical to testWrite and no longer exercises the maxBatchSize threshold in WriteFn.processElement.
To ensure TestPipeline actually exercises the batch size limit in @ProcessElement, you should either:
- Force all
NUM_DOCSdocuments into a single bundle (e.g., by grouping onto a single key and emitting all documents from a singleDoFn.ProcessElement) or use amaxBatchSizeof1so thatbatch.size() >= spec.getMaxBatchSize()is guaranteed to be hit during@ProcessElement. - Ideally, preserve the intermediate check (e.g., via a custom
DoFnorSolrClientspy/wrapper, or by halting/checking state mid-bundle) to verify that flushing happens during@ProcessElementrather than only in@FinishBundle.
|
Assigning reviewers: R: @kennknowles 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). |
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR cleanly migrates SolrIOTest.testWriteWithMaxBatchSize off the deprecated DoFnTester harness onto TestPipeline (resolving #18690). The updated test groups documents into a single bundle and configures withMaxBatchSize(1) so that mid-bundle flushing during @ProcessElement in SolrIO.Write.WriteFn is exercised.
🔍 General Feedback
- The previous review feedback regarding bundle sizing in
DirectRunnerand exercising themaxBatchSizeflush condition during@ProcessElementhas been addressed. LGTM!
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
R: @damccorm |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
kennknowles
left a comment
There was a problem hiding this comment.
Looks good! It does change the test, but I think it makes it better. Before, the test was checking implementation details (like the fact that it only flushes at the end of a bundle) when tests are better if they are testing real end-to-end properties.
It makes it look more like an integration test, but I see it is a local fake so it is great!
|
Thanks @kennknowles! That was exactly the goal moving away from micro testing internal lifecycle details like bundle flushes via DoFnTester, and instead testing the transform's contract end to end against TestPipeline.....Using the embedded/local Solr server keeps it completely hermetic and fast while giving us much higher confidence in actual execution semantics.... |
Fixes #18690.
Description
This pull request ports
SolrIOTestinsdks/java/io/solroff the deprecatedDoFnTestertest harness in favor of standardTestPipelineexecution.org.apache.beam.sdk.transforms.DoFnTester.testWriteWithMaxBatchSize()to execute throughTestPipelinewithCreate.of(...)andwrite, verifying document indexing into Solr.Checklist
Fixes #18690).CHANGES.mdupdate not required (internal test refactoring).Verification
.\gradlew.bat :sdks:java:io:solr:test(12/12 passed).\gradlew.bat :sdks:java:io:solr:spotlessCheck(PASSED)