summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2021-05-30 17:26:13 +0200
committerAndreas Rammhold <andreas@rammhold.de>2021-05-30 17:26:13 +0200
commitd07f52bf810beb4c67bcbf012aad78a2c9f3e495 (patch)
treeb33ebc1b9863cfd90ff83c505e41929f05354f49 /nixos/lib
parentd18c416056e4493fe133acfa064acadc4839cd70 (diff)
downloadnixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar.gz
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar.bz2
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar.lz
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar.xz
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.tar.zst
nixpkgs-d07f52bf810beb4c67bcbf012aad78a2c9f3e495.zip
nixos/test-driver: mention the elapsed time when it times out
For now you had to know that the actions are retried for 900s when
seeing an error like

> Traceback (most recent call last):
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 927, in run_tests
>     exec(tests, globals())
>   File "<string>", line 1, in <module>
>   File "<string>", line 31, in <module>
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 565, in wait_for_file
>     retry(check_file)
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 142, in retry
>     raise Exception("action timed out")
> Exception: action timed out

in your (hydra) build failure. Due to the absence of timestamps you were
left guessing if the machine was just slow, someone passed a low timeout
value (which they couldn't until now) or whatever might have happened.

By making this error a bit more descriptive (by including the elapsed
time) these hopefully become more useful.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index e216e566f28..6bbca95a97f 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -128,18 +128,18 @@ def create_vlan(vlan_nr: str) -> Tuple[str, str, "subprocess.Popen[bytes]", Any]
     return (vlan_nr, vde_socket, vde_process, fd)
 
 
-def retry(fn: Callable) -> None:
+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.
     """
 
-    for _ in range(900):
+    for _ in range(timeout):
         if fn(False):
             return
         time.sleep(1)
 
     if not fn(True):
-        raise Exception("action timed out")
+        raise Exception(f"action timed out after {timeout} seconds")
 
 
 class Logger: