diff --git a/Jenkinsfile b/Jenkinsfile index 80b3b63dbecf6f7df8dc12330dc8e0235503149f..6a54bbc746ba9482017f815c674141ef9f96305a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,5 @@ import hudson.model.Result +import hudson.model.*; import jenkins.model.CauseOfInterruption properties([pipelineTriggers([githubPush()])]) node { @@ -6,6 +7,7 @@ node { } def skipbuild=0 +def win_stop=0 def abortPreviousBuilds() { def currentJobName = env.JOB_NAME @@ -110,7 +112,83 @@ def pre_test(){ ''' return 1 } +def pre_test_win(){ + bat ''' + cd C:\\ + rd /s /Q C:\\TDengine + cd C:\\workspace\\TDinternal + rd /s /Q C:\\workspace\\TDinternal\\debug + cd C:\\workspace\\TDinternal\\community + git reset --hard HEAD~10 + ''' + script { + if (env.CHANGE_TARGET == 'master') { + bat ''' + cd C:\\workspace\\TDinternal\\community + git checkout master + ''' + } + else if(env.CHANGE_TARGET == '2.0'){ + bat ''' + cd C:\\workspace\\TDinternal\\community + git checkout 2.0 + ''' + } + else{ + bat ''' + cd C:\\workspace\\TDinternal\\community + git checkout develop + ''' + } + } + bat''' + cd C:\\workspace\\TDinternal\\community + git pull + git fetch origin +refs/pull/%CHANGE_ID%/merge + git checkout -qf FETCH_HEAD + git clean -dfx + cd C:\\workspace\\TDinternal + git reset --hard HEAD~10 + ''' + script { + if (env.CHANGE_TARGET == 'master') { + bat ''' + cd C:\\workspace\\TDinternal + git checkout master + ''' + } + else if(env.CHANGE_TARGET == '2.0'){ + bat ''' + cd C:\\workspace\\TDinternal + git checkout 2.0 + ''' + } + else{ + bat ''' + cd C:\\workspace\\TDinternal + git checkout develop + ''' + } + } + bat ''' + cd C:\\workspace\\TDinternal + git pull + date + git clean -dfx + mkdir debug + cd debug + call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" amd64 + cmake ../ -G "NMake Makefiles" + nmake + nmake install + xcopy /e/y/i/f C:\\workspace\\TDinternal\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 + cd C:\\workspace\\TDinternal\\community\\src\\connector\\python + python -m pip install . + + ''' + return 1 +} pipeline { agent none environment{ @@ -234,6 +312,7 @@ pipeline { cd ${WKC}/tests/examples/nodejs npm install td2.0-connector > /dev/null 2>&1 node nodejsChecker.js host=localhost + node test1970.js ''' sh ''' cd ${WKC}/tests/examples/C#/taosdemo @@ -369,7 +448,37 @@ pipeline { date''' } } - } + } + + stage('build'){ + agent{label " wintest "} + steps { + pre_test() + script{ + while(win_stop == 0){ + sleep(1) + } + } + } + } + stage('test'){ + agent{label "win"} + steps{ + + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + pre_test_win() + bat''' + cd C:\\workspace\\TDinternal\\community\\tests\\pytest + .\\test-all.bat Wintest + ''' + } + script{ + win_stop=1 + } + } + } + + } } } @@ -451,4 +560,4 @@ pipeline { ) } } -} \ No newline at end of file +} diff --git a/tests/pytest/fulltest.bat b/tests/pytest/fulltest.bat index 505bd97a01aa9b38d1b5e3ff166e81461f3a7541..fd74f2ad029c982a3a3dd98ae0c8df264bab9c66 100644 --- a/tests/pytest/fulltest.bat +++ b/tests/pytest/fulltest.bat @@ -1,22 +1,22 @@ -python .\test.py -f insert\basic.py -w 1 -m u05 -python .\test.py -f insert\int.py -w 1 -m u05 -python .\test.py -f insert\float.py -w 1 -m u05 -python .\test.py -f insert\bigint.py -w 1 -m u05 -python .\test.py -f insert\bool.py -w 1 -m u05 -python .\test.py -f insert\double.py -w 1 -m u05 -python .\test.py -f insert\smallint.py -w 1 -m u05 -python .\test.py -f insert\tinyint.py -w 1 -m u05 -python .\test.py -f insert\date.py -w 1 -m u05 -python .\test.py -f insert\binary.py -w 1 -m u05 -python .\test.py -f insert\nchar.py -w 1 -m u05 +python .\test.py -f insert\basic.py +python .\test.py -f insert\int.py +python .\test.py -f insert\float.py +python .\test.py -f insert\bigint.py +python .\test.py -f insert\bool.py +python .\test.py -f insert\double.py +python .\test.py -f insert\smallint.py +python .\test.py -f insert\tinyint.py +python .\test.py -f insert\date.py +python .\test.py -f insert\binary.py +python .\test.py -f insert\nchar.py -python .\test.py -f query\filter.py -w 1 -m u05 -python .\test.py -f query\filterCombo.py -w 1 -m u05 -python .\test.py -f query\queryNormal.py -w 1 -m u05 -python .\test.py -f query\queryError.py -w 1 -m u05 -python .\test.py -f query\filterAllIntTypes.py -w 1 -m u05 -python .\test.py -f query\filterFloatAndDouble.py -w 1 -m u05 -python .\test.py -f query\filterOtherTypes.py -w 1 -m u05 -python .\test.py -f query\querySort.py -w 1 -m u05 -python .\test.py -f query\queryJoin.py -w 1 -m u05 \ No newline at end of file +python .\test.py -f query\filter.py +python .\test.py -f query\filterCombo.py +python .\test.py -f query\queryNormal.py +python .\test.py -f query\queryError.py +python .\test.py -f query\filterAllIntTypes.py +python .\test.py -f query\filterFloatAndDouble.py +python .\test.py -f query\filterOtherTypes.py +python .\test.py -f query\querySort.py +python .\test.py -f query\queryJoin.py \ No newline at end of file diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py index 0cbb7876c6194041a160f8fee7271f0c76d3b90c..e91a20e65cd04dd64a88af88259e8e25eebf595c 100644 --- a/tests/pytest/insert/binary.py +++ b/tests/pytest/insert/binary.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import platform import sys from util.log import * from util.cases import * @@ -53,9 +54,10 @@ class TDTestCase: tdLog.info("tdSql.checkData(0, 0, '34567')") tdSql.checkData(0, 0, '34567') tdLog.info("insert into tb values (now+4a, \"'';\")") - config_dir = subprocess.check_output(str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), stderr=subprocess.STDOUT, shell=True).decode('utf-8').replace('\n', '') - result = ''.join(os.popen(r"""taos -s "insert into db.tb values (now+4a, \"'';\")" -c %s"""%(config_dir)).readlines()) - if "Query OK" not in result: tdLog.exit("err:insert '';") + if platform.system() == "Linux": + config_dir = subprocess.check_output(str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), stderr=subprocess.STDOUT, shell=True).decode('utf-8').replace('\n', '') + result = ''.join(os.popen(r"""taos -s "insert into db.tb values (now+4a, \"'';\")" -c %s"""%(config_dir)).readlines()) + if "Query OK" not in result: tdLog.exit("err:insert '';") tdLog.info('drop database db') tdSql.execute('drop database db') tdLog.info('show databases') diff --git a/tests/pytest/insert/nchar.py b/tests/pytest/insert/nchar.py index 5ad52b96a1555b3ccd622fd4bf88c7a0b26051b5..023da5b014864a2d010e6ec6acc16a33ccb20424 100644 --- a/tests/pytest/insert/nchar.py +++ b/tests/pytest/insert/nchar.py @@ -15,6 +15,7 @@ import sys from util.log import * from util.cases import * from util.sql import * +import platform class TDTestCase: @@ -37,7 +38,7 @@ class TDTestCase: tdSql.error("insert into tb values (now, 'taosdata001')") - tdSql.error("insert into tb(now, 😀)") + if platform.system() == "Linux" : tdSql.error("insert into tb(now, 😀)") tdSql.query("select * from tb") tdSql.checkRows(2) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 52e49a57c6883f6fe57df887756bbf2d27199806..a1789c8909f542ba3dcae83042ab50cde9e58e32 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -17,6 +17,7 @@ from util.log import * from util.cases import * from util.sql import * from util.dnodes import * +import platform class TDTestCase: def init(self, conn, logSql): @@ -137,8 +138,9 @@ class TDTestCase: tdSql.checkData(1, 1, 421) tdSql.checkData(1, 2, "tm1") - tdDnodes.stop(1) - tdDnodes.start(1) + if platform.system() == "Linux": + tdDnodes.stop(1) + tdDnodes.start(1) tdSql.query("select last(*) from m1 group by tbname") tdSql.checkData(0, 0, "2020-03-01 01:01:01") diff --git a/tests/pytest/test-all.bat b/tests/pytest/test-all.bat index 4193ad8d0cdca7d89f7c23168c90cc514da34814..f0eb4183846edd19709e83de76153987f5ff9929 100644 --- a/tests/pytest/test-all.bat +++ b/tests/pytest/test-all.bat @@ -1,9 +1,16 @@ @echo off -echo locale en_US.UTF-8>"C:\\TDengine\\cfg\\taos.cfg" -echo charset UTF-8>>"C:\\TDengine\\cfg\\taos.cfg" -for /F "usebackq tokens=*" %%i in ( f.bat) do ( +SETLOCAL EnableDelayedExpansion +for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a") +for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( echo Processing %%i - call %%i ARG1 > result.txt 2>error.txt - if errorlevel 1 (echo failed) else (echo sucess) + call %%i ARG1 -w 1 -m %1 > result.txt 2>error.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. ) else ( call :colorEcho 0a "Success" &echo. ) ) -@echo on \ No newline at end of file + +exit + +:colorEcho +echo off + "%~2" +findstr /v /a:%1 /R "^$" "%~2" nul +del "%~2" > nul 2>&1i \ No newline at end of file diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 251f04fb7b67fce08c28407b80e9cca8ed1938e0..a96ac21496431b811f26fa82091c92f6ae8ecb9a 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -129,7 +129,7 @@ if __name__ == "__main__": td_clinet = TDSimClient("C:\\TDengine") td_clinet.deploy() remote_conn = Connection("root@%s"%host) - with remote_conn.cd('/root/TDinternal/community/tests/pytest'): + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): remote_conn.run("python3 ./test.py") conn = taos.connect( host="%s"%(host), diff --git a/tests/pytest/update/merge_commit_data2_update0.py b/tests/pytest/update/merge_commit_data2_update0.py index def50e04661b1752668202359eec7dd89df9b6f0..7e3c65a0a2f2e3c0b01977b0b28cb0ec8a2530ea 100644 --- a/tests/pytest/update/merge_commit_data2_update0.py +++ b/tests/pytest/update/merge_commit_data2_update0.py @@ -27,7 +27,7 @@ class TDTestCase: def restart_taosd(self,db): tdDnodes.stop(1) - tdDnodes.startWithoutSleep(1) + tdDnodes.start(1) tdSql.execute("use %s;" % db) def date_to_timestamp_microseconds(self, date): diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index cd720ab62d4d71661a214ef24df8df81164fd71b..2837dce3f89c64ca987760783ca4d3f9b9a09b2d 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -14,6 +14,9 @@ import sys import os import os.path +import platform +import pathlib +import shutil import subprocess from time import sleep from util.log import * @@ -64,32 +67,45 @@ class TDSimClient: cmd = "echo '%s %s' >> %s" % (option, value, self.cfgPath) if os.system(cmd) != 0: tdLog.exit(cmd) - + def os_string(self,path): + os_path = path.replace("/",os.sep) + return os_path def deploy(self): - self.logDir = "%s/sim/psim/log" % (self.path) - self.cfgDir = "%s/sim/psim/cfg" % (self.path) - self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) - - cmd = "rm -rf " + self.logDir - if os.system(cmd) != 0: - tdLog.exit(cmd) - - cmd = "mkdir -p " + self.logDir - if os.system(cmd) != 0: - tdLog.exit(cmd) - - cmd = "rm -rf " + self.cfgDir - if os.system(cmd) != 0: - tdLog.exit(cmd) - - cmd = "mkdir -p " + self.cfgDir - if os.system(cmd) != 0: - tdLog.exit(cmd) - - cmd = "touch " + self.cfgPath - if os.system(cmd) != 0: - tdLog.exit(cmd) - + self.logDir = self.os_string("%s/sim/psim/log" % (self.path)) + self.cfgDir = self.os_string("%s/sim/psim/cfg" % (self.path)) + self.cfgPath = self.os_string("%s/sim/psim/cfg/taos.cfg" % (self.path)) + + # cmd = "rm -rf " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + if os.path.exists(self.logDir): + try: + shutil.rmtree(self.logDir) + except: + tdLog.exit("del %s failed"%self.logDir) + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) + # cmd = "rm -rf " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + if os.path.exists(self.cfgDir): + try: + shutil.rmtree(self.cfgDir) + except: + tdLog.exit("del %s failed"%self.cfgDir) + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) + # cmd = "touch " + self.cfgPath + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + try: + pathlib.Path(self.cfgPath).touch() + except: + tdLog.exit("create %s failed"%self.cfgPath) if self.testCluster: self.cfg("masterIp", "192.168.0.1") self.cfg("secondIp", "192.168.0.2")