tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
0
fork
atom
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
nixos/keepalived: add test
Jörg Thalheim
6 years ago
aadfcc09
725f85e2
+46
-1
3 changed files
expand all
collapse all
unified
split
nixos
tests
all-tests.nix
keepalived.nix
pkgs
tools
networking
keepalived
default.nix
+1
nixos/tests/all-tests.nix
···
132
132
jellyfin = handleTest ./jellyfin.nix {};
133
133
jenkins = handleTest ./jenkins.nix {};
134
134
kafka = handleTest ./kafka.nix {};
135
135
+
keepalived = handleTest ./keepalived.nix {};
135
136
kerberos = handleTest ./kerberos/default.nix {};
136
137
kernel-latest = handleTest ./kernel-latest.nix {};
137
138
kernel-lts = handleTest ./kernel-lts.nix {};
+42
nixos/tests/keepalived.nix
···
1
1
+
import ./make-test-python.nix ({ pkgs, ... }: {
2
2
+
name = "keepalived";
3
3
+
4
4
+
nodes = {
5
5
+
node1 = { pkgs, ... }: {
6
6
+
networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
7
7
+
services.keepalived.enable = true;
8
8
+
services.keepalived.vrrpInstances.test = {
9
9
+
interface = "eth1";
10
10
+
state = "MASTER";
11
11
+
priority = 50;
12
12
+
virtualIps = [{ addr = "192.168.1.200"; }];
13
13
+
virtualRouterId = 1;
14
14
+
};
15
15
+
environment.systemPackages = [ pkgs.tcpdump ];
16
16
+
};
17
17
+
node2 = { pkgs, ... }: {
18
18
+
networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
19
19
+
services.keepalived.enable = true;
20
20
+
services.keepalived.vrrpInstances.test = {
21
21
+
interface = "eth1";
22
22
+
state = "MASTER";
23
23
+
priority = 100;
24
24
+
virtualIps = [{ addr = "192.168.1.200"; }];
25
25
+
virtualRouterId = 1;
26
26
+
};
27
27
+
environment.systemPackages = [ pkgs.tcpdump ];
28
28
+
};
29
29
+
};
30
30
+
31
31
+
testScript = ''
32
32
+
# wait for boot time delay to pass
33
33
+
for node in [node1, node2]:
34
34
+
node.wait_until_succeeds(
35
35
+
"systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
36
36
+
)
37
37
+
node.wait_for_unit("keepalived")
38
38
+
node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
39
39
+
node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
40
40
+
node1.succeed("ping -c1 192.168.1.200")
41
41
+
'';
42
42
+
})
+3
-1
pkgs/tools/networking/keepalived/default.nix
···
1
1
-
{ stdenv, fetchFromGitHub
1
1
+
{ stdenv, fetchFromGitHub, nixosTests
2
2
, libnfnetlink, libnl, net-snmp, openssl
3
3
, pkgconfig, autoreconfHook }:
4
4
···
19
19
net-snmp
20
20
openssl
21
21
];
22
22
+
23
23
+
passthru.tests.keepalived = nixosTests.keepalived;
22
24
23
25
nativeBuildInputs = [ pkgconfig autoreconfHook ];
24
26