Repository navigation
test(gapic-generator): trigger genuine client-side deadline expiration in Client Timeout compliance tests - #18867
chalmerlowe wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the "Client Timeout" test scenario in the span compliance tests to use the block RPC (which delays the response) instead of simulating a timeout via an error status on the echo RPC. This change affects both the telemetry requirements matrix and the test implementation in test_span_compliance.py. Feedback on the changes suggests importing and using google.protobuf.duration_pb2.Duration explicitly for the response_delay field in BlockRequest to ensure compatibility with pure protobuf clients, rather than relying on dictionary conversion.
| allow_module_level=True, | ||
| ) | ||
|
|
||
| import requests.exceptions |
| BlockRequest( | ||
| response_delay={"seconds": SERVER_BLOCK_DELAY_SECONDS}, | ||
| ), |
There was a problem hiding this comment.
Using a raw dictionary for the response_delay field in BlockRequest relies on proto-plus's automatic conversion. If the client is generated using pure protobuf (which is a supported configuration), this will raise a TypeError because pure protobuf constructors do not automatically convert dictionaries to submessages. Explicitly instantiating duration_pb2.Duration is more robust and compatible with both proto-plus and pure protobuf clients.
| BlockRequest( | |
| response_delay={"seconds": SERVER_BLOCK_DELAY_SECONDS}, | |
| ), | |
| BlockRequest( | |
| response_delay=duration_pb2.Duration( | |
| seconds=SERVER_BLOCK_DELAY_SECONDS | |
| ), | |
| ), |
9365610 to
1e109a0
Compare
c32dfd6 to
628ecb8
Compare
1e109a0 to
08d3f68
Compare
628ecb8 to
d292a3a
Compare
2f1ae8f to
7d82d40
Compare
…ndpoint attributes with spec
…n in Client Timeout compliance tests
d292a3a to
c014818
Compare
7d82d40 to
a0e4ee6
Compare
Problem / Context
Stacked on #18866.
In
packages/gapic-generator/tests/system/test_span_compliance.py, the"Client Timeout"scenario (F1.4,F1.9,F2.4,F2.8) previously calledclient.echo()with a simulated server-sideDEADLINE_EXCEEDEDstatus payload (EchoRequest(error=Status(code=DEADLINE_EXCEEDED))). Because the local Showcase server returned that simulated error response in under 1 millisecond, the test was exercising a server-returned504response rather than a genuine client-side deadline expiration before the server responds.Solution
test_span_compliance.py:run_echo_callin the"Client Timeout"scenario to callclient.block()with a 2-second serverresponse_delay(SERVER_BLOCK_DELAY_SECONDS = 2) and a 200ms client timeout (SHORT_CLIENT_TIMEOUT_SECONDS = 0.2), ensuring the client genuinely times out before receiving a response from the server.telemetry_requirements_matrix.csv:F1.4(HTTP T4),F1.9(gRPC T4),F2.4(HTTP T3), andF2.8(gRPC T3) to reflect theEcho/Blockendpoint and genuine client-side timeout attributes (http.response.status_code = NOT SETandReadTimeouton HTTP;DEADLINE_EXCEEDEDon gRPC).