From fdc7bb0f4f80a5b62d38227c13f575e85304a250 Mon Sep 17 00:00:00 2001 From: Krzysztof Nazarewski Date: Thu, 26 Jun 2025 11:52:37 +0200 Subject: [PATCH] tests/netbird: make the client test more robust --- nixos/tests/netbird.nix | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/nixos/tests/netbird.nix b/nixos/tests/netbird.nix index 581c6eeeab2e..873f5405935e 100644 --- a/nixos/tests/netbird.nix +++ b/nixos/tests/netbird.nix @@ -18,19 +18,18 @@ # TODO: confirm the whole solution is working end-to-end when netbird server is implemented testScript = '' start_all() - def did_start(node, name): + def did_start(node, name, interval=0.5, timeout=10): node.wait_for_unit(f"{name}.service") node.wait_for_file(f"/var/run/{name}/sock") - output = node.succeed(f"{name} status") + # `netbird status` returns a full "Disconnected" status during initialization + # only after a while passes it starts returning "NeedsLogin" help message - # not sure why, but it can print either of: - # - Daemon status: NeedsLogin - # - Management: Disconnected - expected = [ - "Disconnected", - "NeedsLogin", - ] - assert any(msg in output for msg in expected) + start = time.time() + output = node.succeed(f"{name} status") + while "Disconnected" in output and (time.time() - start) < timeout: + time.sleep(interval) + output = node.succeed(f"{name} status") + assert "NeedsLogin" in output did_start(clients, "netbird") did_start(clients, "netbird-custom")