nixpkgs/nixos/tests/hibernate.nix
aszlig 146cb02542
nixos/tests/hibernate: Fix netcat flags
I'm not sure why 024b501907eafbd89624e465ff21afbc96e9fec6 used -q 0
because even netcat-openbsd has the -N flag which IMO is the better way
to shutdown the socket on EOF.

Our default netcat implementation has changed once again[1] in
3c3b82234a6faa5a4c07323d0066452055d1ea81 and we're now using LibreSSL's
implementation, which doesn't have a -q flag.

See https://github.com/NixOS/nixpkgs/pull/39634 for the pull request
introducing the switch.

[1]: https://github.com/NixOS/nixpkgs/pull/19982

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @matthewbauer, @dtzWill, @Mic92
2018-04-29 23:46:47 +02:00

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 -N");
'';
})