From cdded4f53d085860ffa75f6ea7950dafdbbd7153 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 10 May 2018 17:19:34 +0930 Subject: [PATCH] tests/utils.py: make default timeout configurable via $TIMEOUT This is useful when you're expecting a test to fail, you've just added diagnostics. Signed-off-by: Rusty Russell --- tests/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index d4441de13..aca114753 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -28,9 +28,10 @@ LIGHTNINGD_CONFIG = { } DEVELOPER = os.getenv("DEVELOPER", "0") == "1" +TIMEOUT = int(os.getenv("TIMEOUT", "60")) -def wait_for(success, timeout=30, interval=0.1): +def wait_for(success, timeout=TIMEOUT, interval=0.1): start_time = time.time() while not success() and time.time() < start_time + timeout: time.sleep(interval) @@ -134,7 +135,7 @@ class TailableProc(object): logging.debug("Did not find '%s' in logs", regex) return None - def wait_for_logs(self, regexs, timeout=60): + def wait_for_logs(self, regexs, timeout=TIMEOUT): """Look for `regexs` in the logs. We tail the stdout of the process and look for each regex in `regexs`, @@ -173,7 +174,7 @@ class TailableProc(object): return self.logs[pos] pos += 1 - def wait_for_log(self, regex, timeout=60): + def wait_for_log(self, regex, timeout=TIMEOUT): """Look for `regex` in the logs. Convenience wrapper for the common case of only seeking a single entry. @@ -241,7 +242,7 @@ class BitcoinD(TailableProc): def start(self): TailableProc.start(self) - self.wait_for_log("Done loading", timeout=60) + self.wait_for_log("Done loading", timeout=TIMEOUT) logging.info("BitcoinD started")