diff --git a/app/tests/execution_support.py b/app/tests/execution_support.py index b477a1d8..2d33acba 100644 --- a/app/tests/execution_support.py +++ b/app/tests/execution_support.py @@ -25,8 +25,8 @@ def setUp(self): self.addCleanup(execution.EXECUTIONS.clear) docker = mock.patch.object(execution, "docker_here", return_value=None); docker.start(); self.addCleanup(docker.stop) - def wait(self, ex, seconds=10): - ex.thread.join(seconds); self.assertFalse(ex.thread.is_alive(), "the run did not end") + def wait(self, ex, seconds=60): + ex.thread.join(seconds); self.assertFalse(ex.thread.is_alive(), "the run did not end") # join returns when the run ends; 60 s is for a loaded machine return ex def until(self, ex, state, seconds=10): diff --git a/app/tests/test_constraints.py b/app/tests/test_constraints.py index b5dd39d4..f719ac41 100644 --- a/app/tests/test_constraints.py +++ b/app/tests/test_constraints.py @@ -13,12 +13,12 @@ import sys import tempfile import threading -import time import unittest from unittest import mock from nullius import constraints, prerequisites, settings from nullius.standard import container, definitions, install, recipe, run +from tests.execution_support import gone ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures", "standard", "catalogue") ALL = {"cpus": 2, "memory_mb": 512, "processes": 100, "concurrency": 3, "cpu_set": "0-1", "gpu_ids": [0]} @@ -502,9 +502,7 @@ def test_a_unit_past_its_timeout_is_killed_with_its_group(self): run.run_group(cmd, 1, env=env) with open(f"{d}/child") as f: child = int(f.read()) - time.sleep(0.2) - with self.assertRaises(ProcessLookupError): # the background child went with its group - os.kill(child, 0) + self.assertTrue(gone(child, 30), "the background child outlived its group") # under its own 60 s: a child left running fails def probe(self, values=None, ssh=False, systemctl=0, linger="yes", runs="exit 0", bus=True, booted=True, v2=True, tools=True): """``scope_check`` against stand-ins for systemd's programs and files.""" diff --git a/app/tests/test_kit_check_isolation.py b/app/tests/test_kit_check_isolation.py index 5de23955..6acceab1 100644 --- a/app/tests/test_kit_check_isolation.py +++ b/app/tests/test_kit_check_isolation.py @@ -49,9 +49,9 @@ def plant_calc(self): def test_on_docker_the_fix_check_runs_in_a_container_of_the_units_image(self): d = self.driver(**{container.CHECK_IMAGE: "nullius/base:test", "PATH": self.bin + os.pathsep + os.environ["PATH"]}) - d.request("setup", unit="fix", dir=self.ws, timeout=10) + d.request("setup", unit="fix", dir=self.ws, timeout=60) marker = self.plant_calc() - reply = d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10) + reply = d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=60) self.assertFalse(os.path.exists(marker)) # the agent's calc.py was never imported here self.assertTrue(reply["passed"]) argv = json.loads(Path(self.argv_log).read_text()) @@ -62,9 +62,9 @@ def test_on_docker_the_fix_check_runs_in_a_container_of_the_units_image(self): def test_locally_the_fix_check_runs_here_as_the_agent_did(self): d = self.driver() - d.request("setup", unit="fix", dir=self.ws, timeout=10) + d.request("setup", unit="fix", dir=self.ws, timeout=60) marker = self.plant_calc() - self.assertTrue(d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10)["passed"]) + self.assertTrue(d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=60)["passed"]) self.assertTrue(os.path.exists(marker)) self.assertFalse(os.path.exists(self.argv_log)) @@ -73,11 +73,11 @@ def test_a_planted_link_is_not_followed(self): with open(secret, "w") as f: f.write("nullius-ok") # would even pass, read through the link os.symlink(secret, os.path.join(self.ws, "result.txt")) - reply = self.driver().request("score", unit="write", dir=self.ws, transcript="", answer="", timeout=10) + reply = self.driver().request("score", unit="write", dir=self.ws, transcript="", answer="", timeout=60) self.assertEqual((reply["passed"], reply["detail"]["result.txt"]), (False, None)) bashrc = Path(self.tmp, "bashrc"); bashrc.write_text("mine\n") os.symlink(bashrc, os.path.join(self.ws, "test_calc.py")) # the test is rewritten in place, never through a link - self.driver().request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10) + self.driver().request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=60) self.assertEqual(bashrc.read_text(), "mine\n") diff --git a/app/tests/test_standard_definitions.py b/app/tests/test_standard_definitions.py index ea0c6cb6..8e56a449 100644 --- a/app/tests/test_standard_definitions.py +++ b/app/tests/test_standard_definitions.py @@ -201,7 +201,7 @@ def test_catalogue_check_details_cover_the_driver_units(self): cwd=tmp, env=dict(os.environ, PYTHONPATH=str(APP)), log=os.path.join(tmp, "driver.log")) try: - units = driver.request("units", dataset="kit", timeout=10)["units"] + units = driver.request("units", dataset="kit", timeout=60)["units"] finally: driver.close() details = kit["check_details"] diff --git a/app/tests/test_standard_payload.py b/app/tests/test_standard_payload.py index 38e9ada2..1e58e631 100644 --- a/app/tests/test_standard_payload.py +++ b/app/tests/test_standard_payload.py @@ -350,7 +350,7 @@ def inventory(): before = inventory() for index in range(3): execution_ = execution.Execution(make_plan(index)).start() - execution_.thread.join(15) + execution_.thread.join(60) assert not execution_.thread.is_alive(), "fixture did not finish" assert execution_.state == "done", execution_.lines assert execution_.app_on_target == str(snapshot), "a later launch must reuse the same snapshot" @@ -363,7 +363,7 @@ def inventory(): "snapshot": execution_.app_on_target, "successful_launches": 3})) ''' ran = subprocess.run([str(python), "-I", "-B", "-c", driver], cwd=cwd, env=env, - capture_output=True, text=True, timeout=120) + capture_output=True, text=True, timeout=240) self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr) parent = json.loads(ran.stdout) self.assertEqual(parent["providers"], [str(installed)])