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