test(update): deflake the Windows progress self-test (both race directions seen in CI)

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.
This commit is contained in:
Teknium
2026-08-19 17:02:52 -07:00
parent f7d90c9410
commit 6d1284a073
+18 -1
View File
@@ -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)