mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
affce1e246
There was one confusing recent failure of this: http://cache.nixos.org/log/myla8bc17j8spmifdxmrz9jswxwsf5w6-vm-test-run-hibernate.drv I don't have any real ideas on what could cause the problem but there is at least one theoretical one: the system starts hibernating before the listener process manages to open the TCP port for listening, and it can't open it after resuming because not enough pages from the netcat binary have been paged in (and as the 9p filesystem holding it is now toast, they can't be loaded anymore).
44 lines
1.3 KiB
Nix
44 lines
1.3 KiB
Nix
# 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 4444 -k";
|
|
};
|
|
|
|
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->waitForOpenPort(4444);
|
|
$machine->succeed("systemctl hibernate &");
|
|
$machine->waitForShutdown;
|
|
$machine->start;
|
|
$probe->waitForUnit("network.target");
|
|
$probe->waitUntilSucceeds("echo test | nc machine 4444");
|
|
'';
|
|
|
|
})
|