Skip to content

Commit 6618d3e

Browse files
committed
test: Rely on bob's tailscale status to check if alice is reachable
Also, increase the time range that the authkey is valid for (100 years should be enough for us).
1 parent 10c0790 commit 6618d3e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

nixos/tests/flake-part.nix

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
6767
headscale users create --config ./config.yaml bob
6868
api_key="$(headscale apikeys create --config ./config.yaml)"
69-
auth_key="$(headscale preauthkeys create --reusable -e 24h --config ./config.yaml -u bob)"
69+
auth_key="$(headscale preauthkeys create --reusable -e 100y --config ./config.yaml -u bob)"
7070
cat >$out/apikey-envfile <<EOF
7171
TS_API_KEY=$api_key
7272
TS_BASE_URL=${config.server_url}
@@ -235,11 +235,11 @@
235235
def wait_for_hoopsnake_registered(name):
236236
"Poll until hoopsnake appears in the list of hosts, then return its IP."
237237
while True:
238-
output = json.loads(headscale.succeed("headscale nodes list -o json-line"))
239-
print(output)
240-
basic_entry = [elt["ip_addresses"][0] for elt in output if elt["given_name"] == name]
241-
if len(basic_entry) == 1:
242-
return basic_entry[0]
238+
status = json.loads(bob.succeed("tailscale status --json --peers --self=false"))
239+
if status["Peer"] is not None:
240+
basic_entry = [elt["TailscaleIPs"][0] for _, elt in status["Peer"].items() if elt["HostName"] == name]
241+
if len(basic_entry) == 1:
242+
return basic_entry[0]
243243
time.sleep(1)
244244
245245
@@ -319,11 +319,11 @@
319319
def wait_for_hoopsnake_registered(name):
320320
"Poll until hoopsnake appears in the list of hosts, then return its IP."
321321
while True:
322-
output = json.loads(headscale.succeed("headscale nodes list -o json-line"))
323-
print(output)
324-
basic_entry = [elt["ip_addresses"][0] for elt in output if elt["given_name"] == name]
325-
if len(basic_entry) == 1:
326-
return basic_entry[0]
322+
status = json.loads(bob.succeed("tailscale status --json --peers --self=false"))
323+
if status["Peer"] is not None:
324+
basic_entry = [elt["TailscaleIPs"][0] for _, elt in status["Peer"].items() if elt["HostName"] == name]
325+
if len(basic_entry) == 1:
326+
return basic_entry[0]
327327
time.sleep(1)
328328
329329
with subtest("Test setup"):

0 commit comments

Comments
 (0)