Bitcoind should always eventually finish starting, but there is no guarantee on how long it takes, so don't apply a time-out. In case bitcoind hangs indefinitely, the test will hang indefinitely too, but this should be solved in bitcoind, not in the test code.

This commit is contained in:
cornwarecjp
2018-01-30 11:10:13 +01:00
committed by Christian Decker
parent 859070a5ed
commit 0b0708d86a

View File

@@ -127,6 +127,8 @@ class TailableProc(object):
starting from last of the previous waited-for log entries (if any). We starting from last of the previous waited-for log entries (if any). We
fail if the timeout is exceeded or if the underlying process fail if the timeout is exceeded or if the underlying process
exits before all the `regexs` were found. exits before all the `regexs` were found.
If timeout is None, no time-out is applied.
""" """
logging.debug("Waiting for {} in the logs".format(regexs)) logging.debug("Waiting for {} in the logs".format(regexs))
exs = [re.compile(r) for r in regexs] exs = [re.compile(r) for r in regexs]
@@ -134,8 +136,8 @@ class TailableProc(object):
pos = self.logsearch_start pos = self.logsearch_start
initial_pos = len(self.logs) initial_pos = len(self.logs)
while True: while True:
if time.time() > start_time + timeout: if timeout is not None and time.time() > start_time + timeout:
print("Can't find {} in logs".format(exs)) print("Time-out: can't find {} in logs".format(exs))
for r in exs: for r in exs:
if self.is_in_log(r): if self.is_in_log(r):
print("({} was previously in logs!)".format(r)) print("({} was previously in logs!)".format(r))
@@ -223,7 +225,7 @@ class BitcoinD(TailableProc):
def start(self): def start(self):
TailableProc.start(self) TailableProc.start(self)
self.wait_for_log("Done loading", timeout=10) self.wait_for_log("Done loading", timeout=None)
logging.info("BitcoinD started") logging.info("BitcoinD started")