From 6d1284a0735b8e4f571d4ddf0f28f83dda71b6f6 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:02:52 -0700 Subject: [PATCH] test(update): deflake the Windows progress self-test (both race directions seen in CI) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_progress_advances_while_the_orchestrator_blocks raced its subject on both edges within one hour of PR CI (#90358): - Run 1: sampled right after the shim URL printed, before the orchestrator published its stage — caught the page boot default ('Hermes will open once done.' != 'Testing quiet update'). - Run 2 (rerun): with HOLD=4s on a slow runner, the second sample slid past the hold and caught the cleared terminal state ('' != 'Testing quiet update'). Fix: wait (<=10s) for the published stage to actually land before starting the 1.5s stability window, and raise the hold to 10s so both samples land inside it. Same assertions, same contract — just anchored to the event the test is about instead of wall-clock luck. --- tests/test_desktop_update_windows_progress.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_desktop_update_windows_progress.py b/tests/test_desktop_update_windows_progress.py index d3f67a07e1..d6f8acfd95 100644 --- a/tests/test_desktop_update_windows_progress.py +++ b/tests/test_desktop_update_windows_progress.py @@ -39,7 +39,11 @@ def test_progress_advances_while_the_orchestrator_blocks(tmp_path: Path) -> None env = os.environ.copy() env["TEMP"] = str(tmp_path) env["TMP"] = str(tmp_path) - env["HERMES_SELFTEST_HOLD_SECONDS"] = "4" + # Generous hold: the assertions below must both land INSIDE it. 4s was + # too tight for a slow runner — the second sample slid past the hold, + # caught the cleared terminal state, and failed '' == 'Testing quiet + # update' (PR #90358 rerun, Aug 2026). + env["HERMES_SELFTEST_HOLD_SECONDS"] = "10" with output_path.open("wb") as output: process = subprocess.Popen( @@ -72,7 +76,20 @@ def test_progress_advances_while_the_orchestrator_blocks(tmp_path: Path) -> None time.sleep(0.1) assert shim_url, output_path.read_text(encoding="utf-8", errors="replace") + + # The URL prints BEFORE the orchestrator publishes its held stage — + # sampling immediately races the publish and can catch the page's + # boot default instead ('Hermes will open once done.' == + # 'Testing quiet update', PR #90358 first run). Wait for the held + # stage to actually land, THEN start the stability window. + held_stage = "Testing quiet update" + publish_deadline = time.monotonic() + 10 first = _read_progress(shim_url) + while first.get("message") != held_stage and time.monotonic() < publish_deadline: + time.sleep(0.1) + first = _read_progress(shim_url) + assert first["message"] == held_stage, first + time.sleep(1.5) second = _read_progress(shim_url)