summary refs log tree commit diff
path: root/nixos/tests/flannel.nix
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2016-09-27 22:56:58 +0200
committerJaka Hudoklin <jakahudoklin@gmail.com>2016-10-01 17:08:48 +0200
commitfeb9fc3aff07698a01163336613224b08547d65b (patch)
tree074dd145cdd32aaaff063b431c45567d60acfa4a /nixos/tests/flannel.nix
parenteb1377ba304f22dc7bb105b456bd685fd937b18f (diff)
downloadnixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar.gz
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar.bz2
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar.lz
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar.xz
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.tar.zst
nixpkgs-feb9fc3aff07698a01163336613224b08547d65b.zip
flannel service: init
Diffstat (limited to 'nixos/tests/flannel.nix')
-rw-r--r--nixos/tests/flannel.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/nixos/tests/flannel.nix b/nixos/tests/flannel.nix
new file mode 100644
index 00000000000..7f27903a302
--- /dev/null
+++ b/nixos/tests/flannel.nix
@@ -0,0 +1,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 = { config, pkgs, ... }: {
+      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 = { config, ... }: {
+      require = [flannelConfig];
+    };
+
+    node2 = { config, ... }: {
+      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");
+  '';
+})