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.
This commit is contained in:
ScottW514
2026-08-31 13:46:28 -04:00
parent b506e67bce
commit 678a155dba
+16 -2
View File
@@ -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") 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 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("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("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(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 # The release: the settings re-read is at run start, so the
# release lever mid-session is the env-free path - restore the # release lever mid-session is the env-free path - restore the
# threshold and end the session; the alert must not survive # 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") ilk = hw.sysfs_int("cnc/interlock_circuit")
ev["interlock_circuit"] = ilk 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(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"], _set_gates(ctx, fc, {"cool_fire_q1_critical": orig["cool_fire_q1_critical"],
"cool_fire_q1_alert": orig["cool_fire_q1_alert"]}) "cool_fire_q1_alert": orig["cool_fire_q1_alert"]})
grbl.command("M9") grbl.command("M9")