Skip to content

[Spanner Change Streams] Re-enable four disabled SpannerChangeStreamErrorTest tests - #41482

Open
jonathansudhakar1 wants to merge 1 commit into
apache:masterfrom
jonathansudhakar1:spanner-cs-error-tests-41481
Open

jonathansudhakar1 wants to merge 1 commit into
apache:masterfrom
jonathansudhakar1:spanner-cs-error-tests-41481

Conversation

@jonathansudhakar1

Copy link
Copy Markdown
Contributor

Fixes #41481.

#37003 disabled four tests in SpannerChangeStreamErrorTest to 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, ABORTED or RESOURCE_EXHAUSTED) rather than DEADLINE_EXCEEDED. The tests now expect a SpannerException with the injected status, the same way the enabled testUnknownExceptionDoesNotRetry and testResourceExhaustedRetryWithDefaultSettings already do.
  • testInvalidRecordReceived: it failed with INTERNAL: ... There is no result registered for the statement: select option_value from information_schema.change_stream_options .... It lacked the mockChangeStreamOptions(), mockGetPartitionSize(...) and mockChangePartitionState(...) setup that its enabled twin testInvalidRecordReceivedWithDefaultSettings has. It now has the same mocks and expectations as the twin (PipelineExecutionException with "Field not found", and more than zero ExecuteSqlRequests). It still differs from the twin in using getSpannerConfig(), 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:

  • Before the change, with only the @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

…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.

@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 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 the countRequestsOfType(ExecuteSqlRequest.class) > 1 check accurately validates retry behavior under the updated Spanner client.
  • Syncing testInvalidRecordReceived with the mock setup and PipelineExecutionException assertion in testInvalidRecordReceivedWithDefaultSettings properly restores the original test intent.

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

@github-actions github-actions Bot added java io gcp size/s S: 10-49 lines changed labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
Backup reviewer: chamikaramj (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).

@jonathansudhakar1

Copy link
Copy Markdown
Contributor Author

@kennknowles a gentle ping when you have a moment. This re-enables the four SpannerChangeStreamErrorTest tests that #37003 disabled (#41481). It's test-only: the three retry tests now expect the injected status as a SpannerException, and testInvalidRecordReceived gets the same mocks as its enabled twin.

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!

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.

[Failing Test]: Four SpannerChangeStreamErrorTest tests are still disabled and fail on stale expectations

1 participant