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