summary refs log tree commit diff
path: root/nixos/tests/iftop.nix
diff options
context:
space:
mode:
authorxeji <36407913+xeji@users.noreply.github.com>2018-06-01 22:27:51 +0200
committerGitHub <noreply@github.com>2018-06-01 22:27:51 +0200
commitb17b44232f5dd69f399c168c0c5ca87c58af0063 (patch)
tree82eced0bfc0a6db9c51aa9d7e399c4dc819aaa06 /nixos/tests/iftop.nix
parent6cd5863060a48b7d0331dd2f69a7cfd43417d4a3 (diff)
downloadnixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar.gz
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar.bz2
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar.lz
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar.xz
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.tar.zst
nixpkgs-b17b44232f5dd69f399c168c0c5ca87c58af0063.zip
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
Diffstat (limited to 'nixos/tests/iftop.nix')
-rw-r--r--nixos/tests/iftop.nix14
1 files changed, 9 insertions, 5 deletions
diff --git a/nixos/tests/iftop.nix b/nixos/tests/iftop.nix
index 21ff3cafed7..a4f524ceb27 100644
--- a/nixos/tests/iftop.nix
+++ b/nixos/tests/iftop.nix
@@ -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'");
     };
   '';
 })