Skip to content

test(gapic-generator): trigger genuine client-side deadline expiration in Client Timeout compliance tests - #18867

Draft
chalmerlowe wants to merge 2 commits into
mainfrom
test/showcase-client-timeout-compliance
Draft

chalmerlowe wants to merge 2 commits into
mainfrom
test/showcase-client-timeout-compliance

Conversation

@chalmerlowe

Copy link
Copy Markdown
Contributor

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 called client.echo() with a simulated server-side DEADLINE_EXCEEDED status 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-returned 504 response rather than a genuine client-side deadline expiration before the server responds.

Solution

  • test_span_compliance.py:
    • Updated run_echo_call in the "Client Timeout" scenario to call client.block() with a 2-second server response_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:
    • Updated F1.4 (HTTP T4), F1.9 (gRPC T4), F2.4 (HTTP T3), and F2.8 (gRPC T3) to reflect the Echo/Block endpoint and genuine client-side timeout attributes (http.response.status_code = NOT SET and ReadTimeout on HTTP; DEADLINE_EXCEEDED on gRPC).

@gemini-code-assist gemini-code-assist 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.

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

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.

medium

Import duration_pb2 from google.protobuf to allow explicit instantiation of the Duration message for the BlockRequest.

Suggested change
import requests.exceptions
import requests.exceptions
from google.protobuf import duration_pb2

Comment on lines +264 to 266
BlockRequest(
response_delay={"seconds": SERVER_BLOCK_DELAY_SECONDS},
),

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.

medium

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.

Suggested change
BlockRequest(
response_delay={"seconds": SERVER_BLOCK_DELAY_SECONDS},
),
BlockRequest(
response_delay=duration_pb2.Duration(
seconds=SERVER_BLOCK_DELAY_SECONDS
),
),

@chalmerlowe
chalmerlowe force-pushed the test/showcase-client-timeout-compliance branch from 9365610 to 1e109a0 Compare October 27, 2026 20:37
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from c32dfd6 to 628ecb8 Compare October 27, 2026 23:02
@chalmerlowe
chalmerlowe force-pushed the test/showcase-client-timeout-compliance branch from 1e109a0 to 08d3f68 Compare October 27, 2026 23:03
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from 628ecb8 to d292a3a Compare October 28, 2026 09:00
@chalmerlowe
chalmerlowe force-pushed the test/showcase-client-timeout-compliance branch 2 times, most recently from 2f1ae8f to 7d82d40 Compare October 28, 2026 09:39
@chalmerlowe
chalmerlowe force-pushed the fix/otel-test-plan-alignment-2 branch from d292a3a to c014818 Compare October 28, 2026 21:03
@chalmerlowe
chalmerlowe force-pushed the test/showcase-client-timeout-compliance branch from 7d82d40 to a0e4ee6 Compare October 28, 2026 21:03
Base automatically changed from fix/otel-test-plan-alignment-2 to main October 28, 2026 22:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants