From 678a155dbabbad3ef2814794bb01660937703a76 Mon Sep 17 00:00:00 2001 From: ScottW514 Date: Mon, 31 Aug 2026 13:46:28 -0400 Subject: [PATCH] forgetest: the fire-watch log checks wait out the rsyslog lag The engine acted correctly on the bench (FLAME, hold, fire blocked) but the test read the forgectrl log tail one second after the trip, before rsyslog put the line on disk. The two log checks poll the tail for up to 8 s (_tail_wait) instead of reading it once. --- forgetest/forgetest/suite/cooling.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/forgetest/forgetest/suite/cooling.py b/forgetest/forgetest/suite/cooling.py index 49ab7d0..f3c7541 100644 --- a/forgetest/forgetest/suite/cooling.py +++ b/forgetest/forgetest/suite/cooling.py @@ -692,6 +692,18 @@ def tec_drive(ctx): FIRE_KEYS = ("cool_fire_q1_alert", "cool_fire_q1_critical", "cool_fire_q2_alert", "cool_fire_q2_critical") + + +def _tail_wait(ctx, fc, needle, wait=8): + """A log line lands through rsyslog a beat after the engine acts; + poll the tail instead of reading it once.""" + t0 = time.time() + while time.time() - t0 < wait: + if _tail_has(fc, needle): + return True + ctx.sleep(1) + return False + FIRE_WAIT_S = 25 # settings re-read at run start, two-tick breach, 1 Hz @@ -748,7 +760,8 @@ def fire_watch_tiers(ctx): ctx.check(c.get("verdict") == "FLAME", "q1 alert under the lamp did not hold the session: %s", c) ctx.check(c.get("hold") is True and c.get("fire_ok") is False, "FLAME without a hold and fire blocked: %s", c) ctx.check(c.get("fire_watch") == "alert", "fire_watch %r during the alert, expected alert", c.get("fire_watch")) - ctx.check(_tail_has(fc, "lid IR flame alert (quartiles "), "the flame-alert line is missing from the forgectrl log") + ctx.check(_tail_wait(ctx, fc, "lid IR flame alert (quartiles "), + "the flame-alert line is missing from the forgectrl log") # The release: the settings re-read is at run start, so the # release lever mid-session is the env-free path - restore the # threshold and end the session; the alert must not survive @@ -778,7 +791,8 @@ def fire_watch_tiers(ctx): ilk = hw.sysfs_int("cnc/interlock_circuit") ev["interlock_circuit"] = ilk ctx.check(ilk is not None and (ilk & 8), "the laser latch is not locked under FIRE (interlock_circuit=%s)", ilk) - ctx.check(_tail_has(fc, "LID IR FIRE SIGNAL (quartiles "), "the FIRE line is missing from the forgectrl log") + ctx.check(_tail_wait(ctx, fc, "LID IR FIRE SIGNAL (quartiles "), + "the FIRE line is missing from the forgectrl log") _set_gates(ctx, fc, {"cool_fire_q1_critical": orig["cool_fire_q1_critical"], "cool_fire_q1_alert": orig["cool_fire_q1_alert"]}) grbl.command("M9")