提交 9e87c3c5 编写于 作者: wafwerar's avatar wafwerar

[TD-345]<fix>: win run python test case

上级 628fd770
...@@ -371,7 +371,10 @@ int32_t taosFsync(FileFd fd) { ...@@ -371,7 +371,10 @@ int32_t taosFsync(FileFd fd) {
HANDLE h = (HANDLE)_get_osfhandle(fd); HANDLE h = (HANDLE)_get_osfhandle(fd);
return FlushFileBuffers(h); //If the function succeeds, the return value is nonzero.
//If the function fails, the return value is zero. To get extended error information, call GetLastError.
//The function fails if hFile is a handle to the console output. That is because the console output is not buffered. The function returns FALSE, and GetLastError returns ERROR_INVALID_HANDLE.
return FlushFileBuffers(h)-1;
} }
int32_t taosRename(char *oldName, char *newName) { int32_t taosRename(char *oldName, char *newName) {
......
...@@ -524,11 +524,11 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { ...@@ -524,11 +524,11 @@ int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE);
wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); char *pattern = calloc(varDataLen(pRight) + TSDB_NCHAR_SIZE, 1);
wchar_t *str = calloc(size + 1, sizeof(wchar_t)); char *str = calloc(varDataLen(pLeft) + TSDB_NCHAR_SIZE, 1);
memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); memcpy(pattern, varDataVal(pRight), varDataLen(pRight));
memcpy(str, varDataVal(pLeft), size * sizeof(wchar_t)); memcpy(str, varDataVal(pLeft), varDataLen(pLeft));
int32_t ret = WCSPatternMatch((uint32_t *)pattern, (uint32_t *)str, size, &pInfo); int32_t ret = WCSPatternMatch((uint32_t *)pattern, (uint32_t *)str, size, &pInfo);
......
...@@ -45,8 +45,7 @@ class BuildDockerCluser: ...@@ -45,8 +45,7 @@ class BuildDockerCluser:
"qdebugFlag":"135", "qdebugFlag":"135",
"maxSQLLength":"1048576" "maxSQLLength":"1048576"
} }
cmd = "mkdir -p %s" % self.dockerDir os.makedirs(self.dockerDir, exist_ok=True) # like "mkdir -p"
self.execCmd(cmd)
cmd = "cp *.yml %s" % self.dockerDir cmd = "cp *.yml %s" % self.dockerDir
self.execCmd(cmd) self.execCmd(cmd)
...@@ -100,8 +99,7 @@ class BuildDockerCluser: ...@@ -100,8 +99,7 @@ class BuildDockerCluser:
self.removeFile(self.dockerDir, i, self.dirs[2]) self.removeFile(self.dockerDir, i, self.dirs[2])
def createDir(self, rootDir, index, dir): def createDir(self, rootDir, index, dir):
cmd = "mkdir -p %s/node%d/%s" % (rootDir, index, dir) os.makedirs("%s/node%d/%s" % (rootDir, index, dir), exist_ok=True) # like "mkdir -p"
self.execCmd(cmd)
def createDirs(self): def createDirs(self):
for i in range(1, self.numOfNodes + 1): for i in range(1, self.numOfNodes + 1):
......
...@@ -34,7 +34,8 @@ class TDTestCase: ...@@ -34,7 +34,8 @@ class TDTestCase:
path = tdDnodes.dnodes[1].getDnodeRootDir(1) path = tdDnodes.dnodes[1].getDnodeRootDir(1)
print(path) print(path)
tdLog.info("sudo mkdir -p %s/data/vnode/vnode2/wal/old" % path) tdLog.info("sudo mkdir -p %s/data/vnode/vnode2/wal/old" % path)
os.system("sudo mkdir -p %s/data/vnode/vnode2/wal/old" % path) os.makedirs("%s/data/vnode/vnode2/wal/old" % path, exist_ok=True) # like "mkdir -p"
def run(self): def run(self):
# os.system("rm -rf %s/ " % tdDnodes.getDnodesRootDir()) # os.system("rm -rf %s/ " % tdDnodes.getDnodesRootDir())
......
...@@ -58,7 +58,7 @@ if __name__ == "__main__": ...@@ -58,7 +58,7 @@ if __name__ == "__main__":
restart = True restart = True
if key in ['-f', '--file']: if key in ['-f', '--file']:
fileName = value fileName = os.path.normpath(value)
if key in ['-p', '--path']: if key in ['-p', '--path']:
deployPath = value deployPath = value
...@@ -128,6 +128,31 @@ if __name__ == "__main__": ...@@ -128,6 +128,31 @@ if __name__ == "__main__":
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()
if masterIp == "" or masterIp == "localhost":
tdDnodes.init(deployPath)
tdDnodes.setTestCluster(testCluster)
tdDnodes.setValgrind(valgrind)
tdDnodes.stopAll()
is_test_framework = 0
key_word = 'tdCases.addWindows'
try:
if key_word in open(fileName).read():
is_test_framework = 1
except:
pass
if is_test_framework:
moduleName = fileName.replace(".py", "").replace(os.sep, ".")
uModule = importlib.import_module(moduleName)
try:
ucase = uModule.TDTestCase()
tdDnodes.deploy(1,ucase.updatecfgDict)
except :
tdDnodes.deploy(1,{})
else:
pass
tdDnodes.deploy(1,{})
tdDnodes.startWin(1)
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") remote_conn.run("python3 ./test.py")
...@@ -148,7 +173,7 @@ if __name__ == "__main__": ...@@ -148,7 +173,7 @@ if __name__ == "__main__":
except: except:
pass pass
if is_test_framework: if is_test_framework:
moduleName = fileName.replace(".py", "").replace("/", ".") moduleName = fileName.replace(".py", "").replace(os.sep, ".")
uModule = importlib.import_module(moduleName) uModule = importlib.import_module(moduleName)
try: try:
ucase = uModule.TDTestCase() ucase = uModule.TDTestCase()
......
...@@ -53,7 +53,7 @@ class TDCases: ...@@ -53,7 +53,7 @@ class TDCases:
# TODO: load all Linux cases here # TODO: load all Linux cases here
runNum = 0 runNum = 0
for tmp in self.linuxCases: for tmp in self.linuxCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(os.path.normcase(fileName)) != -1:
case = testModule.TDTestCase() case = testModule.TDTestCase()
case.init(conn) case.init(conn)
case.run() case.run()
...@@ -68,7 +68,7 @@ class TDCases: ...@@ -68,7 +68,7 @@ class TDCases:
runNum = 0 runNum = 0
for tmp in self.linuxCases: for tmp in self.linuxCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(os.path.normcase(fileName)) != -1:
case = testModule.TDTestCase() case = testModule.TDTestCase()
case.init(conn, self._logSql) case.init(conn, self._logSql)
try: try:
...@@ -84,7 +84,7 @@ class TDCases: ...@@ -84,7 +84,7 @@ class TDCases:
# TODO: load all Windows cases here # TODO: load all Windows cases here
runNum = 0 runNum = 0
for tmp in self.windowsCases: for tmp in self.windowsCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(os.path.normcase(fileName)) != -1:
case = testModule.TDTestCase() case = testModule.TDTestCase()
case.init(conn) case.init(conn)
case.run() case.run()
...@@ -118,7 +118,7 @@ class TDCases: ...@@ -118,7 +118,7 @@ class TDCases:
runNum = 0 runNum = 0
for tmp in self.clusterCases: for tmp in self.clusterCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(os.path.normcase(fileName)) != -1:
tdLog.notice("run cases like %s" % (fileName)) tdLog.notice("run cases like %s" % (fileName))
case = testModule.TDTestCase() case = testModule.TDTestCase()
case.init() case.init()
...@@ -134,7 +134,7 @@ class TDCases: ...@@ -134,7 +134,7 @@ class TDCases:
runNum = 0 runNum = 0
for tmp in self.clusterCases: for tmp in self.clusterCases:
if tmp.name.find(fileName) != -1: if tmp.name.find(os.path.normcase(fileName)) != -1:
tdLog.notice("run cases like %s" % (fileName)) tdLog.notice("run cases like %s" % (fileName))
case = testModule.TDTestCase() case = testModule.TDTestCase()
case.init() case.init()
......
...@@ -73,17 +73,13 @@ class TDSimClient: ...@@ -73,17 +73,13 @@ class TDSimClient:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "rm -rf " + self.cfgDir cmd = "rm -rf " + self.cfgDir
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
...@@ -149,17 +145,11 @@ class TDDnode: ...@@ -149,17 +145,11 @@ class TDDnode:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.dataDir os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
......
...@@ -71,17 +71,13 @@ class TDSimClient: ...@@ -71,17 +71,13 @@ class TDSimClient:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "rm -rf " + self.cfgDir cmd = "rm -rf " + self.cfgDir
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
...@@ -147,17 +143,11 @@ class TDDnode: ...@@ -147,17 +143,11 @@ class TDDnode:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.dataDir os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
......
...@@ -71,17 +71,13 @@ class TDSimClient: ...@@ -71,17 +71,13 @@ class TDSimClient:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "rm -rf " + self.cfgDir cmd = "rm -rf " + self.cfgDir
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
...@@ -147,17 +143,11 @@ class TDDnode: ...@@ -147,17 +143,11 @@ class TDDnode:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.dataDir os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
......
...@@ -200,17 +200,11 @@ class TDDnode: ...@@ -200,17 +200,11 @@ class TDDnode:
if os.system(cmd) != 0: if os.system(cmd) != 0:
tdLog.exit(cmd) tdLog.exit(cmd)
cmd = "mkdir -p " + self.dataDir os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.logDir os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "mkdir -p " + self.cfgDir os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p"
if os.system(cmd) != 0:
tdLog.exit(cmd)
cmd = "touch " + self.cfgPath cmd = "touch " + self.cfgPath
if os.system(cmd) != 0: if os.system(cmd) != 0:
...@@ -332,6 +326,59 @@ class TDDnode: ...@@ -332,6 +326,59 @@ class TDDnode:
# time.sleep(5) # time.sleep(5)
def startWin(self):
buildPath = self.getBuildPath("taosd.exe")
if (buildPath == ""):
tdLog.exit("taosd.exe not found!")
else:
tdLog.info("taosd.exe found in %s" % buildPath)
binPath = buildPath + "/build/bin/taosd.exe"
taosadapterBinPath = buildPath + "/build/bin/taosadapter.exe"
if self.deployed == 0:
tdLog.exit("dnode:%d is not deployed" % (self.index))
cmd = "mintty -h never -w hide %s -c %s" % (
binPath, self.cfgDir)
taosadapterCmd = "mintty -h never -w hide %s " % (
taosadapterBinPath)
if os.system(taosadapterCmd) != 0:
tdLog.exit(taosadapterCmd)
if os.system(cmd) != 0:
tdLog.exit(cmd)
self.running = 1
tdLog.debug("dnode:%d is running with %s " % (self.index, cmd))
if self.valgrind == 0:
time.sleep(0.1)
key = 'from offline to online'
bkey = bytes(key,encoding="utf8")
logFile = self.logDir + "/taosdlog.0"
i = 0
while not os.path.exists(logFile):
sleep(0.1)
i += 1
if i>50:
break
popen = subprocess.Popen('tail -n +0 -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
pid = popen.pid
# print('Popen.pid:' + str(pid))
timeout = time.time() + 60*2
while True:
line = popen.stdout.readline().strip()
if bkey in line:
popen.kill()
break
if time.time() > timeout:
tdLog.exit('wait too long for taosd start')
tdLog.debug("the dnode:%d has been started." % (self.index))
else:
tdLog.debug("wait 10 seconds for the dnode:%d to start." % (self.index))
time.sleep(10)
def startWithoutSleep(self): def startWithoutSleep(self):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
...@@ -548,6 +595,10 @@ class TDDnodes: ...@@ -548,6 +595,10 @@ class TDDnodes:
self.check(index) self.check(index)
self.dnodes[index - 1].start() self.dnodes[index - 1].start()
def startWin(self, index):
self.check(index)
self.dnodes[index - 1].startWin()
def startWithoutSleep(self, index): def startWithoutSleep(self, index):
self.check(index) self.check(index)
self.dnodes[index - 1].startWithoutSleep() self.dnodes[index - 1].startWithoutSleep()
......
...@@ -27,7 +27,7 @@ class TDTestCase: ...@@ -27,7 +27,7 @@ class TDTestCase:
def createOldDir(self): def createOldDir(self):
oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old"
os.system("sudo mkdir -p %s" % oldDir) os.makedirs(oldDir, exist_ok=True) # like "mkdir -p"
def createOldDirAndAddWal(self): def createOldDirAndAddWal(self):
oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册