1 import ./make-test-python.nix (
5 router = {config, pkgs, ...}: {
7 # This machine simulates a router with IPv6 forwarding and a static IPv6 address.
9 "net.ipv6.conf.all.forwarding" = true;
11 networking.interfaces.eth1 = {
12 ipv6.addresses = [ { address = "fd00:dead:beef:dead::1"; prefixLength = 64; } ];
16 # Serve router advertisements to the client machine with prefix information matching
17 # any IPv6 /64 prefixes configured on this interface.
19 # This configuration is identical to the example in the CoreRAD NixOS module.
29 prefix = [{ prefix = "::/64"; }];
33 address = "localhost:9430";
40 client = {config, pkgs, ...}: {
41 # Use IPv6 SLAAC from router advertisements, and install rdisc6 so we can
42 # trigger one immediately.
44 boot.kernel.sysctl = {
45 "net.ipv6.conf.all.autoconf" = true;
47 environment.systemPackages = with pkgs; [
57 with subtest("Wait for CoreRAD and network ready"):
58 # Ensure networking is online and CoreRAD is ready.
59 router.systemctl("start network-online.target")
60 client.systemctl("start network-online.target")
61 router.wait_for_unit("network-online.target")
62 client.wait_for_unit("network-online.target")
63 router.wait_for_unit("corerad.service")
65 # Ensure the client can reach the router.
66 client.wait_until_succeeds("ping -c 1 fd00:dead:beef:dead::1")
68 with subtest("Verify SLAAC on client"):
69 # Trigger a router solicitation and verify a SLAAC address is assigned from
70 # the prefix configured on the router.
71 client.wait_until_succeeds("rdisc6 -1 -r 10 eth1")
72 client.wait_until_succeeds(
73 "ip -6 addr show dev eth1 | grep -q 'fd00:dead:beef:dead:'"
76 addrs = client.succeed("ip -6 addr show dev eth1")
79 "fd00:dead:beef:dead:" in addrs
80 ), "SLAAC prefix was not found in client addresses after router advertisement"
82 "/64 scope global temporary" in addrs
83 ), "SLAAC temporary address was not configured on client after router advertisement"
85 with subtest("Verify HTTP debug server is configured"):
86 out = router.succeed("curl -f localhost:9430/metrics")
89 "corerad_build_info" in out
90 ), "Build info metric was not found in Prometheus output"