mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
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 <rusty@rustcorp.com.au>
This commit is contained in:
parent
d1b28f832d
commit
cdded4f53d
@ -28,9 +28,10 @@ LIGHTNINGD_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEVELOPER = os.getenv("DEVELOPER", "0") == "1"
|
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()
|
start_time = time.time()
|
||||||
while not success() and time.time() < start_time + timeout:
|
while not success() and time.time() < start_time + timeout:
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
@ -134,7 +135,7 @@ class TailableProc(object):
|
|||||||
logging.debug("Did not find '%s' in logs", regex)
|
logging.debug("Did not find '%s' in logs", regex)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def wait_for_logs(self, regexs, timeout=60):
|
def wait_for_logs(self, regexs, timeout=TIMEOUT):
|
||||||
"""Look for `regexs` in the logs.
|
"""Look for `regexs` in the logs.
|
||||||
|
|
||||||
We tail the stdout of the process and look for each regex in `regexs`,
|
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]
|
return self.logs[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
|
|
||||||
def wait_for_log(self, regex, timeout=60):
|
def wait_for_log(self, regex, timeout=TIMEOUT):
|
||||||
"""Look for `regex` in the logs.
|
"""Look for `regex` in the logs.
|
||||||
|
|
||||||
Convenience wrapper for the common case of only seeking a single entry.
|
Convenience wrapper for the common case of only seeking a single entry.
|
||||||
@ -241,7 +242,7 @@ class BitcoinD(TailableProc):
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
TailableProc.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")
|
logging.info("BitcoinD started")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user