summary refs log tree commit diff
path: root/nixos/tests/flannel.nix
blob: fb66fe282090e1fd97a75a42b1b82c79c2819a61 (plain) (blame)
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
import ./make-test.nix ({ pkgs, ...} : rec {
  name = "flannel";

  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ offline ];
  };

  nodes = let
    flannelConfig = {
      services.flannel = {
        enable = true;
        network = "10.1.0.0/16";
        iface = "eth1";
        etcd.endpoints = ["http://etcd:2379"];
      };

      networking.firewall.allowedUDPPorts = [ 8472 ];
    };
  in {
    etcd = { ... }: {
      services = {
        etcd = {
          enable = true;
          listenClientUrls = ["http://etcd:2379"];
          listenPeerUrls = ["http://etcd:2380"];
          initialAdvertisePeerUrls = ["http://etcd:2379"];
          initialCluster = ["etcd=http://etcd:2379"];
        };
      };

      networking.firewall.allowedTCPPorts = [ 2379 ];
    };

    node1 = { ... }: {
      require = [flannelConfig];
    };

    node2 = { ... }: {
      require = [flannelConfig];
    };
  };

  testScript = ''
    startAll;

    $node1->waitForUnit("flannel.service");
    $node2->waitForUnit("flannel.service");

    my $ip1 = $node1->succeed("ip -4 addr show flannel.1 | grep -oP '(?<=inet).*(?=/)'");
    my $ip2 = $node2->succeed("ip -4 addr show flannel.1 | grep -oP '(?<=inet).*(?=/)'");

    $node1->waitUntilSucceeds("ping -c 1 $ip2");
    $node2->waitUntilSucceeds("ping -c 1 $ip1");
  '';
})