test(spanner): fix AFE server timing metadata failures in prerelease tests - #17970
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the unit tests across the Google Cloud Spanner Python client to assert that the "x-goog-spanner-enable-afe-server-timing" metadata header is set to "true" on all relevant gRPC requests. This change affects both synchronous and asynchronous test suites for clients, databases, sessions, transactions, snapshots, and instances. No review comments were provided, so I have no additional feedback to offer.
sakthivelmanii
force-pushed
the
fix-spanner-prerelease-deps-afe-metadata
branch
3 times, most recently
from
August 2, 2026 07:10
e5260b3 to
56fa705
Compare
In prerelease-deps CI sessions, OpenTelemetry prerelease packages import google.cloud.spanner_v1 before conftest.py executes. Consequently, _helpers.ENABLE_AFE_SERVER_TIMING evaluated to True in prerelease-deps, emitting x-goog-spanner-enable-afe-server-timing headers and breaking 356 unit tests. By setting SPANNER_DISABLE_AFE_SERVER_TIMING='true' in the env dictionary of unit test sessions in noxfile.py, AFE server timing is disabled in the subprocess environment before pytest is launched. This ensures ENABLE_AFE_SERVER_TIMING evaluates to False consistently across all unit test sessions without needing to modify any unit test files or production code. Additionally, the metrics_tracer fixture in test_metrics_tracer.py explicitly sets tracer.afe_server_timing_enabled = True so tracer unit tests continue to test AFE latency recording.
sakthivelmanii
force-pushed
the
fix-spanner-prerelease-deps-afe-metadata
branch
from
August 2, 2026 07:30
56fa705 to
96f8d53
Compare
sinhasubham
approved these changes
Aug 3, 2026
4 tasks
sakthivelmanii
added a commit
that referenced
this pull request
Aug 4, 2026
…n conftest (#17980) Reverts the edits to packages/google-cloud-spanner/noxfile.py from PR #17970 to restore compliance with owlbot/librarian autogeneration and fix issue #17974. Disables AFE server timing in unit tests directly inside tests/unit/conftest.py by setting SPANNER_DISABLE_AFE_SERVER_TIMING="true" and _helpers.ENABLE_AFE_SERVER_TIMING = False. This ensures both standard unit tests and prerelease-deps unit tests pass cleanly without modifying autogenerated files or existing unit test assertions. Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-cloud-python/issues) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AFE server timing metric header ('x-goog-spanner-enable-afe-server-timing') is enabled by default in Spanner client helper methods (_helpers.py). Consequently, _metadata_with_prefix appends ('x-goog-spanner-enable-afe-server-timing', 'true') to all client RPC request metadata.
This commit updates expected metadata tuples across 12 synchronous and asynchronous Spanner unit test files (254 assertions updated) to explicitly include ('x-goog-spanner-enable-afe-server-timing', 'true'), resolving 356 assertion failures in prerelease-deps CI test sessions.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕