pip install bottle
pip install kazoo
-*- coding: utf-8 -*-
from kazoo.client import KazooClient
import unittest
class zktest(unittest.TestCase):
def runTest(self):
zknamespace = “/app/zktest_performance_1”
zkhosts = “127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183”
ZKTEST_DRIVERS = [“ip1”, “ip2”]
ZKTEST_NODES = [“ip3”, “ip4”, “ip5”, “ip6”]
driverChildren = []
nodeChildren = []
badDrivers = []
badNodes = []
# checking
zk = KazooClient(hosts=zkhosts, read_only=True)
zk.start()
driverFatherPath = zknamespace + “/status/drivers”
nodeFatherPath = zknamespace + “/status/nodes”
if zk.exists(driverFatherPath):
driverChildren = zk.get_children(driverFatherPath)
if len(driverChildren) >
for driver in zktest_DRIVERS:
if driver not in driverChildren:
badDrivers.append(driver)
if zk.exists(nodeFatherPath):
nodeChildren = zk.get_children(nodeFatherPath)
if len(nodeChildren) >
for node in zktest_NODES:
if node not in nodeChildren:
badNodes.append(node)
zk.stop()
if (len(badNodes)==0) and (len(badDrivers)==0):
self.assertEquals(1,1,”pass”)
else:
if len(badDrivers) > 0:
self.assertEquals(1,2,'len : %d , error : %s' % (len(badDrivers),badDrivers))
if len(badNodes) > 0:
self.assertEquals(1,2,'len : %d , error : %s' % (len(badNodes),badNodes))
if __name__ == ‘__main__':
unittest.main()
import commands
from bottle import route, run, template
@route(‘/alisa')
def index():
command = “python /Users/metaboy/script/zk_check.py”
#output = os.popen(command)
return template(‘<b>{{text}}</b>', text=commands.getoutput(command))
run(host='localhost', port=8888)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有