Watch
0
0
Fork
You've already forked hyperhive
0

wait for the wg-hive peers before pinging in the vm test

This commit is contained in:
atlas 2026-10-29 03:50:09 +01:00 • committed by mara
commit 51b0a02e95

View file

@ -75,17 +75,25 @@ pkgs.testers.runNixOSTest {
};
testScript = ''
def wg_state(m):
return m.execute("wg show wg-hive; ip route; systemctl status 'wireguard-wg-hive*' --no-pager")[1]
start_all()
for m in (h1, h2):
for m, peer_key in ((h1, "${pub "h2"}"), (h2, "${pub "h1"}")):
m.wait_for_unit("wireguard-wg-hive.service")
m.succeed("ip link show wg-hive")
# The interface unit is active before its peers are installed: each
# peer has its own unit, which runs after network-online.target. Until
# then the interface has no peer and a send fails with ENOKEY.
m.wait_until_succeeds(f"wg show wg-hive allowed-ips | grep -F {peer_key}")
# Traffic makes the tunnel handshake.
h1.succeed("ping -c 3 -W 5 ${meshAddr.h2}")
h2.succeed("ping -c 3 -W 5 ${meshAddr.h1}")
for src, addr in ((h1, "${meshAddr.h2}"), (h2, "${meshAddr.h1}")):
status, out = src.execute(f"ping -c 3 -W 5 {addr}")
assert status == 0, f"ping {addr} failed:\n{out}\n{wg_state(src)}"
for m in (h1, h2):
stamps = m.succeed("wg show wg-hive latest-handshakes").split()
assert len(stamps) == 2 and int(stamps[1]) > 0, f"no handshake: {stamps}"
assert len(stamps) == 2 and int(stamps[1]) > 0, f"no handshake: {stamps}\n{wg_state(m)}"
# The peer's mesh address is routed through the tunnel, its plain
# address is not.