Skip to content

Commit 02fb58e

Browse files
hhensonclaude
andcommitted
Deflake http adaptor tests: retry route-not-ready 404s
The http_client adaptor test client retried connection failures but a successful connection returning a 404 was recorded as the result. On a slow CI runner the request can beat the handler graph's route registration, so tornado returns its default not-found (HTTP 404, HTML body) instead of the handler's 202/200 - failing the assertion (observed on macOS-26 CI: test_http_server_handler_preserves_keyed_ auxiliary_outputs, [(404, b'<html>...')] != [(202, ...)]). Retry a 404 up to the existing 10s deadline, same as a connection error. Safe here because these tests never expect a 404. The REST adaptor tests are deliberately left alone - they DO expect app-produced 404s (JSON bodies), distinguishable from the tornado default only by body, and were not observed flaking. Full tornado suite 42/42; full python suite 1258 passed / 19 skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f776615 commit 02fb58e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

python/tests/adaptors/tornado/test_http_client_adaptor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ def request(method, body=None):
334334
},
335335
)
336336
response = connection.getresponse()
337+
if response.status == 404 and time.monotonic() < deadline:
338+
time.sleep(0.02)
339+
continue
337340
responses.append(
338341
{
339342
"status": response.status,
@@ -455,6 +458,9 @@ def run():
455458
try:
456459
connection.request("GET", f"/handler-{free_tcp_port}/item")
457460
response = connection.getresponse()
461+
if response.status == 404 and time.monotonic() < deadline:
462+
time.sleep(0.02)
463+
continue
458464
client_result.append((response.status, response.read()))
459465
break
460466
except (ConnectionRefusedError, OSError):
@@ -534,6 +540,9 @@ def run():
534540
try:
535541
connection.request("GET", route)
536542
response = connection.getresponse()
543+
if response.status == 404 and time.monotonic() < deadline:
544+
time.sleep(0.02)
545+
continue
537546
client_results.append((response.status, response.read()))
538547
break
539548
except (ConnectionRefusedError, OSError):
@@ -620,6 +629,9 @@ def run():
620629
try:
621630
connection.request("GET", route)
622631
response = connection.getresponse()
632+
if response.status == 404 and time.monotonic() < deadline:
633+
time.sleep(0.02)
634+
continue
623635
client_results.append((response.status, response.read()))
624636
break
625637
except (ConnectionRefusedError, OSError):

0 commit comments

Comments
 (0)