From 9bb52618fa597ddf7f81a376e7782abed05146ea Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Sun, 24 Aug 2025 18:26:42 +0200 Subject: [PATCH] handle test outcome --- deployment/check/data-model/nixosTest.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/deployment/check/data-model/nixosTest.nix b/deployment/check/data-model/nixosTest.nix index 0e5b3a6a..050fb0ad 100644 --- a/deployment/check/data-model/nixosTest.nix +++ b/deployment/check/data-model/nixosTest.nix @@ -122,14 +122,27 @@ in sshOpts=( -o BatchMode=yes -o StrictHostKeyChecking=no + -o "ConnectionAttempts=1" + -o "ConnectTimeout=1" + -o "ServerAliveCountMax=1" + -o "ServerAliveInterval=1" ) # get the realized derivation to deploy outPath=$(nix-store --realize "$drv_path") # deploy the config by nix-copy-closure NIX_SSHOPTS="''${sshOpts[*]}" nix-copy-closure --to "$host" "$outPath" --gzip --use-substitutes # switch the remote host to the config - ssh "''${sshOpts[@]}" "$host" "nix-env --profile /nix/var/nix/profiles/system --set $outPath; $outPath/bin/switch-to-configuration switch" + output=$(ssh "''${sshOpts[@]}" "$host" "nix-env --profile /nix/var/nix/profiles/system --set $outPath; nohup $outPath/bin/switch-to-configuration switch &" 2>&1) || echo "status code: $?" + echo "output: $output" + if [[ $output != *"Timeout, server ${nodeName} not responding"* ]]; then + echo "non-timeout error: $output" + exit 1 + else + exit 0 + fi """) + ${nodeName}.wait_for_unit("multi-user.target") + ${nodeName}.succeed("systemctl is-active sshd") ${nodeName}.succeed("${nodeName} 1>&2") '') targetMachines )}