mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-09-27 08:41:13 -07:00
forgetest: cooling.flow-under-load finds the verdict by offset, not by a tail count
The test counted "heater rise" in the last 300 lines of the forgectrl log before the job, then waited for the count to grow. A tail of fixed length cannot show that: the new verdict line comes in at the bottom as an old one leaves at the top, the count does not move, and a check that verified reads as one that never judged. Seen on the bench reference in campaign c-20260919210959-8780: the engine logged "coolant flow verified (heater rise 11.5 C, dT 9.5 C; laser 1.6 off 13.1)" at 21:37:46, 70 s into the job and inside the wait, and the test failed at 21:39:21 with "the engine published no flow verdict within 120 s". The 21:17:27 verdict of an earlier test sat near the top of the 300-line tail when the test began. Replayed against that log, the old method reads 4 before the job and 4 with the new verdict in the tail; the search from the byte offset finds the 21:37:46 line. The test now takes the log's byte offset before the job (_log_offset, as the fail-tier and liveness tests do) and searches what the file gained since with the verdict expression, stopping only on a line that matches. _log_since reads a file that is now shorter than the offset from its start: a rotation under the test leaves only newer lines. The /logs/tail helper and its line count are gone with their one user. Proven: tests/test_cooling_suite.py FlowVerdictLogTests - the text after the offset alone, the real verdict line through the expression, an old verdict before the offset not taken for the new one, a rotated log read whole, a missing log read as nothing; the cooling host tests pass under Linux, 24 tests. No component source changed, so no pin moves.
This commit is contained in:
@@ -734,3 +734,51 @@ class FanGateTests(unittest.TestCase):
|
||||
self.run_test()
|
||||
self.assertIn("lacks exhaust", str(cm.exception))
|
||||
self.assertEqual(self.fc.state["settings"]["cool_tach_exhaust_min_rpm"], "")
|
||||
|
||||
|
||||
class FlowVerdictLogTests(unittest.TestCase):
|
||||
"""cooling.flow-under-load finds the engine's verdict in what the log
|
||||
gained since the job began, not in a count over a tail of fixed length:
|
||||
there a new verdict line comes in at the bottom as an old one leaves at
|
||||
the top, the count does not move, and a check that verified reads as
|
||||
one that never judged."""
|
||||
|
||||
VERDICT = ("2026-09-19T21:37:46.869674+00:00 forgectrl[2796] INFO cool: coolant flow verified "
|
||||
"(heater rise 11.5 C, dT 9.5 C; laser 1.6 off 13.1)\n")
|
||||
OLD = ("2026-09-19T21:17:27.200840+00:00 forgectrl[965] INFO cool: coolant flow verified "
|
||||
"(heater rise 9.5 C, dT 8.7 C)\n")
|
||||
|
||||
def setUp(self):
|
||||
self.dir = tempfile.mkdtemp(prefix="flowlog.")
|
||||
self.addCleanup(shutil.rmtree, self.dir, ignore_errors=True)
|
||||
self.path = os.path.join(self.dir, "forgectrl.log")
|
||||
|
||||
def write(self, text, mode="w"):
|
||||
with open(self.path, mode, newline="\n") as f:
|
||||
f.write(text)
|
||||
|
||||
def test_only_the_text_after_the_offset_comes_back(self):
|
||||
self.write(self.OLD + "filler\n" * 400)
|
||||
off = os.path.getsize(self.path)
|
||||
self.assertEqual(cooling._log_since(self.path, off), "")
|
||||
self.write(self.VERDICT, mode="a")
|
||||
text = cooling._log_since(self.path, off)
|
||||
self.assertEqual(text, self.VERDICT)
|
||||
m = cooling._load_verdict_rx().search(text)
|
||||
self.assertEqual(m.group(1), "coolant flow verified")
|
||||
self.assertEqual((m.group(2), m.group(5)), ("11.5", "1.6"))
|
||||
|
||||
def test_an_old_verdict_before_the_offset_is_not_the_new_one(self):
|
||||
self.write(self.OLD)
|
||||
off = os.path.getsize(self.path)
|
||||
self.write("2026-09-19T21:36:40+00:00 forgectrl[2796] INFO cool: crash watch armed\n", mode="a")
|
||||
self.assertIsNone(cooling._load_verdict_rx().search(cooling._log_since(self.path, off)))
|
||||
|
||||
def test_a_log_rotated_under_the_test_is_read_whole(self):
|
||||
self.write(self.OLD + "filler\n" * 400)
|
||||
off = os.path.getsize(self.path)
|
||||
self.write(self.VERDICT) # the rotation: a new, shorter file
|
||||
self.assertEqual(cooling._log_since(self.path, off), self.VERDICT)
|
||||
|
||||
def test_a_missing_log_reads_as_nothing(self):
|
||||
self.assertEqual(cooling._log_since(os.path.join(self.dir, "none.log"), 0), "")
|
||||
|
||||
Reference in New Issue
Block a user