diff options
| author | tv <tv@krebsco.de> | 2026-11-12 20:01:47 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 03:24:22 +0100 |
| commit | 08500cfcbb91cda09c6790b916ba97c333cf2df9 (patch) | |
| tree | 5c95f4e03d146eaf909cdfe658ae00ee417761a0 /tests/vm.nix | |
| parent | 1ab4473cddcf8c95956b22c3e6d5c9720a62925e (diff) | |
populate: stop the ssh master also when a signal ends populate
The shell doesn't run the EXIT trap when a signal ends it, so an
interrupted deploy leaves the ssh master, for an hour, and populate's
temporary directory. Populate traps HUP, INT, and TERM and exits, which
runs the EXIT trap.
The shell runs a trap once the command it waits for ends. A signal to
the process group, like the one of an interrupt key, of a closed terminal,
or of timeout, ends that command as well. A signal to populate alone
takes effect after the step that is running.
Phases of scenarios can end populate after some seconds. An edge case
does so while a pipe source's command sleeps, and checks that neither the
ssh master nor the temporary directory remain.
Diffstat (limited to 'tests/vm.nix')
| -rw-r--r-- | tests/vm.nix | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/vm.nix b/tests/vm.nix index 014897a..a203962 100644 --- a/tests/vm.nix +++ b/tests/vm.nix @@ -151,11 +151,15 @@ in pkgs.testers.runNixOSTest { run(node, f"sh {scenario['prepare']}") for i, phase in enumerate(scenario["phases"]): # A hang fails the scenario, not the whole test. + limit = phase["interrupt"] or 600 status, out = deployer.execute( - f"env HOME=/root {phase['env']} timeout 600 {phase['populate']} 2>&1", + f"env HOME=/root {phase['env']} timeout {limit} {phase['populate']} 2>&1", timeout=900, ) - if phase["expect"] is None: + if phase["interrupt"] is not None: + if status != 124: + raise Exception(f"populate {i} ends on its own:\n{out}") + elif phase["expect"] is None: if status != 0: raise Exception(f"populate {i} fails:\n{out}") elif status == 0 or phase["expect"] not in out: |
