2015-03-05 15:21:27 +01:00
|
|
|
# Test whether hibernation from partition works.
|
|
|
|
|
2019-11-09 20:05:18 +01:00
|
|
|
import ./make-test-python.nix (pkgs: {
|
2015-03-05 15:21:27 +01:00
|
|
|
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 ];
|
|
|
|
|
2017-04-02 01:21:59 +02:00
|
|
|
systemd.services.listener.serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l 4444 -k";
|
2015-03-05 15:21:27 +01:00
|
|
|
};
|
|
|
|
|
2018-07-20 22:56:59 +02:00
|
|
|
probe = { pkgs, ...}: {
|
2015-03-05 15:21:27 +01:00
|
|
|
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 =
|
|
|
|
''
|
2019-11-09 20:05:18 +01:00
|
|
|
machine.start()
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
machine.succeed("mkswap /dev/vdb")
|
|
|
|
machine.succeed("swapon -a")
|
|
|
|
machine.start_job("listener")
|
|
|
|
machine.wait_for_open_port(4444)
|
|
|
|
machine.succeed("systemctl hibernate &")
|
|
|
|
machine.wait_for_shutdown()
|
|
|
|
probe.wait_for_unit("multi-user.target")
|
|
|
|
machine.start()
|
|
|
|
probe.wait_until_succeeds("echo test | nc machine 4444 -N")
|
2015-03-05 15:21:27 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
})
|