1import ./make-test-python.nix (
2 { lib, ... }:
3 {
4 name = "flannel";
5
6 meta = with lib.maintainers; {
7 maintainers = [ offline ];
8 };
9
10 nodes =
11 let
12 flannelConfig =
13 { pkgs, ... }:
14 {
15 services.flannel = {
16 enable = true;
17 backend = {
18 Type = "udp";
19 Port = 8285;
20 };
21 network = "10.1.0.0/16";
22 iface = "eth1";
23 etcd.endpoints = [ "http://etcd:2379" ];
24 };
25
26 networking.firewall.allowedUDPPorts = [ 8285 ];
27 };
28 in
29 {
30 etcd =
31 { ... }:
32 {
33 services = {
34 etcd = {
35 enable = true;
36 listenClientUrls = [ "http://0.0.0.0:2379" ]; # requires ip-address for binding
37 listenPeerUrls = [ "http://0.0.0.0:2380" ]; # requires ip-address for binding
38 advertiseClientUrls = [ "http://etcd:2379" ];
39 initialAdvertisePeerUrls = [ "http://etcd:2379" ];
40 initialCluster = [ "etcd=http://etcd:2379" ];
41 };
42 };
43
44 networking.firewall.allowedTCPPorts = [ 2379 ];
45 };
46
47 node1 = flannelConfig;
48 node2 = flannelConfig;
49 };
50
51 testScript = ''
52 start_all()
53
54 node1.wait_for_unit("flannel.service")
55 node2.wait_for_unit("flannel.service")
56
57 node1.wait_until_succeeds("ip l show dev flannel0")
58 ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'")
59 node2.wait_until_succeeds("ip l show dev flannel0")
60 ip2 = node2.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'")
61
62 node1.wait_until_succeeds(f"ping -c 1 {ip2}")
63 node2.wait_until_succeeds(f"ping -c 1 {ip1}")
64 '';
65 }
66)