From abd5df24df6dbc2aeb9b13dc4728d9959fcdfe28 Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Thu, 3 Dec 2026 19:18:58 +0100 Subject: [PATCH] test(execution): wait for KeyCutShort host runs under load and give licence tests their own path A standard run on a host packs and copies the backend first, so under load it ends after the old 10 s wait and its ready file after the old 5 s poll. Both now wait 60 s and still fail a stuck run. The licence tests used a fixed /dev/shm/nullius-; each now has a name of its own. --- app/tests/test_execution.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/tests/test_execution.py b/app/tests/test_execution.py index 541901828..2270afc5a 100644 --- a/app/tests/test_execution.py +++ b/app/tests/test_execution.py @@ -449,6 +449,15 @@ class KeyCutShort(LocalHost): a host alike.""" KEY, URL = "sk-cut-0123456789abcdef", "http://127.0.0.1:8000/v1" + def wait(self, ex, seconds=60): # a host run packs and copies the backend first: slow under load + return super().wait(ex, seconds) + + def shm_name(self, base): + """A run name of its own: the licence folder is /dev/shm/nullius-, shared by every process on the machine.""" + name = f"{base}-{self.tmp.name.rsplit('-', 1)[-1]}" + self.addCleanup(shutil.rmtree, f"/dev/shm/nullius-{name}", True) + return name + def cut_to(self, keep): """The command runner, the launcher's stdin cut to what ``keep`` leaves of it.""" def run(argv, timeout=600.0, stdin=None): @@ -533,7 +542,7 @@ def test_a_standard_run_on_a_host_is_handed_its_benchmarks_licences_and_here_non value, blob = "lic-0123456789abcdef", b"FAKE-LICENCE-FILE\n\x00bytes" for target in ("here", "host"): with self.subTest(target): - name = f"lic-{target}"; root = self.tmp / name; seen = root / "seen" + name = self.shm_name(f"lic-{target}"); root = self.tmp / name; seen = root / "seen" script = (f'echo "line=${{#NULLIUS_LICENCES}} dir=${{NULLIUS_LICENCE_DIR:-none}}" > {seen}; ' f'[ -n "$NULLIUS_LICENCE_DIR" ] && mkdir -p "$NULLIUS_LICENCE_DIR" && echo x > "$NULLIUS_LICENCE_DIR/F"; ' f'echo "$NULLIUS_LICENCES" > {root}/line; echo "{value}"') @@ -557,19 +566,20 @@ def test_a_standard_run_on_a_host_is_handed_its_benchmarks_licences_and_here_non self.assertNotIn(blob.decode(errors="replace"), (root / name / "run.json").read_text()) def test_a_stopped_run_on_a_host_leaves_no_licence_file_behind(self): - name = "lic-stop"; root = self.tmp / name; ready = root / "ready" + name = self.shm_name("lic-stop"); root = self.tmp / name; ready = root / "ready" script = f'mkdir -p "$NULLIUS_LICENCE_DIR" && echo x > "$NULLIUS_LICENCE_DIR/F"; touch {ready}; sleep 30' plan = self.plan([{"id": "a", "label": "a", "script": script}], name) plan.runner, plan.licences = execution.STANDARD, {"benchmark": "envbench", "names": ["F"]} ex = execution.Execution(plan, root=str(root), key=self.KEY, url=self.URL, licences={"F": b"FAKE-LICENCE-FILE"}).start() - for _ in range(250): + for _ in range(3000): # 60 s: the part starts after the backend is copied if ready.exists(): break time.sleep(0.02) + self.assertTrue(ready.exists(), "the part never started") self.assertTrue(os.path.exists(f"/dev/shm/nullius-{name}/F")) ex.stop() self.wait(ex) - self.assertEqual(ex.state, "stopped", ex.lines) + self.assertEqual((ex.state, ex.exit_code), ("stopped", 130), ex.lines) # killed, not a part that ran out its sleep self.assertFalse(os.path.exists(f"/dev/shm/nullius-{name}")) def test_a_launch_the_host_never_answered_is_asked_once_more_and_starts_once(self):