mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
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.
This commit is contained in:
parent
4d12b79cd7
commit
8022c82a39
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user