summary refs log tree commit diff
path: root/nixos/tests/ipv6.nix
diff options
context:
space:
mode:
authorMartin Milata <martin@martinmilata.cz>2019-12-08 19:47:15 +0100
committerMartin Milata <martin@martinmilata.cz>2019-12-08 19:51:00 +0100
commit6ebf84a3d6e31d729214663379d25b6a78cb7493 (patch)
tree82612e85e08991d6b99ee60fb1eeb9caf3f62324 /nixos/tests/ipv6.nix
parentead22d14155659dbcf649933a0e5686878443417 (diff)
downloadnixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar.gz
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar.bz2
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar.lz
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar.xz
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.tar.zst
nixpkgs-6ebf84a3d6e31d729214663379d25b6a78cb7493.zip
nixosTests.ipv6: fix waiting for address
wait_for_address sometimes returned tentative address.
Diffstat (limited to 'nixos/tests/ipv6.nix')
-rw-r--r--nixos/tests/ipv6.nix16
1 files changed, 10 insertions, 6 deletions
diff --git a/nixos/tests/ipv6.nix b/nixos/tests/ipv6.nix
index 59dde852737..ba464b57447 100644
--- a/nixos/tests/ipv6.nix
+++ b/nixos/tests/ipv6.nix
@@ -49,12 +49,16 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
       # Wait until the given interface has a non-tentative address of
       # the desired scope (i.e. has completed Duplicate Address
       # Detection).
-      def wait_for_address(machine, iface, scope):
-          machine.wait_until_succeeds(
-              f"[ `ip -o -6 addr show dev {iface} scope {scope} | grep -v tentative | wc -l` -ge 1 ]"
-          )
-          output = machine.succeed(f"ip -o -6 addr show dev {iface} scope {scope}")
+      def wait_for_address(machine, iface, scope, temporary=False):
+          temporary_flag = "temporary" if temporary else "-temporary"
+          cmd = f"ip -o -6 addr show dev {iface} scope {scope} -tentative {temporary_flag}"
+
+          machine.wait_until_succeeds(f"[ `{cmd} | wc -l` -eq 1 ]")
+          output = machine.succeed(cmd)
           ip = re.search(r"inet6 ([0-9a-f:]{2,})/", output).group(1)
+
+          if temporary:
+              scope = scope + " temporary"
           machine.log(f"{scope} address on {iface} is {ip}")
           return ip
 
@@ -78,7 +82,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
           client.fail(f"curl --fail -g http://[{client_ip}]")
 
       with subtest("Privacy extensions: Global temporary address can be obtained and pinged"):
-          ip = wait_for_address(client, "eth1", "global temporary")
+          ip = wait_for_address(client, "eth1", "global", temporary=True)
           # Default route should have "src <temporary address>" in it
           client.succeed(f"ip r g ::2 | grep {ip}")