diff options
author | Dana Powers <dana.powers@rd.io> | 2015-06-11 10:38:41 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@rd.io> | 2015-06-11 10:38:41 -0700 |
commit | 2451dcc55201a311c8fb5e53261cffd3235e6c77 (patch) | |
tree | e0b12981b1f38de57868fd8034cf8d6259bc7ffa | |
parent | e2955e7759ce1cc0be76b5ec4d0be18ffb4378ed (diff) | |
download | kafka-python-2451dcc55201a311c8fb5e53261cffd3235e6c77.tar.gz |
Increase timeout and backoff when retrying spawn of test fixtures
-rw-r--r-- | test/fixtures.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/fixtures.py b/test/fixtures.py index d4d03ee..164d0d7 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -4,6 +4,7 @@ import os.path import shutil import subprocess import tempfile +import time from six.moves import urllib import uuid @@ -125,12 +126,18 @@ class ZookeeperFixture(Fixture): # Party! self.out("Starting...") + timeout = 5 + max_timeout = 30 + backoff = 1 while True: self.child = SpawnedService(args, env) self.child.start() - if self.child.wait_for(r"binding to port", timeout=5): + timeout = min(timeout, max_timeout) + if self.child.wait_for(r"binding to port", timeout=timeout): break self.child.stop() + timeout *= 2 + time.sleep(backoff) self.out("Done!") def close(self): @@ -225,12 +232,19 @@ class KafkaFixture(Fixture): args = self.kafka_run_class_args("kafka.Kafka", properties) env = self.kafka_run_class_env() + timeout = 5 + max_timeout = 30 + backoff = 1 while True: self.child = SpawnedService(args, env) self.child.start() - if self.child.wait_for(r"\[Kafka Server %d\], Started" % self.broker_id, timeout=5): + timeout = min(timeout, max_timeout) + if self.child.wait_for(r"\[Kafka Server %d\], Started" % + self.broker_id, timeout=timeout): break self.child.stop() + timeout *= 2 + time.sleep(backoff) self.out("Done!") self.running = True |