summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Helbling <cole.helbling@determinate.systems>2021-11-15 12:23:25 -0800
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2021-12-07 17:26:38 +0000
commit337de906d006b2d1e7cbab092937e159f6d6dd43 (patch)
tree31e533a0afe2c5b6a959b39f6359e73e6f169f2d
parentnixos/test-driver: add timeout parameter to execute (diff)
downloadnixpkgs-origin/backport-146271-to-release-21.11.tar.gz
nixos/test-driver: add (functional) timeouts to more functionsorigin/backport-146271-to-release-21.11
A retry timeout doesn't really help if the thing it's retrying may block forever. (cherry picked from commit e62b8020f3d6597ffe4c5444fe824546af88e739)
-rwxr-xr-xnixos/lib/test-driver/test-driver.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index e976917e8c0a..ac8d3efd107b 100755
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -634,12 +634,12 @@ class Machine:
pass_fds=[self.shell.fileno()],
)
- def succeed(self, *commands: str) -> str:
+ def succeed(self, *commands: str, timeout: Optional[int] = None) -> str:
"""Execute each command and check that it succeeds."""
output = ""
for command in commands:
with self.nested("must succeed: {}".format(command)):
- (status, out) = self.execute(command)
+ (status, out) = self.execute(command, timeout=timeout)
if status != 0:
self.log("output: {}".format(out))
raise Exception(
@@ -648,12 +648,12 @@ class Machine:
output += out
return output
- def fail(self, *commands: str) -> str:
+ def fail(self, *commands: str, timeout: Optional[int] = None) -> str:
"""Execute each command and check that it fails."""
output = ""
for command in commands:
with self.nested("must fail: {}".format(command)):
- (status, out) = self.execute(command)
+ (status, out) = self.execute(command, timeout=timeout)
if status == 0:
raise Exception(
"command `{}` unexpectedly succeeded".format(command)
@@ -669,14 +669,14 @@ class Machine:
def check_success(_: Any) -> bool:
nonlocal output
- status, output = self.execute(command)
+ status, output = self.execute(command, timeout=timeout)
return status == 0
with self.nested("waiting for success: {}".format(command)):
retry(check_success, timeout)
return output
- def wait_until_fails(self, command: str) -> str:
+ def wait_until_fails(self, command: str, timeout: int = 900) -> str:
"""Wait until a command returns failure.
Throws an exception on timeout.
"""
@@ -684,7 +684,7 @@ class Machine:
def check_failure(_: Any) -> bool:
nonlocal output
- status, output = self.execute(command)
+ status, output = self.execute(command, timeout=timeout)
return status != 0
with self.nested("waiting for failure: {}".format(command)):