33import requests
44import time
55import sys
6+
67sys .tracebacklimit = 0
78
89
@@ -37,18 +38,29 @@ def check_ruok(hosts):
3738 url = host + ":8080/commands/" + cmd_ruok
3839 response = try_get (url ).json ()
3940
40- if "command" in response and response ["command" ] == cmd_ruok \
41- and "error" in response and response ["error" ] is None :
41+ if (
42+ "command" in response
43+ and response ["command" ] == cmd_ruok
44+ and "error" in response
45+ and response ["error" ] is None
46+ ):
4247 continue
4348 else :
44- print ("Error[" + cmd_ruok + "] for [" + url + "]: received " + str (
45- response ) + " - expected {'command': 'ruok', 'error': None} " )
49+ print (
50+ "Error["
51+ + cmd_ruok
52+ + "] for ["
53+ + url
54+ + "]: received "
55+ + str (response )
56+ + " - expected {'command': 'ruok', 'error': None} "
57+ )
4658 exit (- 1 )
4759
4860
4961def check_monitoring (hosts ):
5062 for host in hosts :
51- url = host + ":9505"
63+ url = host + ":9505/metrics "
5264 response = try_get (url )
5365
5466 if response .ok :
@@ -58,15 +70,29 @@ def check_monitoring(hosts):
5870 exit (- 1 )
5971
6072
61- if __name__ == ' __main__' :
73+ if __name__ == " __main__" :
6274 all_args = argparse .ArgumentParser (description = "Test ZooKeeper." )
63- all_args .add_argument ("-n" , "--namespace" , help = "The namespace to run in" , required = True )
75+ all_args .add_argument (
76+ "-n" , "--namespace" , help = "The namespace to run in" , required = True
77+ )
6478 args = vars (all_args .parse_args ())
6579 namespace = args ["namespace" ]
6680
67- host_primary_0 = "http://test-zk-server-primary-0.test-zk-server-primary." + namespace + ".svc.cluster.local"
68- host_primary_1 = "http://test-zk-server-primary-1.test-zk-server-primary." + namespace + ".svc.cluster.local"
69- host_secondary = "http://test-zk-server-secondary-0.test-zk-server-secondary." + namespace + ".svc.cluster.local"
81+ host_primary_0 = (
82+ "http://test-zk-server-primary-0.test-zk-server-primary."
83+ + namespace
84+ + ".svc.cluster.local"
85+ )
86+ host_primary_1 = (
87+ "http://test-zk-server-primary-1.test-zk-server-primary."
88+ + namespace
89+ + ".svc.cluster.local"
90+ )
91+ host_secondary = (
92+ "http://test-zk-server-secondary-0.test-zk-server-secondary."
93+ + namespace
94+ + ".svc.cluster.local"
95+ )
7096
7197 hosts = [host_primary_0 , host_primary_1 , host_secondary ]
7298
0 commit comments