From 52c6943775fc0fc9283c43d790f35bf1e9d9b9f0 Mon Sep 17 00:00:00 2001 From: zhanghui <23442919+gloryfromca@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:12:37 +0800 Subject: [PATCH] test(purge): let the drain-budget test outlast a slow first pass test_drain_time_counts_toward_the_budget gave the whole job a 1 s budget and expected it to run out in the drain wait. The budget is wall time from the start, so on the Windows runner a first pass near 1 s ran it out before the wait and the blame went to a first-pass step; the same test failed on two unrelated branches (11-19, 11-20). Delaying the first pass by 1.2 s reproduces it locally. A 3 s budget keeps the failure in the wait with that delay and without it. Co-Authored-By: Claude Opus 5.5 --- tests/unit/test_service/test_purge/test_runner.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_service/test_purge/test_runner.py b/tests/unit/test_service/test_purge/test_runner.py index dcef6d826..c9bc377ba 100644 --- a/tests/unit/test_service/test_purge/test_runner.py +++ b/tests/unit/test_service/test_purge/test_runner.py @@ -388,9 +388,14 @@ async def test_drain_time_counts_toward_the_budget( storage: Storage, monkeypatch: pytest.MonkeyPatch ) -> None: """Persisted while it waits, so a restart does not reset it; at the - budget the job fails and says why on the store the second pass missed.""" + budget the job fails and says why on the store the second pass missed. + + The budget is wall time from the start, so it must outlast pass one with + room to spare: a pass one slower than the budget (seen at ~1 s on the + Windows runner) ends the job before the wait and blames a pass-one step. + """ monkeypatch.setattr(_runner, "_DRAIN_SAVE_S", 0.05) - p, job_id = await _confirmed(storage, run_budget_seconds=1) + p, job_id = await _confirmed(storage, run_budget_seconds=3) forever = p.marks.track(_old()) # never ends forever.__enter__() assert await p.run_to_end(job_id) == "failed"