1 import ./make-test-python.nix ({ pkgs, ... }: {
5 node1 = { pkgs, ... }: {
6 networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
7 services.keepalived.enable = true;
8 services.keepalived.vrrpInstances.test = {
12 virtualIps = [{ addr = "192.168.1.200"; }];
15 environment.systemPackages = [ pkgs.tcpdump ];
17 node2 = { pkgs, ... }: {
18 networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
19 services.keepalived.enable = true;
20 services.keepalived.vrrpInstances.test = {
24 virtualIps = [{ addr = "192.168.1.200"; }];
27 environment.systemPackages = [ pkgs.tcpdump ];
32 # wait for boot time delay to pass
33 for node in [node1, node2]:
34 node.wait_until_succeeds(
35 "systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
37 node.wait_for_unit("keepalived")
38 node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
39 node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
40 node1.succeed("ping -c1 192.168.1.200")