Skip to content

Commit 99ad7da

Browse files
authored
nixosTests.frr: fix node.router.config warning (#354710)
2 parents a44589e + 1cc8143 commit 99ad7da

File tree

1 file changed

+87
-79
lines changed

1 file changed

+87
-79
lines changed

nixos/tests/frr.nix

Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
#
66
# All interfaces are in OSPF Area 0.
77

8-
import ./make-test-python.nix ({ pkgs, ... }:
8+
import ./make-test-python.nix (
9+
{ pkgs, ... }:
910
let
1011

11-
ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
12+
ifAddr = node: iface: (pkgs.lib.head node.networking.interfaces.${iface}.ipv4.addresses).address;
1213

1314
ospfConf1 = ''
1415
router ospf
@@ -25,87 +26,94 @@ import ./make-test-python.nix ({ pkgs, ... }:
2526
'';
2627

2728
in
28-
{
29-
name = "frr";
30-
31-
meta = with pkgs.lib.maintainers; {
32-
maintainers = [ ];
33-
};
34-
35-
nodes = {
36-
37-
client =
38-
{ nodes, ... }:
39-
{
40-
virtualisation.vlans = [ 1 ];
41-
services.frr = {
42-
config = ''
43-
ip route 192.168.0.0/16 ${ifAddr nodes.router1 "eth1"}
44-
'';
45-
};
46-
};
29+
{
30+
name = "frr";
4731

48-
router1 =
49-
{ ... }:
50-
{
51-
virtualisation.vlans = [ 1 2 ];
52-
boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
53-
networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
54-
services.frr = {
55-
ospfd.enable = true;
56-
config = ospfConf1;
57-
};
58-
59-
specialisation.ospf.configuration = {
60-
services.frr.config = ospfConf2;
61-
};
62-
};
32+
meta = with pkgs.lib.maintainers; {
33+
maintainers = [ ];
34+
};
35+
36+
nodes = {
6337

64-
router2 =
65-
{ ... }:
66-
{
67-
virtualisation.vlans = [ 3 2 ];
68-
boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
69-
networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
70-
services.frr = {
71-
ospfd.enable = true;
72-
config = ospfConf2;
73-
};
38+
client =
39+
{ nodes, ... }:
40+
{
41+
virtualisation.vlans = [ 1 ];
42+
services.frr = {
43+
config = ''
44+
ip route 192.168.0.0/16 ${ifAddr nodes.router1 "eth1"}
45+
'';
46+
};
47+
};
48+
49+
router1 =
50+
{ ... }:
51+
{
52+
virtualisation.vlans = [
53+
1
54+
2
55+
];
56+
boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
57+
networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
58+
services.frr = {
59+
ospfd.enable = true;
60+
config = ospfConf1;
7461
};
7562

76-
server =
77-
{ nodes, ... }:
78-
{
79-
virtualisation.vlans = [ 3 ];
80-
services.frr = {
81-
config = ''
82-
ip route 192.168.0.0/16 ${ifAddr nodes.router2 "eth1"}
83-
'';
84-
};
63+
specialisation.ospf.configuration = {
64+
services.frr.config = ospfConf2;
65+
};
66+
};
67+
68+
router2 =
69+
{ ... }:
70+
{
71+
virtualisation.vlans = [
72+
3
73+
2
74+
];
75+
boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
76+
networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
77+
services.frr = {
78+
ospfd.enable = true;
79+
config = ospfConf2;
8580
};
86-
};
81+
};
8782

88-
testScript =
83+
server =
8984
{ nodes, ... }:
90-
''
91-
start_all()
92-
93-
# Wait for the networking to start on all machines
94-
for machine in client, router1, router2, server:
95-
machine.wait_for_unit("network.target")
96-
97-
with subtest("Wait for FRR"):
98-
for gw in client, router1, router2, server:
99-
gw.wait_for_unit("frr")
100-
101-
router1.succeed("${nodes.router1.config.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
102-
103-
with subtest("Wait for OSPF to form adjacencies"):
104-
for gw in router1, router2:
105-
gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
106-
gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
107-
108-
with subtest("Test ICMP"):
109-
client.wait_until_succeeds("ping -4 -c 3 server >&2")
110-
'';
111-
})
85+
{
86+
virtualisation.vlans = [ 3 ];
87+
services.frr = {
88+
config = ''
89+
ip route 192.168.0.0/16 ${ifAddr nodes.router2 "eth1"}
90+
'';
91+
};
92+
};
93+
};
94+
95+
testScript =
96+
{ nodes, ... }:
97+
''
98+
start_all()
99+
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")
103+
104+
with subtest("Wait for FRR"):
105+
for gw in client, router1, router2, server:
106+
gw.wait_for_unit("frr")
107+
108+
router1.succeed("${nodes.router1.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
109+
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>'")
114+
115+
with subtest("Test ICMP"):
116+
client.wait_until_succeeds("ping -4 -c 3 server >&2")
117+
'';
118+
}
119+
)

0 commit comments

Comments
 (0)