diff options
author | Janne Heß <janne@hess.ooo> | 2021-10-10 18:08:36 +0200 |
---|---|---|
committer | Janne Heß <janne@hess.ooo> | 2021-10-17 14:35:46 +0200 |
commit | adc033cd5935feb85dc3477a37d2ce1c1384837b (patch) | |
tree | c595563e0afaa5ee4f95cff5f652a4409121faa1 /nixos/tests/switch-test.nix | |
parent | de128feaccaf9751d7092d83f7dcc488f51a4dda (diff) |
nixos/switch-to-configuration: Ignore path units
Diffstat (limited to 'nixos/tests/switch-test.nix')
-rw-r--r-- | nixos/tests/switch-test.nix | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index 1acccbd175406..be8f22f5082a0 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -131,6 +131,26 @@ import ./make-test-python.nix ({ pkgs, ...} : { }; }; + # A system with a path unit + with-path.configuration = { + systemd.paths.test-watch = { + wantedBy = [ "paths.target" ]; + pathConfig.PathExists = "/testpath"; + }; + systemd.services.test-watch = { + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.coreutils}/bin/touch /testpath-modified"; + }; + }; + }; + + # The same system but watching another file + with-path-modified.configuration = { + imports = [ config.specialisation.with-path.configuration ]; + systemd.paths.test-watch.pathConfig.PathExists = lib.mkForce "/testpath2"; + }; + # A system with a slice with-slice.configuration = { systemd.slices.testslice.sliceConfig.MemoryMax = "1"; # don't allow memory allocation @@ -284,6 +304,22 @@ import ./make-test-python.nix ({ pkgs, ...} : { assert_contains(out, "would restart the following units: simple-restart-service.service\n") assert_contains(out, "\nwould start the following units: simple-service.service") + with subtest("paths"): + switch_to_specialisation("with-path") + machine.fail("test -f /testpath-modified") + + # touch the file, unit should be triggered + machine.succeed("touch /testpath") + machine.wait_until_succeeds("test -f /testpath-modified") + + machine.succeed("rm /testpath /testpath-modified") + switch_to_specialisation("with-path-modified") + + machine.succeed("touch /testpath") + machine.fail("test -f /testpath-modified") + machine.succeed("touch /testpath2") + machine.wait_until_succeeds("test -f /testpath-modified") + # This test ensures that changes to slice configuration get applied. # We test this by having a slice that allows no memory allocation at # all and starting a service within it. If the service crashes, the slice |