move timeout expectation to tests (#534)

Reviewed-on: fediversity/fediversity#534
This commit is contained in:
Kiara Grouwstra 2025-09-30 12:00:27 +02:00
parent f076e5653d
commit a12a1606ed
3 changed files with 9 additions and 12 deletions

View file

@ -5,9 +5,10 @@
}: }:
let let
inherit (pkgs) system; inherit (pkgs) system;
deployment-config = {
inherit (import ./constants.nix) pathToRoot;
nodeName = "ssh"; nodeName = "ssh";
deployment-config = {
inherit nodeName;
inherit (import ./constants.nix) pathToRoot;
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [ ];
}; };
@ -58,9 +59,10 @@ in
ssh.fail("hello 1>&2") ssh.fail("hello 1>&2")
with subtest("Run the deployment"): with subtest("Run the deployment"):
deployer.succeed(""" output = deployer.fail("""
${lib.getExe deploy} ${lib.getExe deploy}
""") """)
assert "Timeout, server ${nodeName} not responding" in output
ssh.wait_for_unit("multi-user.target") ssh.wait_for_unit("multi-user.target")
ssh.succeed("su - operator -c hello 1>&2") ssh.succeed("su - operator -c hello 1>&2")
''; '';

View file

@ -5,9 +5,10 @@
}: }:
let let
inherit (pkgs) system; inherit (pkgs) system;
deployment-config = {
inherit (import ./constants.nix) pathToRoot;
nodeName = "target"; nodeName = "target";
deployment-config = {
inherit nodeName;
inherit (import ./constants.nix) pathToRoot;
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [ ];
}; };
@ -51,9 +52,10 @@ in
target.fail("hello 1>&2") target.fail("hello 1>&2")
with subtest("Run the deployment"): with subtest("Run the deployment"):
deployer.succeed(""" output = deployer.fail("""
${lib.getExe deploy} ${lib.getExe deploy}
""") """)
assert "Timeout, server ${nodeName} not responding" in output
target.wait_for_unit("multi-user.target") target.wait_for_unit("multi-user.target")
target.succeed("su - operator -c hello 1>&2") target.succeed("su - operator -c hello 1>&2")
''; '';

View file

@ -37,11 +37,4 @@ NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$destination" "$outPath" --gz
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath" ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath"
# shellcheck disable=SC2029 # shellcheck disable=SC2029
output=$(ssh -o "ConnectTimeout=1" -o "ServerAliveInterval=1" "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1) || echo "status code: $?" ssh -o "ConnectTimeout=1" -o "ServerAliveInterval=1" "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1
echo "output: $output"
if [[ $output != *"Timeout, server $host not responding"* ]]; then
echo "non-timeout error: $output"
exit 1
else
exit 0
fi