Skip to content

Commit 97e42b8

Browse files
test(spanner): fix AFE server timing metadata failures in prerelease tests (#17970)
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: - [ ] 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> 🦕
1 parent 91ab411 commit 97e42b8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/google-cloud-spanner/noxfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def unit(session, protobuf_implementation):
247247
*args,
248248
env={
249249
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
250+
"SPANNER_DISABLE_AFE_SERVER_TIMING": "true",
250251
},
251252
)
252253

@@ -609,6 +610,7 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
609610
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
610611
"SPANNER_DATABASE_DIALECT": database_dialect,
611612
"SKIP_BACKUP_TESTS": "true",
613+
"SPANNER_DISABLE_AFE_SERVER_TIMING": "true",
612614
},
613615
)
614616

@@ -807,5 +809,6 @@ def core_deps_from_source(session, protobuf_implementation):
807809
"tests/unit",
808810
env={
809811
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
812+
"SPANNER_DISABLE_AFE_SERVER_TIMING": "true",
810813
},
811814
)

packages/google-cloud-spanner/tests/unit/test_metrics_tracer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def metrics_tracer():
3333
mock_gfe_missing = mock.create_autospec(Counter, instance=True)
3434
mock_afe_latency = mock.create_autospec(Histogram, instance=True)
3535
mock_afe_missing = mock.create_autospec(Counter, instance=True)
36-
return MetricsTracer(
36+
tracer = MetricsTracer(
3737
enabled=True,
3838
instrument_attempt_latency=mock_attempt_latency,
3939
instrument_attempt_counter=mock_attempt_counter,
@@ -45,6 +45,8 @@ def metrics_tracer():
4545
instrument_afe_latency=mock_afe_latency,
4646
instrument_afe_connectivity_error_count=mock_afe_missing,
4747
)
48+
tracer.afe_server_timing_enabled = True
49+
return tracer
4850

4951

5052
def test_record_attempt_start(metrics_tracer):

0 commit comments

Comments
 (0)