diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2019-12-22 07:45:31 +0000 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2019-12-22 08:52:56 +0000 |
commit | aadfcc0900bb15dfda4b64ab3ffe768551f65d37 (patch) | |
tree | 75e14e8c0b2048d31455aa6dfed1f07a075cc06a /nixos/tests/keepalived.nix | |
parent | 725f85e271b934b57383abd7db81cc601b4b4c18 (diff) | |
download | nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar.gz nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar.bz2 nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar.lz nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar.xz nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.tar.zst nixpkgs-aadfcc0900bb15dfda4b64ab3ffe768551f65d37.zip |
nixos/keepalived: add test
Diffstat (limited to 'nixos/tests/keepalived.nix')
-rw-r--r-- | nixos/tests/keepalived.nix | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/tests/keepalived.nix b/nixos/tests/keepalived.nix new file mode 100644 index 00000000000..d0bf9d46520 --- /dev/null +++ b/nixos/tests/keepalived.nix @@ -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") + ''; +}) |