diff options
author | Janne Heß <janne@hess.ooo> | 2021-10-13 22:19:18 +0200 |
---|---|---|
committer | Janne Heß <janne@hess.ooo> | 2021-10-17 14:35:47 +0200 |
commit | 4f870c7d709888f935d7caf6f685c1a4930b1f6d (patch) | |
tree | b169ba1a7d640f208e231644b688beef15d0828c /nixos/tests/switch-test.nix | |
parent | adc033cd5935feb85dc3477a37d2ce1c1384837b (diff) |
nixos/switch-to-configuration: Restart timers
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 be8f22f5082a0..e7891c18ec473 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 timer + with-timer.configuration = { + systemd.timers.test-timer = { + wantedBy = [ "timers.target" ]; + timerConfig.OnCalendar = "@1395716396"; # chosen by fair dice roll + }; + systemd.services.test-timer = { + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.coreutils}/bin/true"; + }; + }; + }; + + # The same system but with another time + with-timer-modified.configuration = { + imports = [ config.specialisation.with-timer.configuration ]; + systemd.timers.test-timer.timerConfig.OnCalendar = lib.mkForce "Fri 2012-11-23 16:00:00"; + }; + # A system with a path unit with-path.configuration = { systemd.paths.test-watch = { @@ -304,6 +324,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("timers"): + switch_to_specialisation("with-timer") + out = machine.succeed("systemctl show test-timer.timer") + assert_contains(out, "OnCalendar=2014-03-25 02:59:56 UTC") + + out = switch_to_specialisation("with-timer-modified") + assert_lacks(out, "stopping the following units:") + assert_lacks(out, "reloading the following units:") + assert_contains(out, "restarting the following units: test-timer.timer\n") + assert_lacks(out, "\nstarting the following units:") + assert_lacks(out, "the following new units were started:") + assert_lacks(out, "as well:") + # It changed + out = machine.succeed("systemctl show test-timer.timer") + assert_contains(out, "OnCalendar=Fri 2012-11-23 16:00:00") + with subtest("paths"): switch_to_specialisation("with-path") machine.fail("test -f /testpath-modified") |