1 # This test runs FRR and checks if OSPF routing works.
4 # [ client ]--net1--[ router1 ]--net2--[ router2 ]--net3--[ server ]
6 # All interfaces are in OSPF Area 0.
8 import ./make-test-python.nix (
12 ifAddr = node: iface: (pkgs.lib.head node.networking.interfaces.${iface}.ipv4.addresses).address;
16 network 192.168.0.0/16 area 0
21 ip ospf hello-interval 1
22 ip ospf dead-interval 5
25 network 192.168.0.0/16 area 0
32 meta = with pkgs.lib.maintainers; {
41 virtualisation.vlans = [ 1 ];
44 ip route 192.168.0.0/16 ${ifAddr nodes.router1 "eth1"}
52 virtualisation.vlans = [
56 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
57 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
63 specialisation.ospf.configuration = {
64 services.frr.config = ospfConf2;
71 virtualisation.vlans = [
75 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
76 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
86 virtualisation.vlans = [ 3 ];
89 ip route 192.168.0.0/16 ${ifAddr nodes.router2 "eth1"}
100 # Wait for the networking to start on all machines
101 for machine in client, router1, router2, server:
102 machine.wait_for_unit("network.target")
104 with subtest("Wait for FRR"):
105 for gw in client, router1, router2, server:
106 gw.wait_for_unit("frr")
108 router1.succeed("${nodes.router1.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
110 with subtest("Wait for OSPF to form adjacencies"):
111 for gw in router1, router2:
112 gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
113 gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
115 with subtest("Test ICMP"):
116 client.wait_until_succeeds("ping -4 -c 3 server >&2")