summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Ghishan <omar.ghishan@rd.io>2014-01-03 15:52:37 -0800
committerOmar Ghishan <omar.ghishan@rd.io>2014-01-06 15:14:51 -0800
commit6d2b28a59e8d8ebc86f6021c0c66973efdad8c66 (patch)
tree1cd1805d59344f116e534eac7b0857d41857fcdd
parentbbd90e12ffd83e7ed845c488e21a7155c25f5b82 (diff)
downloadkafka-python-6d2b28a59e8d8ebc86f6021c0c66973efdad8c66.tar.gz
Handle starting/stopping Kafka brokers that are already started/stopped in integration tests
If some of the tests stop brokers then error out, the teardown method will try to close the same brokers and fail. This change allows it to continue.
-rw-r--r--test/fixtures.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/fixtures.py b/test/fixtures.py
index c771a58..17e6672 100644
--- a/test/fixtures.py
+++ b/test/fixtures.py
@@ -272,8 +272,13 @@ class KafkaFixture(object):
self.tmp_dir = None
self.child = None
+ self.running = False
def open(self):
+ if self.running:
+ print("*** Kafka instance already running")
+ return
+
self.tmp_dir = tempfile.mkdtemp()
print("*** Running local Kafka instance")
print(" host = %s" % self.host)
@@ -318,10 +323,16 @@ class KafkaFixture(object):
self.child.start()
self.child.wait_for(r"\[Kafka Server %d\], Started" % self.broker_id)
print("*** Done!")
+ self.running = True
def close(self):
+ if not self.running:
+ print("*** Kafka instance already stopped")
+ return
+
print("*** Stopping Kafka...")
self.child.stop()
self.child = None
print("*** Done!")
shutil.rmtree(self.tmp_dir)
+ self.running = False