kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: MINOR: Verify startup of zookeeper service in system tests
Date Tue, 29 Aug 2017 21:30:53 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.2 a00823805 -> 565455eae


MINOR: Verify startup of zookeeper service in system tests

Author: Konstantine Karantasis <konstantine@confluent.io>

Reviewers: Ewen Cheslack-Postava <ewen@confluent.io>

Closes #3707 from kkonstantine/MINOR-Verify-startup-of-zookeeper-service-in-system-tests-by-connecting-to-port


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/565455ea
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/565455ea
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/565455ea

Branch: refs/heads/0.10.2
Commit: 565455eae21d883e0a69f6a80e891a08aa2fb698
Parents: a008238
Author: Konstantine Karantasis <konstantine@confluent.io>
Authored: Wed Aug 23 09:52:21 2017 -0700
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Tue Aug 29 14:30:31 2017 -0700

----------------------------------------------------------------------
 tests/kafkatest/services/zookeeper.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/565455ea/tests/kafkatest/services/zookeeper.py
----------------------------------------------------------------------
diff --git a/tests/kafkatest/services/zookeeper.py b/tests/kafkatest/services/zookeeper.py
index 571956b..6606598 100644
--- a/tests/kafkatest/services/zookeeper.py
+++ b/tests/kafkatest/services/zookeeper.py
@@ -79,7 +79,16 @@ class ZookeeperService(KafkaPathResolverMixin, Service):
         start_cmd += "/mnt/zookeeper.properties 1>> %(path)s 2>> %(path)s &"
% self.logs["zk_log"]
         node.account.ssh(start_cmd)
 
-        time.sleep(5)  # give it some time to start
+        wait_until(lambda: self.listening(node), timeout_sec=10, err_msg="Zookeeper node
failed to start")
+
+    def listening(self, node):
+        try:
+            cmd = "nc -z %s %s" % (node.account.hostname, 2181)
+            node.account.ssh_output(cmd, allow_fail=False)
+            self.logger.debug("Zookeeper started accepting connections at: '%s:%s')", node.account.hostname,
2181)
+            return True
+        except (RemoteCommandError, ValueError) as e:
+            return False
 
     def pids(self, node):
         try:


Mime
View raw message