Repository navigation
[Spanner Change Streams] Re-enable four disabled SpannerChangeStreamErrorTest tests - #41482
jonathansudhakar1 wants to merge 1 commit into
Conversation
…rrorTest tests apache#37003 disabled testUnavailableExceptionRetries, testAbortedExceptionRetries, testResourceExhaustedRetry and testInvalidRecordReceived to unblock the Spanner client upgrade in apache#36995. They fail on stale expectations, not on a connector bug: - readChangeStream() reads the database dialect while the pipeline is constructed, so the mock's sticky error fails that query. The upgraded client surfaces the injected status (UNAVAILABLE, ABORTED or RESOURCE_EXHAUSTED) instead of DEADLINE_EXCEEDED. Expect the injected status, as the enabled testUnknownExceptionDoesNotRetry and testResourceExhaustedRetryWithDefaultSettings already do. - testInvalidRecordReceived lacked the change stream options, partition size and partition state mocks that its enabled twin testInvalidRecordReceivedWithDefaultSettings has. Add them and expect the same "Field not found" failure. Fixes apache#41481.
There was a problem hiding this comment.
📋 Review Summary
This PR re-enables four previously @Ignored unit tests in SpannerChangeStreamErrorTest by updating their exception expectations and mock setups to align with current Cloud Spanner client behavior and connector queries. The changes are clean, well-scoped, and restore test coverage for retryable error codes (UNAVAILABLE, ABORTED, RESOURCE_EXHAUSTED) and invalid change stream record handling.
🔍 General Feedback
- Updating the three retry tests to assert on the injected
ErrorCode(UNAVAILABLE,ABORTED,RESOURCE_EXHAUSTED) while retaining thecountRequestsOfType(ExecuteSqlRequest.class) > 1check accurately validates retry behavior under the updated Spanner client. - Syncing
testInvalidRecordReceivedwith the mock setup andPipelineExecutionExceptionassertion intestInvalidRecordReceivedWithDefaultSettingsproperly restores the original test intent.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
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). |
|
@kennknowles a gentle ping when you have a moment. This re-enables the four I re-ran the class today on master plus this commit, after the GCP libraries BOM upgrade in #41594: 7 tests, 0 failures. It still merges cleanly. Its CI runs are still waiting for a maintainer to approve them. Thanks! |
Fixes #41481.
#37003 disabled four tests in
SpannerChangeStreamErrorTestto unblock the Spanner client upgrade in #36995, and #37002 tracked re-enabling them until the stale bot closed it in July. This PR re-enables them. The change is test-only; no connector code changes.They failed on stale expectations, not on a connector bug:
testUnavailableExceptionRetries,testAbortedExceptionRetries,testResourceExhaustedRetry:readChangeStream().expand()reads the database dialect while the pipeline is constructed (SpannerIO.java#L2404-L2405), so the mock's sticky error fails that query. The upgraded client surfaces the injected status (UNAVAILABLE,ABORTEDorRESOURCE_EXHAUSTED) rather thanDEADLINE_EXCEEDED. The tests now expect aSpannerExceptionwith the injected status, the same way the enabledtestUnknownExceptionDoesNotRetryandtestResourceExhaustedRetryWithDefaultSettingsalready do.testInvalidRecordReceived: it failed withINTERNAL: ... There is no result registered for the statement: select option_value from information_schema.change_stream_options .... It lacked themockChangeStreamOptions(),mockGetPartitionSize(...)andmockChangePartitionState(...)setup that its enabled twintestInvalidRecordReceivedWithDefaultSettingshas. It now has the same mocks and expectations as the twin (PipelineExecutionExceptionwith "Field not found", and more than zeroExecuteSqlRequests). It still differs from the twin in usinggetSpannerConfig(), which sets quick retry settings for streaming SQL as well.I asked about this approach on #37002 on Nov 11 and went ahead with it after a week without a reply.
Testing
All with JDK 21, on d44b808:
@Ignores removed:./gradlew :sdks:java:io:google-cloud-platform:test --tests 'org.apache.beam.sdk.io.gcp.spanner.changestreams.SpannerChangeStreamErrorTest'gave 7 tests, 4 failed (the messages quoted in [Failing Test]: Four SpannerChangeStreamErrorTest tests are still disabled and fail on stale expectations #41481)../gradlew :sdks:java:io:google-cloud-platform:spotlessApply: no changes../gradlew :sdks:java:io:google-cloud-platform:compileJava :sdks:java:io:google-cloud-platform:compileTestJava :sdks:java:io:google-cloud-platform:checkstyleMain :sdks:java:io:google-cloud-platform:checkstyleTest: BUILD SUCCESSFUL../gradlew :sdks:java:io:google-cloud-platform:test --tests 'org.apache.beam.sdk.io.gcp.spanner.changestreams.SpannerChangeStreamErrorTest': 7 tests, 0 failures, 0 skipped. Then 5 more consecutive runs with--rerun: 7 of 7 passed each time.Open questions
testUnknownExceptionDoesNotRetryandtestResourceExhaustedRetryWithDefaultSettings), the exception now comes fromapply(), so the code after it (run(), waiting forRUNNING) is never reached. I kept the change minimal and left that code alone. I'm happy to remove it here, or to rework these tests in a follow-up so that the sticky error hits the read path instead of the dialect query, if you'd prefer that.testUnavailableExceptionRetriesthat Fix SpannerChangeStreamErrorTest.java and stop disabling tests #28751 fixed in 2023. It may be worth closing once this lands.