nixpkgs/nixos/tests/flannel.nix
Florian Klink 28ef43824b nixosTests.flannel: port to python, unbreak
For reasons yet unknown, the vxlan backend doesn't work (at least inside
the qemu networking), so this is moved to the udp backend.

Note changing the backend apparently also changes the interface name,
it's now `flannel0`, not `flannel.1`

fixes #74941
2020-04-14 23:56:42 +02:00

57 lines
1.5 KiB
Nix

import ./make-test-python.nix ({ lib, ...} : {
name = "flannel";
meta = with lib.maintainers; {
maintainers = [ offline ];
};
nodes = let
flannelConfig = { pkgs, ... } : {
services.flannel = {
enable = true;
backend = {
Type = "udp";
Port = 8285;
};
network = "10.1.0.0/16";
iface = "eth1";
etcd.endpoints = ["http://etcd:2379"];
};
networking.firewall.allowedUDPPorts = [ 8285 ];
};
in {
etcd = { ... }: {
services = {
etcd = {
enable = true;
listenClientUrls = ["http://0.0.0.0:2379"]; # requires ip-address for binding
listenPeerUrls = ["http://0.0.0.0:2380"]; # requires ip-address for binding
advertiseClientUrls = ["http://etcd:2379"];
initialAdvertisePeerUrls = ["http://etcd:2379"];
initialCluster = ["etcd=http://etcd:2379"];
};
};
networking.firewall.allowedTCPPorts = [ 2379 ];
};
node1 = flannelConfig;
node2 = flannelConfig;
};
testScript = ''
start_all()
node1.wait_for_unit("flannel.service")
node2.wait_for_unit("flannel.service")
node1.wait_until_succeeds("ip l show dev flannel0")
ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'")
node2.wait_until_succeeds("ip l show dev flannel0")
ip2 = node2.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'")
node1.wait_until_succeeds(f"ping -c 1 {ip2}")
node2.wait_until_succeeds(f"ping -c 1 {ip1}")
'';
})