about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-02-25 18:03:55 +0100
committerDominique Martinet <asmadeus@codewreck.org>2022-02-26 19:13:40 +0900
commit8022c82a39c19bd1fe000884703601532204b82f (patch)
tree19690a1d3a46dff8c4795d91d8e58861c0a602ee /nixos
parent4d12b79cd7edfbe01216171dd6ef0e4c64851b0a (diff)
downloadnixlib-8022c82a39c19bd1fe000884703601532204b82f.tar
nixlib-8022c82a39c19bd1fe000884703601532204b82f.tar.gz
nixlib-8022c82a39c19bd1fe000884703601532204b82f.tar.bz2
nixlib-8022c82a39c19bd1fe000884703601532204b82f.tar.lz
nixlib-8022c82a39c19bd1fe000884703601532204b82f.tar.xz
nixlib-8022c82a39c19bd1fe000884703601532204b82f.tar.zst
nixlib-8022c82a39c19bd1fe000884703601532204b82f.zip
nixosTests.switchTest: fix race condition on /testpath
Currently the test-watch.service gets started in a loop as long as
/testpath exists, so `rm /testpath /testpath-modified` runs into a race
condition where if the service was just getting activated, it will
create /testpath-modified and make the test fail.

This is fixed by making the service RemainAfterExit so that it only
starts once, and stopping it manually after we remove /testpath.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/switch-test.nix2
1 files changed, 2 insertions, 0 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix
index 4f297b6521d1..b429babce838 100644
--- a/nixos/tests/switch-test.nix
+++ b/nixos/tests/switch-test.nix
@@ -283,6 +283,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
           systemd.services.test-watch = {
             serviceConfig = {
               Type = "oneshot";
+              RemainAfterExit = true;
               ExecStart = "${pkgs.coreutils}/bin/touch /testpath-modified";
             };
           };
@@ -723,6 +724,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
         machine.succeed("touch /testpath")
         machine.wait_until_succeeds("test -f /testpath-modified")
         machine.succeed("rm /testpath /testpath-modified")
+        machine.systemctl("stop test-watch.service")
         switch_to_specialisation("${machine}", "pathModified")
         machine.succeed("touch /testpath")
         machine.fail("test -f /testpath-modified")