notes: 2.3.0 -> 2.3.1 (#352950)
[NixPkgs.git] / nixos / tests / gobgpd.nix
blob775f65d1199f3719249be41e168ebeb139e2efbb
1 import ./make-test-python.nix ({ pkgs, ... }:
2   let
3     ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
4   in {
5     name = "gobgpd";
7     meta = with pkgs.lib.maintainers; { maintainers = [ higebu ]; };
9     nodes = {
10       node1 = { nodes, ... }: {
11         environment.systemPackages = [ pkgs.gobgp ];
12         networking.firewall.allowedTCPPorts = [ 179 ];
13         services.gobgpd = {
14           enable = true;
15           settings = {
16             global = {
17               config = {
18                 as = 64512;
19                 router-id = "192.168.255.1";
20               };
21             };
22             neighbors = [{
23               config = {
24                 neighbor-address = ifAddr nodes.node2 "eth1";
25                 peer-as = 64513;
26               };
27             }];
28           };
29         };
30       };
31       node2 = { nodes, ... }: {
32         environment.systemPackages = [ pkgs.gobgp ];
33         networking.firewall.allowedTCPPorts = [ 179 ];
34         services.gobgpd = {
35           enable = true;
36           settings = {
37             global = {
38               config = {
39                 as = 64513;
40                 router-id = "192.168.255.2";
41               };
42             };
43             neighbors = [{
44               config = {
45                 neighbor-address = ifAddr nodes.node1 "eth1";
46                 peer-as = 64512;
47               };
48             }];
49           };
50         };
51       };
52     };
54     testScript = { nodes, ... }: let
55       addr1 = ifAddr nodes.node1 "eth1";
56       addr2 = ifAddr nodes.node2 "eth1";
57     in
58       ''
59       start_all()
61       for node in node1, node2:
62           with subtest("should start gobgpd node"):
63               node.wait_for_unit("gobgpd.service")
64           with subtest("should open port 179"):
65               node.wait_for_open_port(179)
67       with subtest("should show neighbors by gobgp cli and BGP state should be ESTABLISHED"):
68           node1.wait_until_succeeds("gobgp neighbor ${addr2} | grep -q ESTABLISHED")
69           node2.wait_until_succeeds("gobgp neighbor ${addr1} | grep -q ESTABLISHED")
70     '';
71   })