test: support taosc run by valgrind to python cases

This commit is contained in:
plum-lihui 2022-05-31 16:46:01 +08:00
parent 2bc9d1d703
commit f8d29a12ab
2 changed files with 30 additions and 18 deletions

View File

@ -494,6 +494,7 @@ class TDDnodes:
self.simDeployed = False self.simDeployed = False
self.testCluster = False self.testCluster = False
self.valgrind = 0 self.valgrind = 0
self.killValgrind = 1
def init(self, path, remoteIP = ""): def init(self, path, remoteIP = ""):
psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'" psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'"
@ -505,14 +506,15 @@ class TDDnodes:
processID = subprocess.check_output( processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8") psCmd, shell=True).decode("utf-8")
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" if self.killValgrind == 1:
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
while(processID): processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
killCmd = "kill -9 %s > /dev/null 2>&1" % processID while(processID):
os.system(killCmd) killCmd = "kill -9 %s > /dev/null 2>&1" % processID
time.sleep(1) os.system(killCmd)
processID = subprocess.check_output( time.sleep(1)
psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
binPath = self.dnodes[0].getPath() + "/../../../" binPath = self.dnodes[0].getPath() + "/../../../"
# tdLog.debug("binPath %s" % (binPath)) # tdLog.debug("binPath %s" % (binPath))
@ -549,6 +551,9 @@ class TDDnodes:
def setValgrind(self, value): def setValgrind(self, value):
self.valgrind = value self.valgrind = value
def setKillValgrind(self, value):
self.killValgrind = value
def deploy(self, index, *updatecfgDict): def deploy(self, index, *updatecfgDict):
self.sim.setTestCluster(self.testCluster) self.sim.setTestCluster(self.testCluster)
@ -622,14 +627,15 @@ class TDDnodes:
processID = subprocess.check_output( processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8") psCmd, shell=True).decode("utf-8")
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" if self.killValgrind == 1:
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
while(processID): processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
killCmd = "kill -TERM %s > /dev/null 2>&1" % processID while(processID):
os.system(killCmd) killCmd = "kill -TERM %s > /dev/null 2>&1" % processID
time.sleep(1) os.system(killCmd)
processID = subprocess.check_output( time.sleep(1)
psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
# if os.system(cmd) != 0 : # if os.system(cmd) != 0 :
# tdLog.exit(cmd) # tdLog.exit(cmd)

View File

@ -37,6 +37,7 @@ if __name__ == "__main__":
masterIp = "" masterIp = ""
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
killValgrind = 1
logSql = True logSql = True
stop = 0 stop = 0
restart = False restart = False
@ -45,8 +46,8 @@ if __name__ == "__main__":
windows = 1 windows = 1
updateCfgDict = {} updateCfgDict = {}
execCmd = "" execCmd = ""
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:e:', [ opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:', [
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'execCmd']) 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd'])
for key, value in opts: for key, value in opts:
if key in ['-h', '--help']: if key in ['-h', '--help']:
tdLog.printNoPrefix( tdLog.printNoPrefix(
@ -60,6 +61,7 @@ if __name__ == "__main__":
tdLog.printNoPrefix('-g valgrind Test Flag') tdLog.printNoPrefix('-g valgrind Test Flag')
tdLog.printNoPrefix('-r taosd restart test') tdLog.printNoPrefix('-r taosd restart test')
tdLog.printNoPrefix('-d update cfg dict, base64 json str') tdLog.printNoPrefix('-d update cfg dict, base64 json str')
tdLog.printNoPrefix('-k not kill valgrind processer')
tdLog.printNoPrefix('-e eval str to run') tdLog.printNoPrefix('-e eval str to run')
sys.exit(0) sys.exit(0)
@ -100,6 +102,9 @@ if __name__ == "__main__":
print('updateCfgDict convert fail.') print('updateCfgDict convert fail.')
sys.exit(0) sys.exit(0)
if key in ['-k', '--killValgrind']:
killValgrind = 0
if key in ['-e', '--execCmd']: if key in ['-e', '--execCmd']:
try: try:
execCmd = base64.b64decode(value.encode()).decode() execCmd = base64.b64decode(value.encode()).decode()
@ -189,6 +194,7 @@ if __name__ == "__main__":
else: else:
tdCases.runAllWindows(conn) tdCases.runAllWindows(conn)
else: else:
tdDnodes.setKillValgrind(killValgrind)
tdDnodes.init(deployPath, masterIp) tdDnodes.init(deployPath, masterIp)
tdDnodes.setTestCluster(testCluster) tdDnodes.setTestCluster(testCluster)
tdDnodes.setValgrind(valgrind) tdDnodes.setValgrind(valgrind)