diff options
author | Nikolay Amiantov <ab@fmap.me> | 2015-03-05 17:21:27 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-07-19 05:20:02 +0300 |
commit | 9cc70b419cc75bbf7f3224ad9f6848760adac1fd (patch) | |
tree | fb96a000833cb7f3e80ca4c38d26431f762da456 /nixos/tests/hibernate.nix | |
parent | 399db54e3514ceaee82ec217140975d77963359f (diff) |
nixos/tests: add hibernation test
Diffstat (limited to 'nixos/tests/hibernate.nix')
-rw-r--r-- | nixos/tests/hibernate.nix | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/tests/hibernate.nix b/nixos/tests/hibernate.nix new file mode 100644 index 0000000000000..787929f8904df --- /dev/null +++ b/nixos/tests/hibernate.nix @@ -0,0 +1,42 @@ +# Test whether hibernation from partition works. + +import ./make-test.nix (pkgs: { + name = "hibernate"; + + nodes = { + machine = { config, lib, pkgs, ... }: with lib; { + virtualisation.emptyDiskImages = [ config.virtualisation.memorySize ]; + + systemd.services.backdoor.conflicts = [ "sleep.target" ]; + + swapDevices = mkOverride 0 [ { device = "/dev/vdb"; } ]; + + networking.firewall.allowedTCPPorts = [ 4444 ]; + + systemd.services.listener.serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l -p 4444"; + }; + + probe = { config, lib, pkgs, ...}: { + environment.systemPackages = [ pkgs.netcat ]; + }; + }; + + # 9P doesn't support reconnection to virtio transport after a hibernation. + # Therefore, machine just hangs on any Nix store access. + # To work around it we run a daemon which listens to a TCP connection and + # try to connect to it as a test. + + testScript = + '' + $machine->waitForUnit("multi-user.target"); + $machine->succeed("mkswap /dev/vdb"); + $machine->succeed("swapon -a"); + $machine->startJob("listener"); + $machine->succeed("systemctl hibernate &"); + $machine->waitForShutdown; + $machine->start; + $probe->waitForUnit("network.target"); + $probe->waitUntilSucceeds("echo test | nc -c machine 4444"); + ''; + +}) |