From d07f52bf810beb4c67bcbf012aad78a2c9f3e495 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sun, 30 May 2021 17:26:13 +0200 Subject: [PATCH] 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 "", line 1, in > File "", line 31, in > 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. --- nixos/lib/test-driver/test-driver.py | 6 +++--- 1 file 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: