Author: eelco
Date: Sat Feb 19 19:21:19 2011
New Revision: 26036
URL: https://svn.nixos.org/websvn/nix/?rev=26036&sc=1

Log:
* Add a test of IPv6 support.

Added:
   nixos/trunk/tests/ipv6.nix
Modified:
   nixos/trunk/tests/default.nix

Modified: nixos/trunk/tests/default.nix
==============================================================================
--- nixos/trunk/tests/default.nix       Sat Feb 19 19:19:55 2011        (r26035)
+++ nixos/trunk/tests/default.nix       Sat Feb 19 19:21:19 2011        (r26036)
@@ -10,6 +10,7 @@
   bittorrent = makeTest (import ./bittorrent.nix);
   firefox = makeTest (import ./firefox.nix);
   installer = makeTests (import ./installer.nix);
+  ipv6 = makeTest (import ./ipv6.nix);
   kde4 = makeTest (import ./kde4.nix);
   login = makeTest (import ./login.nix);
   nat = makeTest (import ./nat.nix);

Added: nixos/trunk/tests/ipv6.nix
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nixos/trunk/tests/ipv6.nix  Sat Feb 19 19:21:19 2011        (r26036)
@@ -0,0 +1,76 @@
+# Test of IPv6 functionality in NixOS, including whether router
+# solicication/advertisement using radvd works.
+
+{ pkgs, ... }:
+
+{
+
+  nodes =
+    { client = { config, pkgs, ... }: { };
+    
+      server =
+        { config, pkgs, ... }:
+        { services.httpd.enable = true;
+          services.httpd.adminAddr = "[email protected]";
+        };
+
+      router = 
+        { config, pkgs, ... }:
+        { services.radvd.enable = true;
+          services.radvd.config =
+            ''
+              interface eth1 {
+                AdvSendAdvert on;
+                # ULA prefix (RFC 4193).
+                prefix fd60:cc69:b537:1::/64 { };
+              };
+            '';
+        };
+    };
+
+  testScript =
+    ''
+      # Start the router first so that it respond to router solicitations.
+      $router->waitForJob("radvd");
+    
+      startAll;
+    
+      $client->waitForJob("network-interfaces");
+      $server->waitForJob("network-interfaces");
+
+      # Wait until the given interface has a non-tentative address of
+      # the desired scope (i.e. has completed Duplicate Address
+      # Detection).
+      sub waitForAddress {
+          my ($machine, $iface, $scope) = @_;
+          $machine->waitUntilSucceeds("[ `ip -o -6 addr show dev $iface scope 
$scope | grep -v tentative | wc -l` -eq 1 ]");
+          my $ip = (split /[ \/]+/, $machine->succeed("ip -o -6 addr show dev 
$iface scope $scope"))[3];
+          $machine->log("$scope address on $iface is $ip");
+          return $ip;
+      }
+      
+      subtest "loopback address", sub {
+          $client->succeed("ping6 -c 1 ::1 >&2");  
+          $client->fail("ping6 -c 1 ::2 >&2");  
+      };
+    
+      subtest "local link addressing", sub {
+          my $clientIp = waitForAddress $client, "eth1", "link";
+          my $serverIp = waitForAddress $server, "eth1", "link";
+          $client->succeed("ping6 -c 1 -I eth1 $clientIp >&2");
+          $client->succeed("ping6 -c 1 -I eth1 $serverIp >&2");
+      };
+
+      subtest "global addressing", sub {
+          my $clientIp = waitForAddress $client, "eth1", "global";
+          my $serverIp = waitForAddress $server, "eth1", "global";
+          $client->succeed("ping6 -c 1 $clientIp >&2");
+          $client->succeed("ping6 -c 1 $serverIp >&2");
+          $client->succeed("curl --fail -g http://[$serverIp]";);
+          $client->fail("curl --fail -g http://[$clientIp]";);
+      };
+
+      # TODO: test reachability of a machine on another network.
+    '';
+
+}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to