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 ({ pkgs, ... }:
11 ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
15 network 192.168.0.0/16 area 0
20 ip ospf hello-interval 1
21 ip ospf dead-interval 5
24 network 192.168.0.0/16 area 0
31 meta = with pkgs.lib.maintainers; {
32 maintainers = [ hexa ];
40 virtualisation.vlans = [ 1 ];
41 networking.defaultGateway = ifAddr nodes.router1 "eth1";
47 virtualisation.vlans = [ 1 2 ];
48 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
49 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
55 specialisation.ospf.configuration = {
56 services.frr.ospf.config = ospfConf2;
63 virtualisation.vlans = [ 3 2 ];
64 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
65 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
75 virtualisation.vlans = [ 3 ];
76 networking.defaultGateway = ifAddr nodes.router2 "eth1";
85 # Wait for the networking to start on all machines
86 for machine in client, router1, router2, server:
87 machine.wait_for_unit("network.target")
89 with subtest("Wait for Zebra and OSPFD"):
90 for gw in router1, router2:
91 gw.wait_for_unit("zebra")
92 gw.wait_for_unit("ospfd")
94 router1.succeed("${nodes.router1.config.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
96 with subtest("Wait for OSPF to form adjacencies"):
97 for gw in router1, router2:
98 gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
99 gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
101 with subtest("Test ICMP"):
102 client.wait_until_succeeds("ping -c 3 server >&2")