fix(os): windows run shell case
This commit is contained in:
parent
38d69cc119
commit
f999132ff0
|
@ -18,6 +18,7 @@ import getopt
|
|||
import subprocess
|
||||
import time
|
||||
from distutils.log import warn as printf
|
||||
import platform
|
||||
|
||||
from util.log import *
|
||||
from util.dnodes import *
|
||||
|
@ -36,8 +37,10 @@ if __name__ == "__main__":
|
|||
stop = 0
|
||||
restart = False
|
||||
windows = 0
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows'])
|
||||
if platform.system().lower() == 'windows':
|
||||
windows = 1
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghr', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart'])
|
||||
for key, value in opts:
|
||||
if key in ['-h', '--help']:
|
||||
tdLog.printNoPrefix(
|
||||
|
@ -64,9 +67,6 @@ if __name__ == "__main__":
|
|||
if key in ['-m', '--master']:
|
||||
masterIp = value
|
||||
|
||||
if key in ['-w', '--windows']:
|
||||
windows = 1
|
||||
|
||||
if key in ['-l', '--logSql']:
|
||||
if (value.upper() == "TRUE"):
|
||||
logSql = True
|
||||
|
@ -146,7 +146,7 @@ if __name__ == "__main__":
|
|||
else:
|
||||
pass
|
||||
tdDnodes.deploy(1,{})
|
||||
tdDnodes.startWin(1)
|
||||
tdDnodes.start(1)
|
||||
else:
|
||||
remote_conn = Connection("root@%s"%host)
|
||||
with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
|
||||
|
|
|
@ -333,7 +333,7 @@ class TDDnode:
|
|||
if self.deployed == 0:
|
||||
tdLog.exit("dnode:%d is not deployed" % (self.index))
|
||||
|
||||
cmd = "mintty -h never %s -c %s" % (
|
||||
cmd = "mintty -h never -w hide %s -c %s" % (
|
||||
binPath, self.cfgDir)
|
||||
|
||||
if (taosadapterBinPath != ""):
|
||||
|
@ -424,6 +424,7 @@ class TDDnode:
|
|||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
if not platform.system().lower() == 'windows':
|
||||
for port in range(6030, 6041):
|
||||
fuserCmd = "fuser -k -n tcp %d" % port
|
||||
os.system(fuserCmd)
|
||||
|
@ -571,11 +572,10 @@ class TDDnodes:
|
|||
|
||||
def start(self, index):
|
||||
self.check(index)
|
||||
self.dnodes[index - 1].start()
|
||||
|
||||
def startWin(self, index):
|
||||
self.check(index)
|
||||
if platform.system().lower() == 'windows':
|
||||
self.dnodes[index - 1].startWin()
|
||||
else:
|
||||
self.dnodes[index - 1].start()
|
||||
|
||||
def startWithoutSleep(self, index):
|
||||
self.check(index)
|
||||
|
|
|
@ -3,7 +3,11 @@ import taos
|
|||
import sys
|
||||
import time
|
||||
import socket
|
||||
import pexpect
|
||||
import platform
|
||||
if platform.system().lower() == 'windows':
|
||||
import wexpect as taosExpect
|
||||
else:
|
||||
import pexpect as taosExpect
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
|
@ -15,6 +19,10 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
if len(key) == 0:
|
||||
tdLog.exit("taos test key is null!")
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
taosCmd = buildPath + '\\build\\bin\\taos.exe '
|
||||
taosCmd = taosCmd.replace('\\','\\\\')
|
||||
else:
|
||||
taosCmd = buildPath + '/build/bin/taos '
|
||||
if len(cfgDir) != 0:
|
||||
taosCmd = taosCmd + '-c ' + cfgDir
|
||||
|
@ -36,14 +44,17 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
|
||||
tdLog.info ("taos cmd: %s" % taosCmd)
|
||||
|
||||
child = pexpect.spawn(taosCmd, timeout=3)
|
||||
child = taosExpect.spawn(taosCmd, timeout=3)
|
||||
#output = child.readline()
|
||||
#print (output.decode())
|
||||
if len(expectString) != 0:
|
||||
i = child.expect([expectString, pexpect.TIMEOUT, pexpect.EOF], timeout=6)
|
||||
i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
|
||||
else:
|
||||
i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6)
|
||||
i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
retResult = child.before
|
||||
else:
|
||||
retResult = child.before.decode()
|
||||
print("cmd return result:\n%s\n"%retResult)
|
||||
#print(child.after.decode())
|
||||
|
@ -51,7 +62,10 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
print ('taos login success! Here can run sql, taos> ')
|
||||
if len(sqlString) != 0:
|
||||
child.sendline (sqlString)
|
||||
w = child.expect(["Query OK", pexpect.TIMEOUT, pexpect.EOF], timeout=1)
|
||||
w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1)
|
||||
if platform.system().lower() == 'windows':
|
||||
retResult = child.before
|
||||
else:
|
||||
retResult = child.before.decode()
|
||||
if w == 0:
|
||||
return "TAOS_OK", retResult
|
||||
|
@ -103,7 +117,7 @@ class TDTestCase:
|
|||
projPath = selfPath[:selfPath.find("tests")]
|
||||
|
||||
for root, dirs, files in os.walk(projPath):
|
||||
if ("taosd" in files):
|
||||
if ("taosd" in files or "taosd.exe" in files):
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if ("packaging" not in rootRealPath):
|
||||
buildPath = root[:len(root) - len("/build/bin")]
|
||||
|
|
|
@ -3,7 +3,11 @@ import taos
|
|||
import sys
|
||||
import time
|
||||
import socket
|
||||
import pexpect
|
||||
import platform
|
||||
if platform.system().lower() == 'windows':
|
||||
import wexpect as taosExpect
|
||||
else:
|
||||
import pexpect as taosExpect
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
|
@ -15,6 +19,10 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
if len(key) == 0:
|
||||
tdLog.exit("taos test key is null!")
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
taosCmd = buildPath + '\\build\\bin\\taos.exe '
|
||||
taosCmd = taosCmd.replace('\\','\\\\')
|
||||
else:
|
||||
taosCmd = buildPath + '/build/bin/taos '
|
||||
if len(cfgDir) != 0:
|
||||
taosCmd = taosCmd + '-c ' + cfgDir
|
||||
|
@ -36,14 +44,17 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
|
||||
tdLog.info ("taos cmd: %s" % taosCmd)
|
||||
|
||||
child = pexpect.spawn(taosCmd, timeout=3)
|
||||
child = taosExpect.spawn(taosCmd, timeout=3)
|
||||
#output = child.readline()
|
||||
#print (output.decode())
|
||||
if len(expectString) != 0:
|
||||
i = child.expect([expectString, pexpect.TIMEOUT, pexpect.EOF], timeout=6)
|
||||
i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
|
||||
else:
|
||||
i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6)
|
||||
i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
retResult = child.before
|
||||
else:
|
||||
retResult = child.before.decode()
|
||||
print("expect() return code: %d, content:\n %s\n"%(i, retResult))
|
||||
#print(child.after.decode())
|
||||
|
@ -51,7 +62,10 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
|
|||
print ('taos login success! Here can run sql, taos> ')
|
||||
if len(sqlString) != 0:
|
||||
child.sendline (sqlString)
|
||||
w = child.expect(["Query OK", pexpect.TIMEOUT, pexpect.EOF], timeout=1)
|
||||
w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1)
|
||||
if platform.system().lower() == 'windows':
|
||||
retResult = child.before
|
||||
else:
|
||||
retResult = child.before.decode()
|
||||
if w == 0:
|
||||
return "TAOS_OK", retResult
|
||||
|
@ -103,7 +117,7 @@ class TDTestCase:
|
|||
projPath = selfPath[:selfPath.find("tests")]
|
||||
|
||||
for root, dirs, files in os.walk(projPath):
|
||||
if ("taosd" in files):
|
||||
if ("taosd" in files or "taosd.exe" in files):
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if ("packaging" not in rootRealPath):
|
||||
buildPath = root[:len(root) - len("/build/bin")]
|
||||
|
@ -168,6 +182,11 @@ class TDTestCase:
|
|||
tdDnodes.stop(1)
|
||||
|
||||
role = 'server'
|
||||
if platform.system().lower() == 'windows':
|
||||
taosCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\taos.exe -c ' + keyDict['c']
|
||||
taosCmd = taosCmd.replace('\\','\\\\')
|
||||
taosCmd = taosCmd + ' -n ' + role
|
||||
else:
|
||||
taosCmd = 'nohup ' + buildPath + '/build/bin/taos -c ' + keyDict['c']
|
||||
taosCmd = taosCmd + ' -n ' + role + ' > /dev/null 2>&1 &'
|
||||
print (taosCmd)
|
||||
|
@ -176,12 +195,19 @@ class TDTestCase:
|
|||
pktLen = '2000'
|
||||
pktNum = '10'
|
||||
role = 'client'
|
||||
if platform.system().lower() == 'windows':
|
||||
taosCmd = buildPath + '\\build\\bin\\taos.exe -c ' + keyDict['c']
|
||||
taosCmd = taosCmd.replace('\\','\\\\')
|
||||
else:
|
||||
taosCmd = buildPath + '/build/bin/taos -c ' + keyDict['c']
|
||||
taosCmd = taosCmd + ' -n ' + role + ' -l ' + pktLen + ' -N ' + pktNum
|
||||
print (taosCmd)
|
||||
child = pexpect.spawn(taosCmd, timeout=3)
|
||||
i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6)
|
||||
child = taosExpect.spawn(taosCmd, timeout=3)
|
||||
i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
retResult = child.before
|
||||
else:
|
||||
retResult = child.before.decode()
|
||||
print("expect() return code: %d, content:\n %s\n"%(i, retResult))
|
||||
#print(child.after.decode())
|
||||
|
@ -195,6 +221,9 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.exit('taos -n client fail!')
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
os.system('ps -a | grep taos | awk \'{print $2}\' | xargs kill -9')
|
||||
else:
|
||||
os.system('pkill taos')
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -2,7 +2,7 @@ import taos
|
|||
import sys
|
||||
import time
|
||||
import socket
|
||||
import pexpect
|
||||
# import pexpect
|
||||
import os
|
||||
import http.server
|
||||
import gzip
|
||||
|
|
|
@ -2,7 +2,7 @@ import taos
|
|||
import sys
|
||||
import time
|
||||
import socket
|
||||
import pexpect
|
||||
# import pexpect
|
||||
import os
|
||||
import http.server
|
||||
import gzip
|
||||
|
|
|
@ -19,6 +19,7 @@ import subprocess
|
|||
import time
|
||||
import base64
|
||||
import json
|
||||
import platform
|
||||
from distutils.log import warn as printf
|
||||
from fabric2 import Connection
|
||||
sys.path.append("../pytest")
|
||||
|
@ -40,9 +41,11 @@ if __name__ == "__main__":
|
|||
stop = 0
|
||||
restart = False
|
||||
windows = 0
|
||||
if platform.system().lower() == 'windows':
|
||||
windows = 1
|
||||
updateCfgDict = {}
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrwd:', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows', 'updateCfgDict'])
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:', [
|
||||
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict'])
|
||||
for key, value in opts:
|
||||
if key in ['-h', '--help']:
|
||||
tdLog.printNoPrefix(
|
||||
|
@ -55,7 +58,6 @@ if __name__ == "__main__":
|
|||
tdLog.printNoPrefix('-c Test Cluster Flag')
|
||||
tdLog.printNoPrefix('-g valgrind Test Flag')
|
||||
tdLog.printNoPrefix('-r taosd restart test')
|
||||
tdLog.printNoPrefix('-w taos on windows')
|
||||
tdLog.printNoPrefix('-d update cfg dict, base64 json str')
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -89,9 +91,6 @@ if __name__ == "__main__":
|
|||
if key in ['-s', '--stop']:
|
||||
stop = 1
|
||||
|
||||
if key in ['-w', '--windows']:
|
||||
windows = 1
|
||||
|
||||
if key in ['-d', '--updateCfgDict']:
|
||||
try:
|
||||
updateCfgDict = eval(base64.b64decode(value.encode()).decode())
|
||||
|
@ -163,13 +162,13 @@ if __name__ == "__main__":
|
|||
pass
|
||||
tdDnodes.deploy(1,updateCfgDict)
|
||||
if masterIp == "" or masterIp == "localhost":
|
||||
tdDnodes.startWin(1)
|
||||
tdDnodes.start(1)
|
||||
else:
|
||||
remote_conn = Connection("root@%s"%host)
|
||||
with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
|
||||
remote_conn.run("python3 ./test.py %s"%updateCfgDictStr)
|
||||
# print("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr)
|
||||
# os.system("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr)
|
||||
# os.system("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && (ps -aux | grep taosd | head -n 1 | awk '{print $2}' | xargs kill -9) && rm -rf /root/test/sim/dnode1/data/ && python3 ./test.py %s\""%updateCfgDictStr)
|
||||
# time.sleep(2)
|
||||
conn = taos.connect(
|
||||
host="%s"%(host),
|
||||
|
|
Loading…
Reference in New Issue