2024-01-22 20:56:04 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
2019-12-22 07:45:31 +00:00
|
|
|
name = "keepalived";
|
2024-02-16 22:36:32 +00:00
|
|
|
meta.maintainers = [ lib.maintainers.raitobezarius ];
|
2019-12-22 07:45:31 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
node1 = { pkgs, ... }: {
|
|
|
|
services.keepalived.enable = true;
|
2024-05-05 08:58:00 +00:00
|
|
|
services.keepalived.openFirewall = true;
|
2019-12-22 07:45:31 +00:00
|
|
|
services.keepalived.vrrpInstances.test = {
|
|
|
|
interface = "eth1";
|
|
|
|
state = "MASTER";
|
|
|
|
priority = 50;
|
|
|
|
virtualIps = [{ addr = "192.168.1.200"; }];
|
|
|
|
virtualRouterId = 1;
|
|
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.tcpdump ];
|
|
|
|
};
|
|
|
|
node2 = { pkgs, ... }: {
|
|
|
|
services.keepalived.enable = true;
|
2024-05-05 08:58:00 +00:00
|
|
|
services.keepalived.openFirewall = true;
|
2019-12-22 07:45:31 +00:00
|
|
|
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")
|
|
|
|
'';
|
|
|
|
})
|