summaryrefslogtreecommitdiffstats
path: root/nixos/tests/fastnetmon-advanced.nix
blob: 957f26017f4ce49d1f79c19b3784fa5c85b9b4ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ pkgs, lib, ... }:

{
  name = "fastnetmon-advanced";
  meta.maintainers = with lib.maintainers; [ yureka-wdz ];

  nodes = {
    bird =
      { ... }:
      {
        networking.firewall.allowedTCPPorts = [ 179 ];
        services.bird = {
          enable = true;
          config = ''
            router id 192.168.1.1;

            protocol bgp fnm {
              local 192.168.1.1 as 64513;
              neighbor 192.168.1.2 as 64514;
              multihop;
              ipv4 {
                import all;
                export none;
              };
            }
          '';
        };
      };
    fnm =
      { ... }:
      {
        networking.firewall.allowedTCPPorts = [ 179 ];
        services.fastnetmon-advanced = {
          enable = true;
          settings = {
            networks_list = [ "172.23.42.0/24" ];
            gobgp = true;
            gobgp_flow_spec_announces = true;
          };
          bgpPeers = {
            bird = {
              local_asn = 64514;
              remote_asn = 64513;
              local_address = "192.168.1.2";
              remote_address = "192.168.1.1";

              description = "Bird";
              ipv4_unicast = true;
              multihop = true;
              active = true;
            };
          };
        };
      };
  };

  testScript =
    { nodes, ... }:
    ''
      start_all()
      fnm.wait_for_unit("fastnetmon.service")
      bird.wait_for_unit("bird.service")

      fnm.wait_until_succeeds('journalctl -eu fastnetmon.service | grep "BGP daemon restarted correctly"')
      fnm.wait_until_succeeds('journalctl -eu gobgp.service | grep "Peer Up"')
      bird.wait_until_succeeds("birdc show protocol fnm | grep Estab")
      fnm.wait_until_succeeds('journalctl -eu fastnetmon.service | grep "API server listening"')
      fnm.succeed("fcli set blackhole 172.23.42.123")
      bird.succeed("birdc show route | grep 172.23.42.123")
    '';
}