提交 21b9a5a1 编写于 作者: L liuyq-617

(query)fix

上级 380cbbad
...@@ -28,6 +28,7 @@ import taos ...@@ -28,6 +28,7 @@ import taos
if __name__ == "__main__": if __name__ == "__main__":
fileName = "all" fileName = "all"
deployPath = "" deployPath = ""
masterIp = "" masterIp = ""
...@@ -37,83 +38,68 @@ if __name__ == "__main__": ...@@ -37,83 +38,68 @@ if __name__ == "__main__":
stop = 0 stop = 0
restart = False restart = False
windows = 0 windows = 0
opts, args = getopt.gnu_getopt( opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [
sys.argv[1:], 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows'])
"f:p:m:l:scghrw",
[
"file=",
"path=",
"master",
"logSql",
"stop",
"cluster",
"valgrind",
"help",
"windows",
],
)
for key, value in opts: for key, value in opts:
if key in ["-h", "--help"]: if key in ['-h', '--help']:
tdLog.printNoPrefix("A collection of test cases written using Python") tdLog.printNoPrefix(
tdLog.printNoPrefix("-f Name of test case file written by Python") 'A collection of test cases written using Python')
tdLog.printNoPrefix("-p Deploy Path for Simulator") tdLog.printNoPrefix('-f Name of test case file written by Python')
tdLog.printNoPrefix("-m Master Ip for Simulator") tdLog.printNoPrefix('-p Deploy Path for Simulator')
tdLog.printNoPrefix("-l <True:False> logSql Flag") tdLog.printNoPrefix('-m Master Ip for Simulator')
tdLog.printNoPrefix("-s stop All dnodes") tdLog.printNoPrefix('-l <True:False> logSql Flag')
tdLog.printNoPrefix("-c Test Cluster Flag") tdLog.printNoPrefix('-s stop All dnodes')
tdLog.printNoPrefix("-g valgrind Test Flag") tdLog.printNoPrefix('-c Test Cluster Flag')
tdLog.printNoPrefix("-r taosd restart test") tdLog.printNoPrefix('-g valgrind Test Flag')
tdLog.printNoPrefix("-w taos on windows") tdLog.printNoPrefix('-r taosd restart test')
tdLog.printNoPrefix('-w taos on windows')
sys.exit(0) sys.exit(0)
if key in ["-r", "--restart"]: if key in ['-r', '--restart']:
restart = True restart = True
if key in ["-f", "--file"]: if key in ['-f', '--file']:
fileName = value fileName = value
if key in ["-p", "--path"]: if key in ['-p', '--path']:
deployPath = value deployPath = value
if key in ["-m", "--master"]: if key in ['-m', '--master']:
masterIp = value masterIp = value
if key in ["-l", "--logSql"]: if key in ['-l', '--logSql']:
if value.upper() == "TRUE": if (value.upper() == "TRUE"):
logSql = True logSql = True
elif value.upper() == "FALSE": elif (value.upper() == "FALSE"):
logSql = False logSql = False
else: else:
tdLog.printNoPrefix("logSql value %s is invalid" % logSql) tdLog.printNoPrefix("logSql value %s is invalid" % logSql)
sys.exit(0) sys.exit(0)
if key in ["-c", "--cluster"]: if key in ['-c', '--cluster']:
testCluster = True testCluster = True
if key in ["-g", "--valgrind"]: if key in ['-g', '--valgrind']:
valgrind = 1 valgrind = 1
if key in ["-s", "--stop"]: if key in ['-s', '--stop']:
stop = 1 stop = 1
if key in ["-w", "--windows"]: if key in ['-w', '--windows']:
windows = 1 windows = 1
if stop != 0: if (stop != 0):
if valgrind == 0: if (valgrind == 0):
toBeKilled = "taosd" toBeKilled = "taosd"
else: else:
toBeKilled = "valgrind.bin" toBeKilled = "valgrind.bin"
killCmd = ( killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
% toBeKilled
)
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
while processID: while(processID):
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
...@@ -130,26 +116,25 @@ if __name__ == "__main__": ...@@ -130,26 +116,25 @@ if __name__ == "__main__":
if valgrind: if valgrind:
time.sleep(2) time.sleep(2)
tdLog.info("stop All dnodes") tdLog.info('stop All dnodes')
if masterIp == "": if masterIp == "":
host = "127.0.0.1" host = '127.0.0.1'
else: else:
host = masterIp host = masterIp
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
uModule = tdDnodes.import_module(fileName)
if windows: if windows:
tdCases.logSql(logSql) tdCases.logSql(logSql)
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
td_clinet = TDSimClient("C:\\TDengine") td_clinet = TDSimClient("C:\\TDengine")
td_clinet.deploy() td_clinet.deploy()
remote_conn = Connection("root@%s" % host) remote_conn = Connection("root@%s"%host)
with remote_conn.cd( with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn.run("python3 ./test.py") remote_conn.run("python3 ./test.py")
conn = taos.connect(host="%s" % (host), config=td_clinet.cfgDir) conn = taos.connect(
host="%s"%(host),
config=td_clinet.cfgDir)
tdCases.runOneWindows(conn, fileName) tdCases.runOneWindows(conn, fileName)
else: else:
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
...@@ -157,24 +142,27 @@ if __name__ == "__main__": ...@@ -157,24 +142,27 @@ if __name__ == "__main__":
tdDnodes.setValgrind(valgrind) tdDnodes.setValgrind(valgrind)
tdDnodes.stopAll() tdDnodes.stopAll()
is_test_framework = 0 is_test_framework = 0
key_word = "tdCases.addLinux" key_word = 'tdCases.addLinux'
try: try:
if key_word in open(fileName).read(): if key_word in open(fileName).read():
is_test_framework = 1 is_test_framework = 1
except: except:
pass pass
if is_test_framework: if is_test_framework:
moduleName = fileName.replace(".py", "").replace("/", ".")
uModule = importlib.import_module(moduleName)
try: try:
ucase = uModule.TDTestCase() ucase = uModule.TDTestCase()
tdDnodes.deploy(1, ucase.updatecfgDict) tdDnodes.deploy(1,ucase.updatecfgDict)
del uModule except :
except: tdDnodes.deploy(1,{})
tdDnodes.deploy(1, {})
else: else:
pass pass
tdDnodes.deploy(1, {}) tdDnodes.deploy(1,{})
tdDnodes.start(1) tdDnodes.start(1)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if testCluster: if testCluster:
...@@ -185,25 +173,26 @@ if __name__ == "__main__": ...@@ -185,25 +173,26 @@ if __name__ == "__main__":
tdCases.runOneCluster(fileName) tdCases.runOneCluster(fileName)
else: else:
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect(
host,
config=tdDnodes.getSimCfgPath())
if fileName == "all": if fileName == "all":
tdCases.runAllLinux(conn) tdCases.runAllLinux(conn)
else: else:
tdCases.runOneLinux(conn, fileName, uModule) tdCases.runOneWindows(conn, fileName)
if restart: if restart:
if fileName == "all": if fileName == "all":
tdLog.info("not need to query ") tdLog.info("not need to query ")
else: else:
sp = fileName.rsplit(".", 1) sp = fileName.rsplit(".", 1)
if len(sp) == 2 and sp[1] == "py": if len(sp) == 2 and sp[1] == "py":
tdDnodes.stopAll() tdDnodes.stopAll()
tdDnodes.start(1) tdDnodes.start(1)
time.sleep(1) time.sleep(1)
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect( host, config=tdDnodes.getSimCfgPath())
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
tdLog.info("query test after taosd restart") tdLog.info("query test after taosd restart")
tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py")
else: else:
tdLog.info("not need to query") tdLog.info("not need to query")
conn.close() conn.close()
...@@ -37,83 +37,68 @@ if __name__ == "__main__": ...@@ -37,83 +37,68 @@ if __name__ == "__main__":
stop = 0 stop = 0
restart = False restart = False
windows = 0 windows = 0
opts, args = getopt.gnu_getopt( opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [
sys.argv[1:], 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows'])
"f:p:m:l:scghrw",
[
"file=",
"path=",
"master",
"logSql",
"stop",
"cluster",
"valgrind",
"help",
"windows",
],
)
for key, value in opts: for key, value in opts:
if key in ["-h", "--help"]: if key in ['-h', '--help']:
tdLog.printNoPrefix("A collection of test cases written using Python") tdLog.printNoPrefix(
tdLog.printNoPrefix("-f Name of test case file written by Python") 'A collection of test cases written using Python')
tdLog.printNoPrefix("-p Deploy Path for Simulator") tdLog.printNoPrefix('-f Name of test case file written by Python')
tdLog.printNoPrefix("-m Master Ip for Simulator") tdLog.printNoPrefix('-p Deploy Path for Simulator')
tdLog.printNoPrefix("-l <True:False> logSql Flag") tdLog.printNoPrefix('-m Master Ip for Simulator')
tdLog.printNoPrefix("-s stop All dnodes") tdLog.printNoPrefix('-l <True:False> logSql Flag')
tdLog.printNoPrefix("-c Test Cluster Flag") tdLog.printNoPrefix('-s stop All dnodes')
tdLog.printNoPrefix("-g valgrind Test Flag") tdLog.printNoPrefix('-c Test Cluster Flag')
tdLog.printNoPrefix("-r taosd restart test") tdLog.printNoPrefix('-g valgrind Test Flag')
tdLog.printNoPrefix("-w taos on windows") tdLog.printNoPrefix('-r taosd restart test')
tdLog.printNoPrefix('-w taos on windows')
sys.exit(0) sys.exit(0)
if key in ["-r", "--restart"]: if key in ['-r', '--restart']:
restart = True restart = True
if key in ["-f", "--file"]: if key in ['-f', '--file']:
fileName = value fileName = value
if key in ["-p", "--path"]: if key in ['-p', '--path']:
deployPath = value deployPath = value
if key in ["-m", "--master"]: if key in ['-m', '--master']:
masterIp = value masterIp = value
if key in ["-l", "--logSql"]: if key in ['-l', '--logSql']:
if value.upper() == "TRUE": if (value.upper() == "TRUE"):
logSql = True logSql = True
elif value.upper() == "FALSE": elif (value.upper() == "FALSE"):
logSql = False logSql = False
else: else:
tdLog.printNoPrefix("logSql value %s is invalid" % logSql) tdLog.printNoPrefix("logSql value %s is invalid" % logSql)
sys.exit(0) sys.exit(0)
if key in ["-c", "--cluster"]: if key in ['-c', '--cluster']:
testCluster = True testCluster = True
if key in ["-g", "--valgrind"]: if key in ['-g', '--valgrind']:
valgrind = 1 valgrind = 1
if key in ["-s", "--stop"]: if key in ['-s', '--stop']:
stop = 1 stop = 1
if key in ["-w", "--windows"]: if key in ['-w', '--windows']:
windows = 1 windows = 1
if stop != 0: if (stop != 0):
if valgrind == 0: if (valgrind == 0):
toBeKilled = "taosd" toBeKilled = "taosd"
else: else:
toBeKilled = "valgrind.bin" toBeKilled = "valgrind.bin"
killCmd = ( killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
% toBeKilled
)
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
while processID: while(processID):
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
...@@ -130,26 +115,25 @@ if __name__ == "__main__": ...@@ -130,26 +115,25 @@ if __name__ == "__main__":
if valgrind: if valgrind:
time.sleep(2) time.sleep(2)
tdLog.info("stop All dnodes") tdLog.info('stop All dnodes')
if masterIp == "": if masterIp == "":
host = "127.0.0.1" host = '127.0.0.1'
else: else:
host = masterIp host = masterIp
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
uModule = tdDnodes.import_module(fileName)
if windows: if windows:
tdCases.logSql(logSql) tdCases.logSql(logSql)
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
td_clinet = TDSimClient("C:\\TDengine") td_clinet = TDSimClient("C:\\TDengine")
td_clinet.deploy() td_clinet.deploy()
remote_conn = Connection("root@%s" % host) remote_conn = Connection("root@%s"%host)
with remote_conn.cd( with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn.run("python3 ./test.py") remote_conn.run("python3 ./test.py")
conn = taos.connect(host="%s" % (host), config=td_clinet.cfgDir) conn = taos.connect(
host="%s"%(host),
config=td_clinet.cfgDir)
tdCases.runOneWindows(conn, fileName) tdCases.runOneWindows(conn, fileName)
else: else:
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
...@@ -157,24 +141,27 @@ if __name__ == "__main__": ...@@ -157,24 +141,27 @@ if __name__ == "__main__":
tdDnodes.setValgrind(valgrind) tdDnodes.setValgrind(valgrind)
tdDnodes.stopAll() tdDnodes.stopAll()
is_test_framework = 0 is_test_framework = 0
key_word = "tdCases.addLinux" key_word = 'tdCases.addLinux'
try: try:
if key_word in open(fileName).read(): if key_word in open(fileName).read():
is_test_framework = 1 is_test_framework = 1
except: except:
pass pass
if is_test_framework: if is_test_framework:
moduleName = fileName.replace(".py", "").replace("/", ".")
uModule = importlib.import_module(moduleName)
try: try:
ucase = uModule.TDTestCase() ucase = uModule.TDTestCase()
tdDnodes.deploy(1, ucase.updatecfgDict) tdDnodes.deploy(1,ucase.updatecfgDict)
del uModule except :
except: tdDnodes.deploy(1,{})
tdDnodes.deploy(1, {})
else: else:
pass pass
tdDnodes.deploy(1, {}) tdDnodes.deploy(1,{})
tdDnodes.start(1) tdDnodes.start(1)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if testCluster: if testCluster:
...@@ -185,21 +172,23 @@ if __name__ == "__main__": ...@@ -185,21 +172,23 @@ if __name__ == "__main__":
tdCases.runOneCluster(fileName) tdCases.runOneCluster(fileName)
else: else:
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect(
host,
config=tdDnodes.getSimCfgPath())
if fileName == "all": if fileName == "all":
tdCases.runAllLinux(conn) tdCases.runAllLinux(conn)
else: else:
tdCases.runOneLinux(conn, fileName, uModule) tdCases.runOneWindows(conn, fileName)
if restart: if restart:
if fileName == "all": if fileName == "all":
tdLog.info("not need to query ") tdLog.info("not need to query ")
else: else:
sp = fileName.rsplit(".", 1) sp = fileName.rsplit(".", 1)
if len(sp) == 2 and sp[1] == "py": if len(sp) == 2 and sp[1] == "py":
tdDnodes.stopAll() tdDnodes.stopAll()
tdDnodes.start(1) tdDnodes.start(1)
time.sleep(1) time.sleep(1)
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect( host, config=tdDnodes.getSimCfgPath())
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
tdLog.info("query test after taosd restart") tdLog.info("query test after taosd restart")
tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py")
......
...@@ -17,7 +17,6 @@ import time ...@@ -17,7 +17,6 @@ import time
import datetime import datetime
import inspect import inspect
import importlib import importlib
from util.dnodes import *
from util.log import * from util.log import *
...@@ -35,9 +34,8 @@ class TDCases: ...@@ -35,9 +34,8 @@ class TDCases:
self.clusterCases = [] self.clusterCases = []
def __dynamicLoadModule(self, fileName): def __dynamicLoadModule(self, fileName):
# moduleName = fileName.replace(".py", "").replace(os.sep, ".") moduleName = fileName.replace(".py", "").replace(os.sep, ".")
# return importlib.import_module(moduleName, package='..') return importlib.import_module(moduleName, package='..')
return tdDnodes.import_module(fileName)
def logSql(self, logSql): def logSql(self, logSql):
self._logSql = logSql self._logSql = logSql
...@@ -65,11 +63,10 @@ class TDCases: ...@@ -65,11 +63,10 @@ class TDCases:
tdLog.info("total %d Linux test case(s) executed" % (runNum)) tdLog.info("total %d Linux test case(s) executed" % (runNum))
def runOneLinux(self, conn, fileName, testModule): def runOneLinux(self, conn, fileName):
# testModule = self.__dynamicLoadModule(fileName) testModule = self.__dynamicLoadModule(fileName)
runNum = 0 runNum = 0
if fileName.startswith(".."):
fileName = fileName[3:]
for tmp in self.linuxCases: for tmp in self.linuxCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(fileName) != -1:
case = testModule.TDTestCase() case = testModule.TDTestCase()
...@@ -98,7 +95,7 @@ class TDCases: ...@@ -98,7 +95,7 @@ class TDCases:
tdLog.notice("total %d Windows test case(s) executed" % (runNum)) tdLog.notice("total %d Windows test case(s) executed" % (runNum))
def runOneWindows(self, conn, fileName): def runOneWindows(self, conn, fileName):
# testModule = self.__dynamicLoadModule(fileName) testModule = self.__dynamicLoadModule(fileName)
runNum = 0 runNum = 0
for tmp in self.windowsCases: for tmp in self.windowsCases:
...@@ -133,7 +130,7 @@ class TDCases: ...@@ -133,7 +130,7 @@ class TDCases:
tdLog.notice("total %d Cluster test case(s) executed" % (runNum)) tdLog.notice("total %d Cluster test case(s) executed" % (runNum))
def runOneCluster(self, fileName): def runOneCluster(self, fileName):
# testModule = self.__dynamicLoadModule(fileName) testModule = self.__dynamicLoadModule(fileName)
runNum = 0 runNum = 0
for tmp in self.clusterCases: for tmp in self.clusterCases:
......
...@@ -18,7 +18,6 @@ import platform ...@@ -18,7 +18,6 @@ import platform
import pathlib import pathlib
import shutil import shutil
import subprocess import subprocess
import importlib
from time import sleep from time import sleep
from util.log import * from util.log import *
...@@ -580,13 +579,6 @@ class TDDnodes: ...@@ -580,13 +579,6 @@ class TDDnodes:
def check(self, index): def check(self, index):
if index < 1 or index > 10: if index < 1 or index > 10:
tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) tdLog.exit("index:%d should on a scale of [1, 10]" % (index))
def import_module(self,fileName):
module_dir, module_file = os.path.split(fileName)
module_name, module_ext = os.path.splitext(module_file)
spec = importlib.util.spec_from_file_location(module_name,fileName)
uModule = spec.loader.load_module()
return uModule
def stopAll(self): def stopAll(self):
tdLog.info("stop all dnodes") tdLog.info("stop all dnodes")
......
...@@ -28,6 +28,7 @@ import taos ...@@ -28,6 +28,7 @@ import taos
if __name__ == "__main__": if __name__ == "__main__":
fileName = "all" fileName = "all"
deployPath = "" deployPath = ""
masterIp = "" masterIp = ""
...@@ -37,83 +38,68 @@ if __name__ == "__main__": ...@@ -37,83 +38,68 @@ if __name__ == "__main__":
stop = 0 stop = 0
restart = False restart = False
windows = 0 windows = 0
opts, args = getopt.gnu_getopt( opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [
sys.argv[1:], 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows'])
"f:p:m:l:scghrw",
[
"file=",
"path=",
"master",
"logSql",
"stop",
"cluster",
"valgrind",
"help",
"windows",
],
)
for key, value in opts: for key, value in opts:
if key in ["-h", "--help"]: if key in ['-h', '--help']:
tdLog.printNoPrefix("A collection of test cases written using Python") tdLog.printNoPrefix(
tdLog.printNoPrefix("-f Name of test case file written by Python") 'A collection of test cases written using Python')
tdLog.printNoPrefix("-p Deploy Path for Simulator") tdLog.printNoPrefix('-f Name of test case file written by Python')
tdLog.printNoPrefix("-m Master Ip for Simulator") tdLog.printNoPrefix('-p Deploy Path for Simulator')
tdLog.printNoPrefix("-l <True:False> logSql Flag") tdLog.printNoPrefix('-m Master Ip for Simulator')
tdLog.printNoPrefix("-s stop All dnodes") tdLog.printNoPrefix('-l <True:False> logSql Flag')
tdLog.printNoPrefix("-c Test Cluster Flag") tdLog.printNoPrefix('-s stop All dnodes')
tdLog.printNoPrefix("-g valgrind Test Flag") tdLog.printNoPrefix('-c Test Cluster Flag')
tdLog.printNoPrefix("-r taosd restart test") tdLog.printNoPrefix('-g valgrind Test Flag')
tdLog.printNoPrefix("-w taos on windows") tdLog.printNoPrefix('-r taosd restart test')
tdLog.printNoPrefix('-w taos on windows')
sys.exit(0) sys.exit(0)
if key in ["-r", "--restart"]: if key in ['-r', '--restart']:
restart = True restart = True
if key in ["-f", "--file"]: if key in ['-f', '--file']:
fileName = value fileName = value
if key in ["-p", "--path"]: if key in ['-p', '--path']:
deployPath = value deployPath = value
if key in ["-m", "--master"]: if key in ['-m', '--master']:
masterIp = value masterIp = value
if key in ["-l", "--logSql"]: if key in ['-l', '--logSql']:
if value.upper() == "TRUE": if (value.upper() == "TRUE"):
logSql = True logSql = True
elif value.upper() == "FALSE": elif (value.upper() == "FALSE"):
logSql = False logSql = False
else: else:
tdLog.printNoPrefix("logSql value %s is invalid" % logSql) tdLog.printNoPrefix("logSql value %s is invalid" % logSql)
sys.exit(0) sys.exit(0)
if key in ["-c", "--cluster"]: if key in ['-c', '--cluster']:
testCluster = True testCluster = True
if key in ["-g", "--valgrind"]: if key in ['-g', '--valgrind']:
valgrind = 1 valgrind = 1
if key in ["-s", "--stop"]: if key in ['-s', '--stop']:
stop = 1 stop = 1
if key in ["-w", "--windows"]: if key in ['-w', '--windows']:
windows = 1 windows = 1
if stop != 0: if (stop != 0):
if valgrind == 0: if (valgrind == 0):
toBeKilled = "taosd" toBeKilled = "taosd"
else: else:
toBeKilled = "valgrind.bin" toBeKilled = "valgrind.bin"
killCmd = ( killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
% toBeKilled
)
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
while processID: while(processID):
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
...@@ -130,26 +116,25 @@ if __name__ == "__main__": ...@@ -130,26 +116,25 @@ if __name__ == "__main__":
if valgrind: if valgrind:
time.sleep(2) time.sleep(2)
tdLog.info("stop All dnodes") tdLog.info('stop All dnodes')
if masterIp == "": if masterIp == "":
host = "127.0.0.1" host = '127.0.0.1'
else: else:
host = masterIp host = masterIp
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
uModule = tdDnodes.import_module(fileName)
if windows: if windows:
tdCases.logSql(logSql) tdCases.logSql(logSql)
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
td_clinet = TDSimClient("C:\\TDengine") td_clinet = TDSimClient("C:\\TDengine")
td_clinet.deploy() td_clinet.deploy()
remote_conn = Connection("root@%s" % host) remote_conn = Connection("root@%s"%host)
with remote_conn.cd( with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn.run("python3 ./test.py") remote_conn.run("python3 ./test.py")
conn = taos.connect(host="%s" % (host), config=td_clinet.cfgDir) conn = taos.connect(
host="%s"%(host),
config=td_clinet.cfgDir)
tdCases.runOneWindows(conn, fileName) tdCases.runOneWindows(conn, fileName)
else: else:
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
...@@ -157,24 +142,27 @@ if __name__ == "__main__": ...@@ -157,24 +142,27 @@ if __name__ == "__main__":
tdDnodes.setValgrind(valgrind) tdDnodes.setValgrind(valgrind)
tdDnodes.stopAll() tdDnodes.stopAll()
is_test_framework = 0 is_test_framework = 0
key_word = "tdCases.addLinux" key_word = 'tdCases.addLinux'
try: try:
if key_word in open(fileName).read(): if key_word in open(fileName).read():
is_test_framework = 1 is_test_framework = 1
except: except:
pass pass
if is_test_framework: if is_test_framework:
moduleName = fileName.replace(".py", "").replace("/", ".")
uModule = importlib.import_module(moduleName)
try: try:
ucase = uModule.TDTestCase() ucase = uModule.TDTestCase()
tdDnodes.deploy(1, ucase.updatecfgDict) tdDnodes.deploy(1,ucase.updatecfgDict)
del uModule except :
except: tdDnodes.deploy(1,{})
tdDnodes.deploy(1, {})
else: else:
pass pass
tdDnodes.deploy(1, {}) tdDnodes.deploy(1,{})
tdDnodes.start(1) tdDnodes.start(1)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if testCluster: if testCluster:
...@@ -185,25 +173,26 @@ if __name__ == "__main__": ...@@ -185,25 +173,26 @@ if __name__ == "__main__":
tdCases.runOneCluster(fileName) tdCases.runOneCluster(fileName)
else: else:
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect(
host,
config=tdDnodes.getSimCfgPath())
if fileName == "all": if fileName == "all":
tdCases.runAllLinux(conn) tdCases.runAllLinux(conn)
else: else:
tdCases.runOneLinux(conn, fileName, uModule) tdCases.runOneWindows(conn, fileName)
if restart: if restart:
if fileName == "all": if fileName == "all":
tdLog.info("not need to query ") tdLog.info("not need to query ")
else: else:
sp = fileName.rsplit(".", 1) sp = fileName.rsplit(".", 1)
if len(sp) == 2 and sp[1] == "py": if len(sp) == 2 and sp[1] == "py":
tdDnodes.stopAll() tdDnodes.stopAll()
tdDnodes.start(1) tdDnodes.start(1)
time.sleep(1) time.sleep(1)
conn = taos.connect(host, config=tdDnodes.getSimCfgPath()) conn = taos.connect( host, config=tdDnodes.getSimCfgPath())
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
tdLog.info("query test after taosd restart") tdLog.info("query test after taosd restart")
tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py")
else: else:
tdLog.info("not need to query") tdLog.info("not need to query")
conn.close() conn.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册