diff options
author | Omar Ghishan <omar.ghishan@rd.io> | 2014-01-06 14:16:11 -0800 |
---|---|---|
committer | Omar Ghishan <omar.ghishan@rd.io> | 2014-01-06 15:14:51 -0800 |
commit | e0c45ff898aa4cb8fb4534be7d585451bafecd35 (patch) | |
tree | 05984f04bef89d65dc307dd2602271d43d53e06e | |
parent | c11ff042bfffa9221220b41ca6754842b273d903 (diff) | |
download | kafka-python-e0c45ff898aa4cb8fb4534be7d585451bafecd35.tar.gz |
Add object type and ID to message prefix in fixtures output for easier debugging
-rw-r--r-- | test/fixtures.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/test/fixtures.py b/test/fixtures.py index 17e6672..28d6519 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -208,9 +208,12 @@ class ZookeeperFixture(object): self.tmp_dir = None self.child = None + def out(self, message): + print("*** Zookeeper[%s]: %s" % (id(self), message)) + def open(self): self.tmp_dir = tempfile.mkdtemp() - print("*** Running local Zookeeper instance...") + print("*** [%s] Running local Zookeeper instance..." % id(self)) print(" host = %s" % self.host) print(" port = %s" % self.port) print(" tmp_dir = %s" % self.tmp_dir) @@ -229,16 +232,16 @@ class ZookeeperFixture(object): self.child.configure_stderr(os.path.join(self.tmp_dir, "stderr.txt")) # Party! - print("*** Starting Zookeeper...") + self.out("Starting...") self.child.start() self.child.wait_for(r"Snapshotting") - print("*** Done!") + self.out("Done!") def close(self): - print("*** Stopping Zookeeper...") + self.out("Stopping...") self.child.stop() self.child = None - print("*** Done!") + self.out("Done!") shutil.rmtree(self.tmp_dir) @@ -274,13 +277,16 @@ class KafkaFixture(object): self.child = None self.running = False + def out(self, message): + print("*** Kafka[%s]: %s" % (id(self), message)) + def open(self): if self.running: - print("*** Kafka instance already running") + self.out("Instance already running") return self.tmp_dir = tempfile.mkdtemp() - print("*** Running local Kafka instance") + self.out("Running local instance") print(" host = %s" % self.host) print(" port = %s" % self.port) print(" broker_id = %s" % self.broker_id) @@ -308,31 +314,31 @@ class KafkaFixture(object): self.child.configure_stderr(os.path.join(self.tmp_dir, "stderr.txt")) # Party! - print("*** Creating Zookeeper chroot node...") + self.out("Creating Zookeeper chroot node...") proc = subprocess.Popen(kafka_run_class_args( "org.apache.zookeeper.ZooKeeperMain", "-server", "%s:%d" % (self.zk_host, self.zk_port), "create", "/%s" % self.zk_chroot, "kafka-python" )) if proc.wait() != 0: - print("*** Failed to create Zookeeper chroot node") + self.out("Failed to create Zookeeper chroot node") raise RuntimeError("Failed to create Zookeeper chroot node") - print("*** Done!") + self.out("Done!") - print("*** Starting Kafka...") + self.out("Starting...") self.child.start() self.child.wait_for(r"\[Kafka Server %d\], Started" % self.broker_id) - print("*** Done!") + self.out("Done!") self.running = True def close(self): if not self.running: - print("*** Kafka instance already stopped") + self.out("Instance already stopped") return - print("*** Stopping Kafka...") + self.out("Stopping...") self.child.stop() self.child = None - print("*** Done!") + self.out("Done!") shutil.rmtree(self.tmp_dir) self.running = False |