From 64b27eea92ec79f0e467d7a3f433b354d220ab98 Mon Sep 17 00:00:00 2001 From: Rabari Mihir <169349389+Mihir-Rabari@users.noreply.github.com> Date: Fri, 16 Oct 2026 04:29:05 +0000 Subject: [PATCH] test(proxy): require sustained event-loop interleaving across the buffered drain The old assertion only compared the probe's first and last observed step, which passes when the drain yields once early and then monopolizes the loop again. The probe must now advance through at least half the backlog and make progress across at least a quarter of the chunk transitions, so a regression that starves other tasks mid-drain turns the test red Addresses the review on PR #46810 --- .../proxy/test_proxy_server_endpoints_and_startup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/proxy/test_proxy_server_endpoints_and_startup.py b/tests/unit/proxy/test_proxy_server_endpoints_and_startup.py index 9f6500304f5..12c7783187a 100644 --- a/tests/unit/proxy/test_proxy_server_endpoints_and_startup.py +++ b/tests/unit/proxy/test_proxy_server_endpoints_and_startup.py @@ -4402,9 +4402,14 @@ async def test_async_data_generator_yields_to_event_loop_while_chunks_are_buffer _, observed_progress = await asyncio.gather(probe(), consume()) - assert observed_progress[0] < observed_progress[-1], ( + assert observed_progress[-1] >= num_chunks // 2, ( f"Event loop starved while {num_chunks} buffered chunks were drained, " - f"probe progress stayed at {observed_progress[0]} the whole stream" + f"probe only reached {observed_progress[-1]} steps" + ) + sustained_advances = sum(1 for a, b in zip(observed_progress, observed_progress[1:]) if b > a) + assert sustained_advances >= num_chunks // 4, ( + f"Probe advanced in only {sustained_advances} of {num_chunks} chunks, " + f"the drain yields once at the start and then monopolizes the loop again" )