at 16.09-beta 1.3 kB view raw
1# Test whether hibernation from partition works. 2 3import ./make-test.nix (pkgs: { 4 name = "hibernate"; 5 6 nodes = { 7 machine = { config, lib, pkgs, ... }: with lib; { 8 virtualisation.emptyDiskImages = [ config.virtualisation.memorySize ]; 9 10 systemd.services.backdoor.conflicts = [ "sleep.target" ]; 11 12 swapDevices = mkOverride 0 [ { device = "/dev/vdb"; } ]; 13 14 networking.firewall.allowedTCPPorts = [ 4444 ]; 15 16 systemd.services.listener.serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l -p 4444"; 17 }; 18 19 probe = { config, lib, pkgs, ...}: { 20 environment.systemPackages = [ pkgs.netcat ]; 21 }; 22 }; 23 24 # 9P doesn't support reconnection to virtio transport after a hibernation. 25 # Therefore, machine just hangs on any Nix store access. 26 # To work around it we run a daemon which listens to a TCP connection and 27 # try to connect to it as a test. 28 29 testScript = 30 '' 31 $machine->waitForUnit("multi-user.target"); 32 $machine->succeed("mkswap /dev/vdb"); 33 $machine->succeed("swapon -a"); 34 $machine->startJob("listener"); 35 $machine->succeed("systemctl hibernate &"); 36 $machine->waitForShutdown; 37 $machine->start; 38 $probe->waitForUnit("network.target"); 39 $probe->waitUntilSucceeds("echo test | nc -c machine 4444"); 40 ''; 41 42})