1 # This test does a basic functionality check for all bird variants and demonstrates a use
2 # of the preCheckConfig option.
4 { system ? builtins.currentSystem
5 , pkgs ? import ../.. { inherit system; config = { }; }
9 inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
10 inherit (pkgs.lib) optionalString;
12 makeBird2Host = hostId: { pkgs, ... }: {
13 virtualisation.vlans = [ 1 ];
15 environment.systemPackages = with pkgs; [ jq ];
20 firewall.enable = false;
23 systemd.network.networks."01-eth1" = {
25 networkConfig.Address = "10.0.0.${hostId}/24";
36 router id 10.0.0.${hostId};
41 protocol kernel kernel4 {
48 protocol static static4 {
50 include "static4.conf";
53 protocol ospf v2 ospf4 {
65 protocol kernel kernel6 {
72 protocol static static6 {
74 include "static6.conf";
77 protocol ospf v3 ospf6 {
91 echo "route 1.2.3.4/32 blackhole;" > static4.conf
92 echo "route fd00::/128 blackhole;" > static6.conf
96 systemd.tmpfiles.rules = [
97 "f /etc/bird/static4.conf - - - - route 10.10.0.${hostId}/32 blackhole;"
98 "f /etc/bird/static6.conf - - - - route fdff::${hostId}/128 blackhole;"
105 nodes.host1 = makeBird2Host "1";
106 nodes.host2 = makeBird2Host "2";
111 host1.wait_for_unit("bird2.service")
112 host2.wait_for_unit("bird2.service")
113 host1.succeed("systemctl reload bird2.service")
115 with subtest("Waiting for advertised IPv4 routes"):
116 host1.wait_until_succeeds("ip --json r | jq -e 'map(select(.dst == \"10.10.0.2\")) | any'")
117 host2.wait_until_succeeds("ip --json r | jq -e 'map(select(.dst == \"10.10.0.1\")) | any'")
118 with subtest("Waiting for advertised IPv6 routes"):
119 host1.wait_until_succeeds("ip --json -6 r | jq -e 'map(select(.dst == \"fdff::2\")) | any'")
120 host2.wait_until_succeeds("ip --json -6 r | jq -e 'map(select(.dst == \"fdff::1\")) | any'")
122 with subtest("Check fake routes in preCheckConfig do not exists"):
123 host1.fail("ip --json r | jq -e 'map(select(.dst == \"1.2.3.4\")) | any'")
124 host2.fail("ip --json r | jq -e 'map(select(.dst == \"1.2.3.4\")) | any'")
126 host1.fail("ip --json -6 r | jq -e 'map(select(.dst == \"fd00::\")) | any'")
127 host2.fail("ip --json -6 r | jq -e 'map(select(.dst == \"fd00::\")) | any'")