Loading nixos/lib/test-driver/src/test_driver/driver.py +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ class Driver: return ret with driver.logger.nested(f"waiting for {self.condition.description}"): retry(condition, timeout=timeout) retry(condition, timeout_seconds=timeout) if fun_ is None: return Poll Loading nixos/lib/test-driver/src/test_driver/machine/__init__.py +11 −5 Original line number Diff line number Diff line Loading @@ -93,19 +93,25 @@ def make_command(args: list) -> str: return " ".join(map(shlex.quote, (map(str, args)))) def retry(fn: Callable, timeout: int = 900) -> None: """Call the given function repeatedly, with 1 second intervals, until it returns True or a timeout is reached. def retry(fn: Callable, timeout_seconds: int = 900) -> None: """Call the given function repeatedly, with a one second interval between retries, until it returns True or a timeout is reached. Note that the timeout shown will include the time of the last attempted run. """ start_time = time.monotonic() for _ in range(timeout): while time.monotonic() - start_time < timeout_seconds: if fn(False): return time.sleep(1) elapsed = time.monotonic() - start_time if not fn(True): raise RequestedAssertionFailed( f"action timed out after {timeout} tries with one-second pause in-between" f"action timed out after {elapsed:.2f} seconds " f"(timeout={timeout_seconds})" ) Loading nixos/tests/openssh.nix +12 −12 Original line number Diff line number Diff line Loading @@ -290,23 +290,23 @@ in testScript = '' start_all() server.wait_for_unit("sshd", timeout=30) server_allowed_users.wait_for_unit("sshd", timeout=30) server_localhost_only.wait_for_unit("sshd", timeout=30) server_match_rule.wait_for_unit("sshd", timeout=30) server_no_openssl.wait_for_unit("sshd", timeout=30) server_no_pam.wait_for_unit("sshd", timeout=30) server_null_pam.wait_for_unit("sshd", timeout=30) server.wait_for_unit("sshd", timeout=60) server_allowed_users.wait_for_unit("sshd", timeout=60) server_localhost_only.wait_for_unit("sshd", timeout=60) server_match_rule.wait_for_unit("sshd", timeout=60) server_no_openssl.wait_for_unit("sshd", timeout=60) server_no_pam.wait_for_unit("sshd", timeout=60) server_null_pam.wait_for_unit("sshd", timeout=60) server_null_pam.fail("journalctl -u sshd.service | grep 'Unsupported option UsePAM'") server_sftp.wait_for_unit("sshd", timeout=30) server_sftp.wait_for_unit("sshd", timeout=60) server_lazy.wait_for_unit("sshd.socket", timeout=30) server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=30) server_lazy_socket.wait_for_unit("sshd.socket", timeout=30) server_lazy.wait_for_unit("sshd.socket", timeout=60) server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=60) server_lazy_socket.wait_for_unit("sshd.socket", timeout=60) # sshd-keygen is a oneshot unit, so just wait for multi-user.target, which # pulls it in. server_no_sshd_with_key.wait_for_unit("multi-user.target", timeout=30) server_no_sshd_with_key.wait_for_unit("multi-user.target", timeout=60) with subtest("manual-authkey"): client.succeed( Loading Loading
nixos/lib/test-driver/src/test_driver/driver.py +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ class Driver: return ret with driver.logger.nested(f"waiting for {self.condition.description}"): retry(condition, timeout=timeout) retry(condition, timeout_seconds=timeout) if fun_ is None: return Poll Loading
nixos/lib/test-driver/src/test_driver/machine/__init__.py +11 −5 Original line number Diff line number Diff line Loading @@ -93,19 +93,25 @@ def make_command(args: list) -> str: return " ".join(map(shlex.quote, (map(str, args)))) def retry(fn: Callable, timeout: int = 900) -> None: """Call the given function repeatedly, with 1 second intervals, until it returns True or a timeout is reached. def retry(fn: Callable, timeout_seconds: int = 900) -> None: """Call the given function repeatedly, with a one second interval between retries, until it returns True or a timeout is reached. Note that the timeout shown will include the time of the last attempted run. """ start_time = time.monotonic() for _ in range(timeout): while time.monotonic() - start_time < timeout_seconds: if fn(False): return time.sleep(1) elapsed = time.monotonic() - start_time if not fn(True): raise RequestedAssertionFailed( f"action timed out after {timeout} tries with one-second pause in-between" f"action timed out after {elapsed:.2f} seconds " f"(timeout={timeout_seconds})" ) Loading
nixos/tests/openssh.nix +12 −12 Original line number Diff line number Diff line Loading @@ -290,23 +290,23 @@ in testScript = '' start_all() server.wait_for_unit("sshd", timeout=30) server_allowed_users.wait_for_unit("sshd", timeout=30) server_localhost_only.wait_for_unit("sshd", timeout=30) server_match_rule.wait_for_unit("sshd", timeout=30) server_no_openssl.wait_for_unit("sshd", timeout=30) server_no_pam.wait_for_unit("sshd", timeout=30) server_null_pam.wait_for_unit("sshd", timeout=30) server.wait_for_unit("sshd", timeout=60) server_allowed_users.wait_for_unit("sshd", timeout=60) server_localhost_only.wait_for_unit("sshd", timeout=60) server_match_rule.wait_for_unit("sshd", timeout=60) server_no_openssl.wait_for_unit("sshd", timeout=60) server_no_pam.wait_for_unit("sshd", timeout=60) server_null_pam.wait_for_unit("sshd", timeout=60) server_null_pam.fail("journalctl -u sshd.service | grep 'Unsupported option UsePAM'") server_sftp.wait_for_unit("sshd", timeout=30) server_sftp.wait_for_unit("sshd", timeout=60) server_lazy.wait_for_unit("sshd.socket", timeout=30) server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=30) server_lazy_socket.wait_for_unit("sshd.socket", timeout=30) server_lazy.wait_for_unit("sshd.socket", timeout=60) server_localhost_only_lazy.wait_for_unit("sshd.socket", timeout=60) server_lazy_socket.wait_for_unit("sshd.socket", timeout=60) # sshd-keygen is a oneshot unit, so just wait for multi-user.target, which # pulls it in. server_no_sshd_with_key.wait_for_unit("multi-user.target", timeout=30) server_no_sshd_with_key.wait_for_unit("multi-user.target", timeout=60) with subtest("manual-authkey"): client.succeed( Loading