From 01ffd1296b1f424dadcbf3e4e75d60af2ca2e626 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Tue, 28 Jul 2026 11:21:36 -0700 Subject: [PATCH] fix(e2e): poll for both spend rows before asserting the cache-hit contract (#34968) The cache-hit and paid rows for the two driver calls flush from different pods on independent update_spend timers, so waiting only for the cache-hit row can return a half-arrived result set where the paid-row assertion then fails on an empty list. Requiring both row kinds in the poll predicate lets the existing deadline absorb the slower flush without weakening any assertion --- .../spend_tracking/test_spend_tracking_e2e.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/quota_management/spend_tracking/test_spend_tracking_e2e.py b/tests/e2e/quota_management/spend_tracking/test_spend_tracking_e2e.py index b6e33627a5e..6a0032981fd 100644 --- a/tests/e2e/quota_management/spend_tracking/test_spend_tracking_e2e.py +++ b/tests/e2e/quota_management/spend_tracking/test_spend_tracking_e2e.py @@ -230,7 +230,9 @@ def test_cache_hit_is_zero_cost_and_suffixed( _ = unwrap(client.chat(scoped_key, "gemini-2.5-flash", prompt, max_tokens=16)) rows = client.poll_logs_for_key( - scoped_key, predicate=lambda rs: any(r.cache_hit == "True" for r in rs) + scoped_key, + predicate=lambda rs: any(r.cache_hit == "True" for r in rs) + and any(r.cache_hit != "True" for r in rs), ) cache_row = _require_row( rows,