summary refs log tree commit diff
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2023-09-13 19:14:08 +0200
committerJanne Heß <janne@hess.ooo>2023-09-22 10:26:11 +0200
commit358347e8b651ae24413c2abb7640c8c8e1786a1f (patch)
tree1480d667518ecb738e9d32dcd7b9833363d2f276
parent85c1c30fd9ab350ad254736d0950d07639b9f6e8 (diff)
downloadnixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar.gz
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar.bz2
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar.lz
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar.xz
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.tar.zst
nixpkgs-358347e8b651ae24413c2abb7640c8c8e1786a1f.zip
nixos/switchTest: Also test swap devices
-rw-r--r--nixos/tests/switch-test.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix
index 5e9b38d2913..5ffdf180d5e 100644
--- a/nixos/tests/switch-test.nix
+++ b/nixos/tests/switch-test.nix
@@ -85,6 +85,10 @@ in {
           virtualisation.fileSystems."/".device = lib.mkForce "auto";
         };
 
+        swap.configuration.swapDevices = lib.mkVMOverride [
+          { device = "/swapfile"; size = 1; }
+        ];
+
         simpleService.configuration = {
           systemd.services.test = {
             wantedBy = [ "multi-user.target" ];
@@ -741,6 +745,26 @@ in {
         assert_lacks(out, "\nstarting the following units:")
         assert_lacks(out, "the following new units were started:")
 
+    with subtest("swaps"):
+        switch_to_specialisation("${machine}", "")
+        # add a swap
+        out = switch_to_specialisation("${machine}", "swap")
+        assert_lacks(out, "stopping the following units:")
+        assert_lacks(out, "NOT restarting the following changed units:")
+        assert_contains(out, "reloading the following units: dbus.service\n")
+        assert_lacks(out, "\nrestarting the following units:")
+        assert_lacks(out, "\nstarting the following units:")
+        assert_contains(out, "the following new units were started: swapfile.swap")
+        # remove it
+        out = switch_to_specialisation("${machine}", "")
+        assert_contains(out, "stopping swap device: /swapfile")
+        assert_lacks(out, "stopping the following units:")
+        assert_lacks(out, "NOT restarting the following changed units:")
+        assert_contains(out, "reloading the following units: dbus.service\n")
+        assert_lacks(out, "\nrestarting the following units:")
+        assert_lacks(out, "\nstarting the following units:")
+        assert_lacks(out, "the following new units were started:")
+
     with subtest("services"):
         switch_to_specialisation("${machine}", "")
         # Nothing happens when nothing is changed