about summary refs log tree commit diff
path: root/nixos/tests/switch-test.nix
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2023-08-13 14:25:24 +0200
committerJanne Heß <janne@hess.ooo>2023-08-13 14:25:24 +0200
commit7937c5816df1d4071b24289a41f5f5731b15e288 (patch)
tree116e5d03599755169a96047a8478cea8feb8e8a6 /nixos/tests/switch-test.nix
parentd073105d6b346e4bdc27a22ad50cffcdc8a4b630 (diff)
nixos/switchTest: Also check for base unit modifications
Diffstat (limited to 'nixos/tests/switch-test.nix')
-rw-r--r--nixos/tests/switch-test.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix
index fe6bad1ac054a..53595ae7d3e29 100644
--- a/nixos/tests/switch-test.nix
+++ b/nixos/tests/switch-test.nix
@@ -279,6 +279,28 @@ in {
           systemd.services.test-service.unitConfig.RefuseManualStart = true;
         };
 
+        unitWithTemplate.configuration = {
+          systemd.services."instantiated@".serviceConfig = {
+            Type = "oneshot";
+            RemainAfterExit = true;
+            ExecStart = "${pkgs.coreutils}/bin/true";
+            ExecReload = "${pkgs.coreutils}/bin/true";
+          };
+          systemd.services."instantiated@one" = {
+            wantedBy = [ "multi-user.target" ];
+            overrideStrategy = "asDropin";
+          };
+          systemd.services."instantiated@two" = {
+            wantedBy = [ "multi-user.target" ];
+            overrideStrategy = "asDropin";
+          };
+        };
+
+        unitWithTemplateModified.configuration = {
+          imports = [ unitWithTemplate.configuration ];
+          systemd.services."instantiated@".serviceConfig.X-Test = "test";
+        };
+
         restart-and-reload-by-activation-script.configuration = {
           systemd.services = rec {
             simple-service = {
@@ -770,6 +792,16 @@ in {
         assert_contains(out, "\nstarting the following units: required-service.service\n")
         assert_lacks(out, "the following new units were started:")
 
+        # Ensure templated units are restarted when the base unit changes
+        switch_to_specialisation("${machine}", "unitWithTemplate")
+        out = switch_to_specialisation("${machine}", "unitWithTemplateModified")
+        assert_contains(out, "stopping the following units: instantiated@one.service, instantiated@two.service\n")
+        assert_lacks(out, "NOT restarting the following changed units:")
+        assert_lacks(out, "reloading the following units:")
+        assert_lacks(out, "\nrestarting the following units:")
+        assert_contains(out, "\nstarting the following units: instantiated@one.service, instantiated@two.service\n")
+        assert_lacks(out, "the following new units were started:")
+
     with subtest("failing units"):
         # Let the simple service fail
         switch_to_specialisation("${machine}", "simpleServiceModified")