1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-30 09:31:01 +00:00
nixpkgs/nixos/tests/ipv6.nix
Jörg Thalheim fd78ff23f7
replace ping6 with ping
reason: after the upgrade of iputils from 20151218 to 20161105
functionality of ping6 and tracepath6 was merged into ping and tracepath.

Ping is now mostly a drop-in replacment for ping6, except that selecting a
specific interface is done by encoding it into the address (ex.: fe80::1%eth0)
rather then specifing it with the `-I` flag.
2017-02-17 16:04:49 +01:00

80 lines
2.6 KiB
Nix

# Test of IPv6 functionality in NixOS, including whether router
# solicication/advertisement using radvd works.
import ./make-test.nix ({ pkgs, ...} : {
name = "ipv6";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ eelco chaoflow ];
};
nodes =
{ client = { config, pkgs, ... }: { };
server =
{ config, pkgs, ... }:
{ services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
networking.firewall.allowedTCPPorts = [ 80 ];
};
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->waitForUnit("radvd");
startAll;
$client->waitForUnit("network.target");
$server->waitForUnit("network.target");
$server->waitForUnit("httpd.service");
# 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("ping -c 1 ::1 >&2");
$client->fail("ping -c 1 ::2 >&2");
};
subtest "local link addressing", sub {
my $clientIp = waitForAddress $client, "eth1", "link";
my $serverIp = waitForAddress $server, "eth1", "link";
$client->succeed("ping -c 1 $clientIp%eth1 >&2");
$client->succeed("ping -c 1 $serverIp%eth1 >&2");
};
subtest "global addressing", sub {
my $clientIp = waitForAddress $client, "eth1", "global";
my $serverIp = waitForAddress $server, "eth1", "global";
$client->succeed("ping -c 1 $clientIp >&2");
$client->succeed("ping -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.
'';
})