forgetest: the supervisor's levers get a timeout above the daemon's own waits

POST /mode, /controller/start and /controller/stop answer only when the
switch is done: the old controller gone, the new one started after any
pending liveness probe, and its first job-state report in (15 s without
one). The client's 10 s timeout read a slow but honest switch as a dead
daemon and errored cloud.service-protocol on the bench; those three
paths now get 120 s. No catalog consequence: the tests and their covers
are unchanged, the client only waits longer.
This commit is contained in:
ScottW514
2026-08-23 12:10:20 -04:00
parent 908e0c76b8
commit ab0a515a85
2 changed files with 38 additions and 2 deletions
+21
View File
@@ -78,6 +78,27 @@ class SwitchModeTests(unittest.TestCase):
self.assertTrue(ok, detail)
self.assertEqual(self.fc.posts, [])
def test_the_supervisors_levers_get_the_slow_timeout(self):
from forgetest import hw
fc = hw.Forgectrl(timeout=1.0, slow_timeout=2.0)
self.assertEqual(fc.timeout_for("POST", "/mode"), 2.0)
self.assertEqual(fc.timeout_for("POST", "/controller/start"), 2.0)
self.assertEqual(fc.timeout_for("POST", "/controller/stop"), 2.0)
self.assertEqual(fc.timeout_for("GET", "/mode"), 1.0)
self.assertEqual(fc.timeout_for("POST", "/settings"), 1.0)
self.assertGreater(hw.SLOW_TIMEOUT_S, 15.0) # forgectrl's first-report wait
# a switch that answers after the ordinary timeout still lands
import time
def on_post(path, form):
time.sleep(1.5)
self.fc.state["mode"] = dict(self.fc.state["mode"], mode="cloud")
return None
self.fc.on_post = on_post
st, body = fc.post("/mode", data={"controller": "cloud"})
self.assertEqual(st, 200) # 1.5 s > timeout, < slow_timeout
self.assertEqual(self.fc.state["mode"]["mode"], "cloud")
def test_cloud_to_grbl_switches_and_waits_for_the_port(self):
cloud(self.fc)
b = self.bl()