handle test outcome

This commit is contained in:
Kiara Grouwstra 2025-08-24 18:26:42 +02:00
parent ff8d29177f
commit 9bb52618fa
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU

View file

@ -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
)}