summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorCole Helbling <cole.helbling@determinate.systems>2021-11-15 12:23:25 -0800
committerCole Helbling <cole.helbling@determinate.systems>2021-11-17 16:11:10 -0800
commite62b8020f3d6597ffe4c5444fe824546af88e739 (patch)
tree06714112dfcabd9608f880db9a66ca248a6ae885 /nixos/lib
parent363d7f3ae857aeb863bc2e00fb487591b7d5db2b (diff)
downloadnixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar.gz
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar.bz2
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar.lz
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar.xz
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.tar.zst
nixpkgs-e62b8020f3d6597ffe4c5444fe824546af88e739.zip
nixos/test-driver: add (functional) timeouts to more functions
A retry timeout doesn't really help if the thing it's retrying may block
forever.
Diffstat (limited to 'nixos/lib')
-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 1d45e001bb4..b6fbc03c177 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)):