提交 352a62c2 编写于 作者: G Ganlin Zhao

fix test cases

上级 c4f14a4f
...@@ -33,14 +33,14 @@ class TDTestCase: ...@@ -33,14 +33,14 @@ class TDTestCase:
tdSql.query('select database()') tdSql.query('select database()')
tdSql.checkData(0,0,self.dbname) tdSql.checkData(0,0,self.dbname)
tdSql.execute(f'drop database {self.dbname}') tdSql.execute(f'drop database {self.dbname}')
def check_version(self): def check_version(self):
taos_list = ['server','client'] taos_list = ['server','client']
for i in taos_list: for i in taos_list:
tdSql.query(f'select {i}_version()') tdSql.query(f'select {i}_version()')
version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1] version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1]
tdSql.checkData(0,0,version_info) tdSql.checkData(0,0,version_info)
def get_server_status(self): def get_server_status(self):
sleep(self.delaytime) sleep(self.delaytime)
tdSql.query('select server_status()') tdSql.query('select server_status()')
...@@ -51,7 +51,7 @@ class TDTestCase: ...@@ -51,7 +51,7 @@ class TDTestCase:
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sleep(10) sleep(10)
tdSql.error('select server_status()') tdSql.error('select server_status()')
def run(self): def run(self):
self.get_database_info() self.get_database_info()
self.check_version() self.check_version()
...@@ -61,4 +61,4 @@ class TDTestCase: ...@@ -61,4 +61,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -18,7 +18,7 @@ from util.dnodes import * ...@@ -18,7 +18,7 @@ from util.dnodes import *
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
if len(key) == 0: if len(key) == 0:
tdLog.exit("taos test key is null!") tdLog.exit("taos test key is null!")
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = buildPath + '\\build\\bin\\taos.exe '
taosCmd = taosCmd.replace('\\','\\\\') taosCmd = taosCmd.replace('\\','\\\\')
...@@ -158,34 +158,34 @@ class TDTestCase: ...@@ -158,34 +158,34 @@ class TDTestCase:
if "2: service ok" in retVal: if "2: service ok" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 1") tdLog.exit("taos -k fail 1")
# stop taosd # stop taosd
tdDnodes.stop(1) tdDnodes.stop(1)
#sleep(10) #sleep(10)
#tdDnodes.start(1) #tdDnodes.start(1)
#sleep(5) #sleep(5)
retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString)
if "0: unavailable" in retVal: if "0: unavailable" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 2") tdLog.exit("taos -k fail 2")
# restart taosd # restart taosd
tdDnodes.start(1) tdDnodes.start(1)
#sleep(5) #sleep(5)
retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString)
if "2: service ok" in retVal: if "2: service ok" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 3") tdLog.exit("taos -k fail 3")
tdLog.printNoPrefix("================================ parameter: -n") tdLog.printNoPrefix("================================ parameter: -n")
# stop taosd # stop taosd
tdDnodes.stop(1) tdDnodes.stop(1)
try: try:
role = 'server' role = 'server'
...@@ -220,7 +220,7 @@ class TDTestCase: ...@@ -220,7 +220,7 @@ class TDTestCase:
#print(child.after.decode()) #print(child.after.decode())
if i == 0: if i == 0:
tdLog.exit('taos -n server fail!') tdLog.exit('taos -n server fail!')
expectString1 = 'response is received, size:' + pktLen expectString1 = 'response is received, size:' + pktLen
expectSTring2 = pktNum + '/' + pktNum expectSTring2 = pktNum + '/' + pktNum
if expectString1 in retResult and expectSTring2 in retResult: if expectString1 in retResult and expectSTring2 in retResult:
......
...@@ -51,7 +51,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -51,7 +51,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "version" not in infoDict["cluster_info"] or infoDict["cluster_info"]["version"] == None: if "version" not in infoDict["cluster_info"] or infoDict["cluster_info"]["version"] == None:
tdLog.exit("first_ep_dnode_id is null!") tdLog.exit("first_ep_dnode_id is null!")
if "master_uptime" not in infoDict["cluster_info"] or infoDict["cluster_info"]["master_uptime"] == None: if "master_uptime" not in infoDict["cluster_info"] or infoDict["cluster_info"]["master_uptime"] == None:
tdLog.exit("master_uptime is null!") tdLog.exit("master_uptime is null!")
...@@ -69,13 +69,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -69,13 +69,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None : if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None :
tdLog.exit("dnodes is null!") tdLog.exit("dnodes is null!")
dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"} dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"}
for k ,v in dnodes_info.items(): for k ,v in dnodes_info.items():
if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] : if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] :
tdLog.exit("dnodes info is null!") tdLog.exit("dnodes info is null!")
mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" } mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" }
for k ,v in mnodes_info.items(): for k ,v in mnodes_info.items():
...@@ -86,7 +86,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -86,7 +86,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "vgroup_infos" not in infoDict or infoDict["vgroup_infos"]== None: if "vgroup_infos" not in infoDict or infoDict["vgroup_infos"]== None:
tdLog.exit("vgroup_infos is null!") tdLog.exit("vgroup_infos is null!")
vgroup_infos_nums = len(infoDict["vgroup_infos"]) vgroup_infos_nums = len(infoDict["vgroup_infos"])
for index in range(vgroup_infos_nums): for index in range(vgroup_infos_nums):
...@@ -116,14 +116,14 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -116,14 +116,14 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "timeseries_total" not in infoDict["grant_info"] or not infoDict["grant_info"]["timeseries_total"] > 0: if "timeseries_total" not in infoDict["grant_info"] or not infoDict["grant_info"]["timeseries_total"] > 0:
tdLog.exit("timeseries_total is null!") tdLog.exit("timeseries_total is null!")
# dnode_info ==================================== # dnode_info ====================================
if "dnode_info" not in infoDict or infoDict["dnode_info"]== None: if "dnode_info" not in infoDict or infoDict["dnode_info"]== None:
tdLog.exit("dnode_info is null!") tdLog.exit("dnode_info is null!")
dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine', dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine',
'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select', 'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select',
'req_select_rate', 'req_insert', 'req_insert_success', 'req_insert_rate', 'req_insert_batch', 'req_insert_batch_success', 'req_select_rate', 'req_insert', 'req_insert_success', 'req_insert_rate', 'req_insert_batch', 'req_insert_batch_success',
'req_insert_batch_rate', 'errors', 'vnodes_num', 'masters', 'has_mnode', 'has_qnode', 'has_snode', 'has_bnode'] 'req_insert_batch_rate', 'errors', 'vnodes_num', 'masters', 'has_mnode', 'has_qnode', 'has_snode', 'has_bnode']
for elem in dnode_infos: for elem in dnode_infos:
...@@ -134,7 +134,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -134,7 +134,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "disk_infos" not in infoDict or infoDict["disk_infos"]== None: if "disk_infos" not in infoDict or infoDict["disk_infos"]== None:
tdLog.exit("disk_infos is null!") tdLog.exit("disk_infos is null!")
# bug for data_dir # bug for data_dir
if "datadir" not in infoDict["disk_infos"] or len(infoDict["disk_infos"]["datadir"]) <=0 : if "datadir" not in infoDict["disk_infos"] or len(infoDict["disk_infos"]["datadir"]) <=0 :
tdLog.exit("datadir is null!") tdLog.exit("datadir is null!")
...@@ -187,7 +187,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -187,7 +187,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
# log_infos ==================================== # log_infos ====================================
if "log_infos" not in infoDict or infoDict["log_infos"]== None: if "log_infos" not in infoDict or infoDict["log_infos"]== None:
tdLog.exit("log_infos is null!") tdLog.exit("log_infos is null!")
...@@ -206,13 +206,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -206,13 +206,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "summary" not in infoDict["log_infos"] or len(infoDict["log_infos"]["summary"])!= 4: if "summary" not in infoDict["log_infos"] or len(infoDict["log_infos"]["summary"])!= 4:
tdLog.exit("summary is null!") tdLog.exit("summary is null!")
if "total" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["total"] < 0 : if "total" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["total"] < 0 :
tdLog.exit("total is null!") tdLog.exit("total is null!")
if "level" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["level"] not in ["error" ,"info" , "debug" ,"trace"]: if "level" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["level"] not in ["error" ,"info" , "debug" ,"trace"]:
tdLog.exit("level is null!") tdLog.exit("level is null!")
def do_GET(self): def do_GET(self):
""" """
process GET request process GET request
...@@ -227,25 +227,25 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -227,25 +227,25 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if contentEncoding == 'gzip': if contentEncoding == 'gzip':
req_body = self.rfile.read(int(self.headers["Content-Length"])) req_body = self.rfile.read(int(self.headers["Content-Length"]))
plainText = gzip.decompress(req_body).decode() plainText = gzip.decompress(req_body).decode()
else: else:
plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() plainText = self.rfile.read(int(self.headers["Content-Length"])).decode()
print(plainText) print(plainText)
# 1. send response code and header # 1. send response code and header
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers() self.end_headers()
# 2. send response content # 2. send response content
#self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8"))
# 3. check request body info # 3. check request body info
infoDict = json.loads(plainText) infoDict = json.loads(plainText)
#print("================") #print("================")
# print(infoDict) # print(infoDict)
self.telemetryInfoCheck(infoDict) self.telemetryInfoCheck(infoDict)
# 4. shutdown the server and exit case # 4. shutdown the server and exit case
assassin = threading.Thread(target=self.server.shutdown) assassin = threading.Thread(target=self.server.shutdown)
assassin.daemon = True assassin.daemon = True
assassin.start() assassin.start()
...@@ -287,7 +287,7 @@ class TDTestCase: ...@@ -287,7 +287,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare() tdSql.prepare()
# time.sleep(2) # time.sleep(2)
......
...@@ -100,9 +100,9 @@ def telemetryInfoCheck(infoDict=''): ...@@ -100,9 +100,9 @@ def telemetryInfoCheck(infoDict=''):
if "compStorage" not in infoDict or infoDict["compStorage"] < 0: if "compStorage" not in infoDict or infoDict["compStorage"] < 0:
tdLog.exit("compStorage is null!") tdLog.exit("compStorage is null!")
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
""" """
process GET request process GET request
...@@ -117,26 +117,26 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -117,26 +117,26 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if contentEncoding == 'gzip': if contentEncoding == 'gzip':
req_body = self.rfile.read(int(self.headers["Content-Length"])) req_body = self.rfile.read(int(self.headers["Content-Length"]))
plainText = gzip.decompress(req_body).decode() plainText = gzip.decompress(req_body).decode()
else: else:
plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() plainText = self.rfile.read(int(self.headers["Content-Length"])).decode()
print("monitor info:\n%s"%plainText) print("monitor info:\n%s"%plainText)
# 1. send response code and header # 1. send response code and header
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers() self.end_headers()
# 2. send response content # 2. send response content
#self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8"))
# 3. check request body info # 3. check request body info
infoDict = json.loads(plainText) infoDict = json.loads(plainText)
#print("================") #print("================")
#print(infoDict) #print(infoDict)
telemetryInfoCheck(infoDict) telemetryInfoCheck(infoDict)
# 4. shutdown the server and exit case # 4. shutdown the server and exit case
assassin = threading.Thread(target=self.server.shutdown) assassin = threading.Thread(target=self.server.shutdown)
assassin.daemon = True assassin.daemon = True
assassin.start() assassin.start()
...@@ -176,7 +176,7 @@ class TDTestCase: ...@@ -176,7 +176,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare() tdSql.prepare()
# time.sleep(2) # time.sleep(2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册