nixos/keepalived: add test

This commit is contained in:
Jörg Thalheim 2019-12-22 07:45:31 +00:00
parent 725f85e271
commit aadfcc0900
No known key found for this signature in database
GPG Key ID: B3F5D81B0C6967C4
3 changed files with 46 additions and 1 deletions

View File

@ -132,6 +132,7 @@ in
jellyfin = handleTest ./jellyfin.nix {};
jenkins = handleTest ./jenkins.nix {};
kafka = handleTest ./kafka.nix {};
keepalived = handleTest ./keepalived.nix {};
kerberos = handleTest ./kerberos/default.nix {};
kernel-latest = handleTest ./kernel-latest.nix {};
kernel-lts = handleTest ./kernel-lts.nix {};

View File

@ -0,0 +1,42 @@
import ./make-test-python.nix ({ pkgs, ... }: {
name = "keepalived";
nodes = {
node1 = { pkgs, ... }: {
networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
services.keepalived.enable = true;
services.keepalived.vrrpInstances.test = {
interface = "eth1";
state = "MASTER";
priority = 50;
virtualIps = [{ addr = "192.168.1.200"; }];
virtualRouterId = 1;
};
environment.systemPackages = [ pkgs.tcpdump ];
};
node2 = { pkgs, ... }: {
networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
services.keepalived.enable = true;
services.keepalived.vrrpInstances.test = {
interface = "eth1";
state = "MASTER";
priority = 100;
virtualIps = [{ addr = "192.168.1.200"; }];
virtualRouterId = 1;
};
environment.systemPackages = [ pkgs.tcpdump ];
};
};
testScript = ''
# wait for boot time delay to pass
for node in [node1, node2]:
node.wait_until_succeeds(
"systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
)
node.wait_for_unit("keepalived")
node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
node1.succeed("ping -c1 192.168.1.200")
'';
})

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub
{ stdenv, fetchFromGitHub, nixosTests
, libnfnetlink, libnl, net-snmp, openssl
, pkgconfig, autoreconfHook }:
@ -20,6 +20,8 @@ stdenv.mkDerivation rec {
openssl
];
passthru.tests.keepalived = nixosTests.keepalived;
nativeBuildInputs = [ pkgconfig autoreconfHook ];
configureFlags = [