1import ./make-test.nix ({ pkgs, ...} : rec {
2 name = "flannel";
3
4 meta = with pkgs.stdenv.lib.maintainers; {
5 maintainers = [ offline ];
6 };
7
8 nodes = let
9 flannelConfig = {
10 services.flannel = {
11 enable = true;
12 network = "10.1.0.0/16";
13 iface = "eth1";
14 etcd.endpoints = ["http://etcd:2379"];
15 };
16
17 networking.firewall.allowedUDPPorts = [ 8472 ];
18 };
19 in {
20 etcd = { config, pkgs, ... }: {
21 services = {
22 etcd = {
23 enable = true;
24 listenClientUrls = ["http://etcd:2379"];
25 listenPeerUrls = ["http://etcd:2380"];
26 initialAdvertisePeerUrls = ["http://etcd:2379"];
27 initialCluster = ["etcd=http://etcd:2379"];
28 };
29 };
30
31 networking.firewall.allowedTCPPorts = [ 2379 ];
32 };
33
34 node1 = { config, ... }: {
35 require = [flannelConfig];
36 };
37
38 node2 = { config, ... }: {
39 require = [flannelConfig];
40 };
41 };
42
43 testScript = ''
44 startAll;
45
46 $node1->waitForUnit("flannel.service");
47 $node2->waitForUnit("flannel.service");
48
49 my $ip1 = $node1->succeed("ip -4 addr show flannel.1 | grep -oP '(?<=inet).*(?=/)'");
50 my $ip2 = $node2->succeed("ip -4 addr show flannel.1 | grep -oP '(?<=inet).*(?=/)'");
51
52 $node1->waitUntilSucceeds("ping -c 1 $ip2");
53 $node2->waitUntilSucceeds("ping -c 1 $ip1");
54 '';
55})