nixos/tests/iftop: fix non-deterministic failure (#41309)

- make sure machines are fully booted before sending commands
- test that capability setting in iftop module makes a difference
This commit is contained in:
xeji 2018-06-01 22:27:51 +02:00 committed by GitHub
parent 6cd5863060
commit b17b44232f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,22 +9,26 @@ with lib;
nodes = {
withIftop = {
imports = [ ./common/user-account.nix ];
programs.iftop.enable = true;
};
withoutIftop = {
imports = [ ./common/user-account.nix ];
environment.systemPackages = [ pkgs.iftop ];
};
};
testScript = ''
subtest "machine with iftop enabled", sub {
$withIftop->start;
$withIftop->succeed("su -l alice -c 'iftop -t -s 1'");
$withIftop->waitForUnit("default.target");
# limit to eth1 (eth0 is the test driver's control interface)
# and don't try name lookups
$withIftop->succeed("su -l alice -c 'iftop -t -s 1 -n -i eth1'");
};
subtest "machine without iftop", sub {
$withoutIftop->start;
$withoutIftop->mustFail("su -l alice -c 'iftop -t -s 1'");
$withoutIftop->waitForUnit("default.target");
# check that iftop is there but user alice lacks capabilities
$withoutIftop->succeed("iftop -t -s 1 -n -i eth1");
$withoutIftop->fail("su -l alice -c 'iftop -t -s 1 -n -i eth1'");
};
'';
})