Retry with shorter 5sec timeout when trying to open() fixtures

- this is intended to reduce flapping tests caused by intermittent
- fixture startup issues on travis-ci
This commit is contained in:
Dana Powers
2015-06-08 21:05:40 -07:00
parent 3d4d98ed78
commit d262107aa8
2 changed files with 14 additions and 7 deletions

View File

@@ -126,8 +126,11 @@ class ZookeeperFixture(Fixture):
# Party!
self.out("Starting...")
self.child.start()
self.child.wait_for(r"binding to port")
while True:
self.child.start()
if self.child.wait_for(r"binding to port", timeout=5):
break
self.child.stop()
self.out("Done!")
def close(self):
@@ -222,8 +225,11 @@ class KafkaFixture(Fixture):
self.out("Done!")
self.out("Starting...")
self.child.start()
self.child.wait_for(r"\[Kafka Server %d\], Started" % self.broker_id)
while True:
self.child.start()
if self.child.wait_for(r"\[Kafka Server %d\], Started" % self.broker_id, timeout=5):
break
self.child.stop()
self.out("Done!")
self.running = True

View File

@@ -110,14 +110,15 @@ class SpawnedService(threading.Thread):
log.exception("Received exception when killing child process")
self.dump_logs()
raise RuntimeError("Waiting for %r timed out after %d seconds" % (pattern, timeout))
log.error("Waiting for %r timed out after %d seconds", pattern, timeout)
return False
if re.search(pattern, '\n'.join(self.captured_stdout), re.IGNORECASE) is not None:
log.info("Found pattern %r in %d seconds via stdout", pattern, (t2 - t1))
return
return True
if re.search(pattern, '\n'.join(self.captured_stderr), re.IGNORECASE) is not None:
log.info("Found pattern %r in %d seconds via stderr", pattern, (t2 - t1))
return
return True
time.sleep(0.1)
def start(self):