1# This test does a basic functionality check for birdwatcher
2
3{
4 system ? builtins.currentSystem,
5 pkgs ? import ../.. {
6 inherit system;
7 config = { };
8 },
9}:
10
11let
12 inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
13 inherit (pkgs.lib) optionalString;
14in
15makeTest {
16 name = "birdwatcher";
17 nodes = {
18 host1 = {
19 environment.systemPackages = with pkgs; [ jq ];
20 services.bird = {
21 enable = true;
22 config = ''
23 log syslog all;
24
25 debug protocols all;
26
27 router id 10.0.0.1;
28
29 protocol device {
30 }
31
32 protocol kernel kernel4 {
33 ipv4 {
34 import none;
35 export all;
36 };
37 }
38
39 protocol kernel kernel6 {
40 ipv6 {
41 import none;
42 export all;
43 };
44 }
45 '';
46 };
47 services.birdwatcher = {
48 enable = true;
49 settings = ''
50 [server]
51 allow_from = []
52 allow_uncached = false
53 modules_enabled = ["status",
54 "protocols",
55 "protocols_bgp",
56 "protocols_short",
57 "routes_protocol",
58 "routes_peer",
59 "routes_table",
60 "routes_table_filtered",
61 "routes_table_peer",
62 "routes_filtered",
63 "routes_prefixed",
64 "routes_noexport",
65 "routes_pipe_filtered_count",
66 "routes_pipe_filtered"
67 ]
68 [status]
69 reconfig_timestamp_source = "bird"
70 reconfig_timestamp_match = "# created: (.*)"
71 filter_fields = []
72 [bird]
73 listen = "0.0.0.0:29184"
74 config = "/etc/bird/bird.conf"
75 birdc = "${pkgs.bird2}/bin/birdc"
76 ttl = 5 # time to live (in minutes) for caching of cli output
77 [parser]
78 filter_fields = []
79 [cache]
80 use_redis = false # if not using redis cache, activate housekeeping to save memory!
81 [housekeeping]
82 interval = 5
83 force_release_memory = true
84 '';
85 };
86 };
87 };
88
89 testScript = ''
90 start_all()
91
92 host1.wait_for_unit("bird.service")
93 host1.wait_for_unit("birdwatcher.service")
94 host1.wait_for_open_port(29184)
95 host1.succeed("curl http://[::]:29184/status | jq -r .status.message | grep 'Daemon is up and running'")
96 host1.succeed("curl http://[::]:29184/protocols | jq -r .protocols.device1.state | grep 'up'")
97 '';
98}