Merge pull request #13535 from taosdata/fix/ZhiqiangWang/TD-16262-add-win32-monitor-case
fix(os): add win32 monitor case
This commit is contained in:
commit
37c822d358
|
@ -8,6 +8,7 @@ import http.server
|
|||
import gzip
|
||||
import threading
|
||||
import json
|
||||
import pickle
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -15,13 +16,13 @@ from util.cases import *
|
|||
from util.dnodes import *
|
||||
|
||||
telemetryPort = '6043'
|
||||
serverPort = '7080'
|
||||
hostname = socket.gethostname()
|
||||
|
||||
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
|
||||
hostPort = hostname + ":" + serverPort
|
||||
|
||||
def telemetryInfoCheck(infoDict=''):
|
||||
|
||||
hostname = socket.gethostname()
|
||||
serverPort = 7080
|
||||
|
||||
def telemetryInfoCheck(self, infoDict=''):
|
||||
if "ts" not in infoDict or len(infoDict["ts"]) == 0:
|
||||
tdLog.exit("ts is null!")
|
||||
|
||||
|
@ -69,13 +70,13 @@ def telemetryInfoCheck(infoDict=''):
|
|||
if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None :
|
||||
tdLog.exit("dnodes is null!")
|
||||
|
||||
dnodes_info = { "dnode_id": 1,"dnode_ep": f"{hostname}:{serverPort}","status":"ready"}
|
||||
dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"}
|
||||
|
||||
for k ,v in dnodes_info.items():
|
||||
if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] :
|
||||
tdLog.exit("dnodes info is null!")
|
||||
|
||||
mnodes_info = { "mnode_id":1, "mnode_ep":f"{hostname}:{serverPort}","role": "leader" }
|
||||
mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" }
|
||||
|
||||
for k ,v in mnodes_info.items():
|
||||
if k not in infoDict["cluster_info"]["mnodes"][0] or v != infoDict["cluster_info"]["mnodes"][0][k] :
|
||||
|
@ -169,8 +170,6 @@ def telemetryInfoCheck(infoDict=''):
|
|||
if "total" not in infoDict["disk_infos"]["logdir"] or infoDict["disk_infos"]["logdir"]["total"] <= 0:
|
||||
tdLog.exit("total is null!")
|
||||
|
||||
|
||||
|
||||
if "tempdir" not in infoDict["disk_infos"] or infoDict["disk_infos"]["tempdir"]== None:
|
||||
tdLog.exit("tempdir is null!")
|
||||
|
||||
|
@ -214,7 +213,6 @@ def telemetryInfoCheck(infoDict=''):
|
|||
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!")
|
||||
|
||||
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
"""
|
||||
process GET request
|
||||
|
@ -245,17 +243,23 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
|
|||
infoDict = json.loads(plainText)
|
||||
#print("================")
|
||||
# print(infoDict)
|
||||
telemetryInfoCheck(infoDict)
|
||||
self.telemetryInfoCheck(infoDict)
|
||||
|
||||
# 4. shutdown the server and exit case
|
||||
assassin = threading.Thread(target=httpServer.shutdown)
|
||||
assassin = threading.Thread(target=self.server.shutdown)
|
||||
assassin.daemon = True
|
||||
assassin.start()
|
||||
print ("==== shutdown http server ====")
|
||||
|
||||
class TDTestCase:
|
||||
hostname = socket.gethostname()
|
||||
serverPort = '7080'
|
||||
global hostname
|
||||
global serverPort
|
||||
if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""):
|
||||
try:
|
||||
config = eval(tdDnodes.dnodes[0].remoteIP )
|
||||
hostname = config["host"]
|
||||
except Exception:
|
||||
hostname = tdDnodes.dnodes[0].remoteIP
|
||||
rpcDebugFlagVal = '143'
|
||||
clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||
clientCfgDict["serverPort"] = serverPort
|
||||
|
@ -291,21 +295,19 @@ class TDTestCase:
|
|||
sql = "create database db3 vgroups " + vgroups
|
||||
tdSql.query(sql)
|
||||
|
||||
# loop to wait request
|
||||
httpServer.serve_forever()
|
||||
# create http server: bing ip/port , and request processor
|
||||
if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""):
|
||||
RequestHandlerImplStr = base64.b64encode(pickle.dumps(RequestHandlerImpl)).decode()
|
||||
cmdStr = "import pickle\nimport http\nRequestHandlerImpl=pickle.loads(base64.b64decode(\"%s\".encode()))\nclass NewRequestHandlerImpl(RequestHandlerImpl):\n hostPort = \'%s\'\nhttp.server.HTTPServer((\"\", %s), NewRequestHandlerImpl).serve_forever()"%(RequestHandlerImplStr,hostname+":"+serverPort,telemetryPort)
|
||||
tdDnodes.dnodes[0].remoteExec({}, cmdStr)
|
||||
else:
|
||||
serverAddress = ("", int(telemetryPort))
|
||||
http.server.HTTPServer(serverAddress, RequestHandlerImpl).serve_forever()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
# create http server: bing ip/port , and request processor
|
||||
serverAddress = ("", int(telemetryPort))
|
||||
httpServer = http.server.HTTPServer(serverAddress, RequestHandlerImpl)
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
@REM python3 .\test.py -f 0-others\taosShell.py
|
||||
python3 .\test.py -f 0-others\taosShell.py
|
||||
python3 .\test.py -f 0-others\taosShellError.py
|
||||
python3 .\test.py -f 0-others\taosShellNetChk.py
|
||||
python3 .\test.py -f 0-others\telemetry.py
|
||||
@REM python3 .\test.py -f 0-others\taosdMonitor.py
|
||||
python3 .\test.py -f 0-others\taosdMonitor.py
|
||||
python3 .\test.py -f 0-others\udfTest.py
|
||||
python3 .\test.py -f 0-others\udf_create.py
|
||||
python3 .\test.py -f 0-others\udf_restart_taosd.py
|
||||
|
|
|
@ -114,6 +114,7 @@ if __name__ == "__main__":
|
|||
|
||||
if not execCmd == "":
|
||||
tdDnodes.init(deployPath)
|
||||
print(execCmd)
|
||||
exec(execCmd)
|
||||
quit()
|
||||
|
||||
|
|
Loading…
Reference in New Issue