Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21b9a5a1
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21b9a5a1
编写于
12月 23, 2021
作者:
L
liuyq-617
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(query)fix
上级
380cbbad
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
168 addition
and
212 deletion
+168
-212
tests/develop-test/test.py
tests/develop-test/test.py
+54
-65
tests/pytest/test.py
tests/pytest/test.py
+53
-64
tests/pytest/util/cases.py
tests/pytest/util/cases.py
+7
-10
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+0
-8
tests/system-test/test.py
tests/system-test/test.py
+54
-65
未找到文件。
tests/develop-test/test.py
浏览文件 @
21b9a5a1
...
...
@@ -28,6 +28,7 @@ import taos
if
__name__
==
"__main__"
:
fileName
=
"all"
deployPath
=
""
masterIp
=
""
...
...
@@ -37,83 +38,68 @@ 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"
,
],
)
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'f:p:m:l:scghrw'
,
[
'file='
,
'path='
,
'master'
,
'logSql'
,
'stop'
,
'cluster'
,
'valgrind'
,
'help'
,
'windows'
])
for
key
,
value
in
opts
:
if
key
in
[
"-h"
,
"--help"
]:
tdLog
.
printNoPrefix
(
"A collection of test cases written using Python"
)
tdLog
.
printNoPrefix
(
"-f Name of test case file written by Python"
)
tdLog
.
printNoPrefix
(
"-p Deploy Path for Simulator"
)
tdLog
.
printNoPrefix
(
"-m Master Ip for Simulator"
)
tdLog
.
printNoPrefix
(
"-l <True:False> logSql Flag"
)
tdLog
.
printNoPrefix
(
"-s stop All dnodes"
)
tdLog
.
printNoPrefix
(
"-c Test Cluster Flag"
)
tdLog
.
printNoPrefix
(
"-g valgrind Test Flag"
)
tdLog
.
printNoPrefix
(
"-r taosd restart test"
)
tdLog
.
printNoPrefix
(
"-w taos on windows"
)
if
key
in
[
'-h'
,
'--help'
]:
tdLog
.
printNoPrefix
(
'A collection of test cases written using Python'
)
tdLog
.
printNoPrefix
(
'-f Name of test case file written by Python'
)
tdLog
.
printNoPrefix
(
'-p Deploy Path for Simulator'
)
tdLog
.
printNoPrefix
(
'-m Master Ip for Simulator'
)
tdLog
.
printNoPrefix
(
'-l <True:False> logSql Flag'
)
tdLog
.
printNoPrefix
(
'-s stop All dnodes'
)
tdLog
.
printNoPrefix
(
'-c Test Cluster Flag'
)
tdLog
.
printNoPrefix
(
'-g valgrind Test Flag'
)
tdLog
.
printNoPrefix
(
'-r taosd restart test'
)
tdLog
.
printNoPrefix
(
'-w taos on windows'
)
sys
.
exit
(
0
)
if
key
in
[
"-r"
,
"--restart"
]:
if
key
in
[
'-r'
,
'--restart'
]:
restart
=
True
if
key
in
[
"-f"
,
"--file"
]:
if
key
in
[
'-f'
,
'--file'
]:
fileName
=
value
if
key
in
[
"-p"
,
"--path"
]:
if
key
in
[
'-p'
,
'--path'
]:
deployPath
=
value
if
key
in
[
"-m"
,
"--master"
]:
if
key
in
[
'-m'
,
'--master'
]:
masterIp
=
value
if
key
in
[
"-l"
,
"--logSql"
]:
if
value
.
upper
()
==
"TRUE"
:
if
key
in
[
'-l'
,
'--logSql'
]:
if
(
value
.
upper
()
==
"TRUE"
)
:
logSql
=
True
elif
value
.
upper
()
==
"FALSE"
:
elif
(
value
.
upper
()
==
"FALSE"
)
:
logSql
=
False
else
:
tdLog
.
printNoPrefix
(
"logSql value %s is invalid"
%
logSql
)
sys
.
exit
(
0
)
if
key
in
[
"-c"
,
"--cluster"
]:
if
key
in
[
'-c'
,
'--cluster'
]:
testCluster
=
True
if
key
in
[
"-g"
,
"--valgrind"
]:
if
key
in
[
'-g'
,
'--valgrind'
]:
valgrind
=
1
if
key
in
[
"-s"
,
"--stop"
]:
if
key
in
[
'-s'
,
'--stop'
]:
stop
=
1
if
key
in
[
"-w"
,
"--windows"
]:
if
key
in
[
'-w'
,
'--windows'
]:
windows
=
1
if
stop
!=
0
:
if
valgrind
==
0
:
if
(
stop
!=
0
)
:
if
(
valgrind
==
0
)
:
toBeKilled
=
"taosd"
else
:
toBeKilled
=
"valgrind.bin"
killCmd
=
(
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
)
killCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
psCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}'"
%
toBeKilled
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
while
processID
:
while
(
processID
)
:
os
.
system
(
killCmd
)
time
.
sleep
(
1
)
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
...
...
@@ -130,26 +116,25 @@ if __name__ == "__main__":
if
valgrind
:
time
.
sleep
(
2
)
tdLog
.
info
(
"stop All dnodes"
)
tdLog
.
info
(
'stop All dnodes'
)
if
masterIp
==
""
:
host
=
"127.0.0.1"
host
=
'127.0.0.1'
else
:
host
=
masterIp
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
uModule
=
tdDnodes
.
import_module
(
fileName
)
if
windows
:
tdCases
.
logSql
(
logSql
)
tdLog
.
info
(
"Procedures for testing self-deployment"
)
td_clinet
=
TDSimClient
(
"C:
\\
TDengine"
)
td_clinet
.
deploy
()
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
'/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'
):
remote_conn
.
run
(
"python3 ./test.py"
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
tdCases
.
runOneWindows
(
conn
,
fileName
)
else
:
tdDnodes
.
init
(
deployPath
)
...
...
@@ -157,24 +142,27 @@ if __name__ == "__main__":
tdDnodes
.
setValgrind
(
valgrind
)
tdDnodes
.
stopAll
()
is_test_framework
=
0
key_word
=
"tdCases.addLinux"
key_word
=
'tdCases.addLinux'
try
:
if
key_word
in
open
(
fileName
).
read
():
is_test_framework
=
1
except
:
pass
if
is_test_framework
:
moduleName
=
fileName
.
replace
(
".py"
,
""
).
replace
(
"/"
,
"."
)
uModule
=
importlib
.
import_module
(
moduleName
)
try
:
ucase
=
uModule
.
TDTestCase
()
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
del
uModule
except
:
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
except
:
tdDnodes
.
deploy
(
1
,{})
else
:
pass
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,{})
tdDnodes
.
start
(
1
)
tdCases
.
logSql
(
logSql
)
if
testCluster
:
...
...
@@ -185,25 +173,26 @@ if __name__ == "__main__":
tdCases
.
runOneCluster
(
fileName
)
else
:
tdLog
.
info
(
"Procedures for testing self-deployment"
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
if
fileName
==
"all"
:
tdCases
.
runAllLinux
(
conn
)
else
:
tdCases
.
runOne
Linux
(
conn
,
fileName
,
uModul
e
)
tdCases
.
runOne
Windows
(
conn
,
fileNam
e
)
if
restart
:
if
fileName
==
"all"
:
tdLog
.
info
(
"not need to query "
)
else
:
else
:
sp
=
fileName
.
rsplit
(
"."
,
1
)
if
len
(
sp
)
==
2
and
sp
[
1
]
==
"py"
:
tdDnodes
.
stopAll
()
tdDnodes
.
start
(
1
)
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
tdLog
.
info
(
"query test after taosd restart"
)
tdCases
.
runOneLinux
(
conn
,
sp
[
0
]
+
"_"
+
"restart.py"
)
else
:
tdLog
.
info
(
"not need to query"
)
conn
.
close
()
tests/pytest/test.py
浏览文件 @
21b9a5a1
...
...
@@ -37,83 +37,68 @@ 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"
,
],
)
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'f:p:m:l:scghrw'
,
[
'file='
,
'path='
,
'master'
,
'logSql'
,
'stop'
,
'cluster'
,
'valgrind'
,
'help'
,
'windows'
])
for
key
,
value
in
opts
:
if
key
in
[
"-h"
,
"--help"
]:
tdLog
.
printNoPrefix
(
"A collection of test cases written using Python"
)
tdLog
.
printNoPrefix
(
"-f Name of test case file written by Python"
)
tdLog
.
printNoPrefix
(
"-p Deploy Path for Simulator"
)
tdLog
.
printNoPrefix
(
"-m Master Ip for Simulator"
)
tdLog
.
printNoPrefix
(
"-l <True:False> logSql Flag"
)
tdLog
.
printNoPrefix
(
"-s stop All dnodes"
)
tdLog
.
printNoPrefix
(
"-c Test Cluster Flag"
)
tdLog
.
printNoPrefix
(
"-g valgrind Test Flag"
)
tdLog
.
printNoPrefix
(
"-r taosd restart test"
)
tdLog
.
printNoPrefix
(
"-w taos on windows"
)
if
key
in
[
'-h'
,
'--help'
]:
tdLog
.
printNoPrefix
(
'A collection of test cases written using Python'
)
tdLog
.
printNoPrefix
(
'-f Name of test case file written by Python'
)
tdLog
.
printNoPrefix
(
'-p Deploy Path for Simulator'
)
tdLog
.
printNoPrefix
(
'-m Master Ip for Simulator'
)
tdLog
.
printNoPrefix
(
'-l <True:False> logSql Flag'
)
tdLog
.
printNoPrefix
(
'-s stop All dnodes'
)
tdLog
.
printNoPrefix
(
'-c Test Cluster Flag'
)
tdLog
.
printNoPrefix
(
'-g valgrind Test Flag'
)
tdLog
.
printNoPrefix
(
'-r taosd restart test'
)
tdLog
.
printNoPrefix
(
'-w taos on windows'
)
sys
.
exit
(
0
)
if
key
in
[
"-r"
,
"--restart"
]:
if
key
in
[
'-r'
,
'--restart'
]:
restart
=
True
if
key
in
[
"-f"
,
"--file"
]:
if
key
in
[
'-f'
,
'--file'
]:
fileName
=
value
if
key
in
[
"-p"
,
"--path"
]:
if
key
in
[
'-p'
,
'--path'
]:
deployPath
=
value
if
key
in
[
"-m"
,
"--master"
]:
if
key
in
[
'-m'
,
'--master'
]:
masterIp
=
value
if
key
in
[
"-l"
,
"--logSql"
]:
if
value
.
upper
()
==
"TRUE"
:
if
key
in
[
'-l'
,
'--logSql'
]:
if
(
value
.
upper
()
==
"TRUE"
)
:
logSql
=
True
elif
value
.
upper
()
==
"FALSE"
:
elif
(
value
.
upper
()
==
"FALSE"
)
:
logSql
=
False
else
:
tdLog
.
printNoPrefix
(
"logSql value %s is invalid"
%
logSql
)
sys
.
exit
(
0
)
if
key
in
[
"-c"
,
"--cluster"
]:
if
key
in
[
'-c'
,
'--cluster'
]:
testCluster
=
True
if
key
in
[
"-g"
,
"--valgrind"
]:
if
key
in
[
'-g'
,
'--valgrind'
]:
valgrind
=
1
if
key
in
[
"-s"
,
"--stop"
]:
if
key
in
[
'-s'
,
'--stop'
]:
stop
=
1
if
key
in
[
"-w"
,
"--windows"
]:
if
key
in
[
'-w'
,
'--windows'
]:
windows
=
1
if
stop
!=
0
:
if
valgrind
==
0
:
if
(
stop
!=
0
)
:
if
(
valgrind
==
0
)
:
toBeKilled
=
"taosd"
else
:
toBeKilled
=
"valgrind.bin"
killCmd
=
(
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
)
killCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
psCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}'"
%
toBeKilled
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
while
processID
:
while
(
processID
)
:
os
.
system
(
killCmd
)
time
.
sleep
(
1
)
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
...
...
@@ -130,26 +115,25 @@ if __name__ == "__main__":
if
valgrind
:
time
.
sleep
(
2
)
tdLog
.
info
(
"stop All dnodes"
)
tdLog
.
info
(
'stop All dnodes'
)
if
masterIp
==
""
:
host
=
"127.0.0.1"
host
=
'127.0.0.1'
else
:
host
=
masterIp
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
uModule
=
tdDnodes
.
import_module
(
fileName
)
if
windows
:
tdCases
.
logSql
(
logSql
)
tdLog
.
info
(
"Procedures for testing self-deployment"
)
td_clinet
=
TDSimClient
(
"C:
\\
TDengine"
)
td_clinet
.
deploy
()
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
'/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'
):
remote_conn
.
run
(
"python3 ./test.py"
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
tdCases
.
runOneWindows
(
conn
,
fileName
)
else
:
tdDnodes
.
init
(
deployPath
)
...
...
@@ -157,24 +141,27 @@ if __name__ == "__main__":
tdDnodes
.
setValgrind
(
valgrind
)
tdDnodes
.
stopAll
()
is_test_framework
=
0
key_word
=
"tdCases.addLinux"
key_word
=
'tdCases.addLinux'
try
:
if
key_word
in
open
(
fileName
).
read
():
is_test_framework
=
1
except
:
pass
if
is_test_framework
:
moduleName
=
fileName
.
replace
(
".py"
,
""
).
replace
(
"/"
,
"."
)
uModule
=
importlib
.
import_module
(
moduleName
)
try
:
ucase
=
uModule
.
TDTestCase
()
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
del
uModule
except
:
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
except
:
tdDnodes
.
deploy
(
1
,{})
else
:
pass
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,{})
tdDnodes
.
start
(
1
)
tdCases
.
logSql
(
logSql
)
if
testCluster
:
...
...
@@ -185,21 +172,23 @@ if __name__ == "__main__":
tdCases
.
runOneCluster
(
fileName
)
else
:
tdLog
.
info
(
"Procedures for testing self-deployment"
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
if
fileName
==
"all"
:
tdCases
.
runAllLinux
(
conn
)
else
:
tdCases
.
runOne
Linux
(
conn
,
fileName
,
uModul
e
)
tdCases
.
runOne
Windows
(
conn
,
fileNam
e
)
if
restart
:
if
fileName
==
"all"
:
tdLog
.
info
(
"not need to query "
)
else
:
else
:
sp
=
fileName
.
rsplit
(
"."
,
1
)
if
len
(
sp
)
==
2
and
sp
[
1
]
==
"py"
:
tdDnodes
.
stopAll
()
tdDnodes
.
start
(
1
)
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
tdLog
.
info
(
"query test after taosd restart"
)
tdCases
.
runOneLinux
(
conn
,
sp
[
0
]
+
"_"
+
"restart.py"
)
...
...
tests/pytest/util/cases.py
浏览文件 @
21b9a5a1
...
...
@@ -17,7 +17,6 @@ import time
import
datetime
import
inspect
import
importlib
from
util.dnodes
import
*
from
util.log
import
*
...
...
@@ -35,9 +34,8 @@ class TDCases:
self
.
clusterCases
=
[]
def
__dynamicLoadModule
(
self
,
fileName
):
# moduleName = fileName.replace(".py", "").replace(os.sep, ".")
# return importlib.import_module(moduleName, package='..')
return
tdDnodes
.
import_module
(
fileName
)
moduleName
=
fileName
.
replace
(
".py"
,
""
).
replace
(
os
.
sep
,
"."
)
return
importlib
.
import_module
(
moduleName
,
package
=
'..'
)
def
logSql
(
self
,
logSql
):
self
.
_logSql
=
logSql
...
...
@@ -65,11 +63,10 @@ class TDCases:
tdLog
.
info
(
"total %d Linux test case(s) executed"
%
(
runNum
))
def
runOneLinux
(
self
,
conn
,
fileName
,
testModule
):
# testModule = self.__dynamicLoadModule(fileName)
def
runOneLinux
(
self
,
conn
,
fileName
):
testModule
=
self
.
__dynamicLoadModule
(
fileName
)
runNum
=
0
if
fileName
.
startswith
(
".."
):
fileName
=
fileName
[
3
:]
for
tmp
in
self
.
linuxCases
:
if
tmp
.
name
.
find
(
fileName
)
!=
-
1
:
case
=
testModule
.
TDTestCase
()
...
...
@@ -98,7 +95,7 @@ class TDCases:
tdLog
.
notice
(
"total %d Windows test case(s) executed"
%
(
runNum
))
def
runOneWindows
(
self
,
conn
,
fileName
):
#
testModule = self.__dynamicLoadModule(fileName)
testModule
=
self
.
__dynamicLoadModule
(
fileName
)
runNum
=
0
for
tmp
in
self
.
windowsCases
:
...
...
@@ -133,7 +130,7 @@ class TDCases:
tdLog
.
notice
(
"total %d Cluster test case(s) executed"
%
(
runNum
))
def
runOneCluster
(
self
,
fileName
):
#
testModule = self.__dynamicLoadModule(fileName)
testModule
=
self
.
__dynamicLoadModule
(
fileName
)
runNum
=
0
for
tmp
in
self
.
clusterCases
:
...
...
tests/pytest/util/dnodes.py
浏览文件 @
21b9a5a1
...
...
@@ -18,7 +18,6 @@ import platform
import
pathlib
import
shutil
import
subprocess
import
importlib
from
time
import
sleep
from
util.log
import
*
...
...
@@ -580,13 +579,6 @@ class TDDnodes:
def
check
(
self
,
index
):
if
index
<
1
or
index
>
10
:
tdLog
.
exit
(
"index:%d should on a scale of [1, 10]"
%
(
index
))
def
import_module
(
self
,
fileName
):
module_dir
,
module_file
=
os
.
path
.
split
(
fileName
)
module_name
,
module_ext
=
os
.
path
.
splitext
(
module_file
)
spec
=
importlib
.
util
.
spec_from_file_location
(
module_name
,
fileName
)
uModule
=
spec
.
loader
.
load_module
()
return
uModule
def
stopAll
(
self
):
tdLog
.
info
(
"stop all dnodes"
)
...
...
tests/system-test/test.py
浏览文件 @
21b9a5a1
...
...
@@ -28,6 +28,7 @@ import taos
if
__name__
==
"__main__"
:
fileName
=
"all"
deployPath
=
""
masterIp
=
""
...
...
@@ -37,83 +38,68 @@ 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"
,
],
)
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'f:p:m:l:scghrw'
,
[
'file='
,
'path='
,
'master'
,
'logSql'
,
'stop'
,
'cluster'
,
'valgrind'
,
'help'
,
'windows'
])
for
key
,
value
in
opts
:
if
key
in
[
"-h"
,
"--help"
]:
tdLog
.
printNoPrefix
(
"A collection of test cases written using Python"
)
tdLog
.
printNoPrefix
(
"-f Name of test case file written by Python"
)
tdLog
.
printNoPrefix
(
"-p Deploy Path for Simulator"
)
tdLog
.
printNoPrefix
(
"-m Master Ip for Simulator"
)
tdLog
.
printNoPrefix
(
"-l <True:False> logSql Flag"
)
tdLog
.
printNoPrefix
(
"-s stop All dnodes"
)
tdLog
.
printNoPrefix
(
"-c Test Cluster Flag"
)
tdLog
.
printNoPrefix
(
"-g valgrind Test Flag"
)
tdLog
.
printNoPrefix
(
"-r taosd restart test"
)
tdLog
.
printNoPrefix
(
"-w taos on windows"
)
if
key
in
[
'-h'
,
'--help'
]:
tdLog
.
printNoPrefix
(
'A collection of test cases written using Python'
)
tdLog
.
printNoPrefix
(
'-f Name of test case file written by Python'
)
tdLog
.
printNoPrefix
(
'-p Deploy Path for Simulator'
)
tdLog
.
printNoPrefix
(
'-m Master Ip for Simulator'
)
tdLog
.
printNoPrefix
(
'-l <True:False> logSql Flag'
)
tdLog
.
printNoPrefix
(
'-s stop All dnodes'
)
tdLog
.
printNoPrefix
(
'-c Test Cluster Flag'
)
tdLog
.
printNoPrefix
(
'-g valgrind Test Flag'
)
tdLog
.
printNoPrefix
(
'-r taosd restart test'
)
tdLog
.
printNoPrefix
(
'-w taos on windows'
)
sys
.
exit
(
0
)
if
key
in
[
"-r"
,
"--restart"
]:
if
key
in
[
'-r'
,
'--restart'
]:
restart
=
True
if
key
in
[
"-f"
,
"--file"
]:
if
key
in
[
'-f'
,
'--file'
]:
fileName
=
value
if
key
in
[
"-p"
,
"--path"
]:
if
key
in
[
'-p'
,
'--path'
]:
deployPath
=
value
if
key
in
[
"-m"
,
"--master"
]:
if
key
in
[
'-m'
,
'--master'
]:
masterIp
=
value
if
key
in
[
"-l"
,
"--logSql"
]:
if
value
.
upper
()
==
"TRUE"
:
if
key
in
[
'-l'
,
'--logSql'
]:
if
(
value
.
upper
()
==
"TRUE"
)
:
logSql
=
True
elif
value
.
upper
()
==
"FALSE"
:
elif
(
value
.
upper
()
==
"FALSE"
)
:
logSql
=
False
else
:
tdLog
.
printNoPrefix
(
"logSql value %s is invalid"
%
logSql
)
sys
.
exit
(
0
)
if
key
in
[
"-c"
,
"--cluster"
]:
if
key
in
[
'-c'
,
'--cluster'
]:
testCluster
=
True
if
key
in
[
"-g"
,
"--valgrind"
]:
if
key
in
[
'-g'
,
'--valgrind'
]:
valgrind
=
1
if
key
in
[
"-s"
,
"--stop"
]:
if
key
in
[
'-s'
,
'--stop'
]:
stop
=
1
if
key
in
[
"-w"
,
"--windows"
]:
if
key
in
[
'-w'
,
'--windows'
]:
windows
=
1
if
stop
!=
0
:
if
valgrind
==
0
:
if
(
stop
!=
0
)
:
if
(
valgrind
==
0
)
:
toBeKilled
=
"taosd"
else
:
toBeKilled
=
"valgrind.bin"
killCmd
=
(
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
)
killCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
%
toBeKilled
psCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print $2}'"
%
toBeKilled
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
while
processID
:
while
(
processID
)
:
os
.
system
(
killCmd
)
time
.
sleep
(
1
)
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
)
...
...
@@ -130,26 +116,25 @@ if __name__ == "__main__":
if
valgrind
:
time
.
sleep
(
2
)
tdLog
.
info
(
"stop All dnodes"
)
tdLog
.
info
(
'stop All dnodes'
)
if
masterIp
==
""
:
host
=
"127.0.0.1"
host
=
'127.0.0.1'
else
:
host
=
masterIp
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
uModule
=
tdDnodes
.
import_module
(
fileName
)
if
windows
:
tdCases
.
logSql
(
logSql
)
tdLog
.
info
(
"Procedures for testing self-deployment"
)
td_clinet
=
TDSimClient
(
"C:
\\
TDengine"
)
td_clinet
.
deploy
()
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
"/var/lib/jenkins/workspace/TDinternal/community/tests/pytest"
):
remote_conn
=
Connection
(
"root@%s"
%
host
)
with
remote_conn
.
cd
(
'/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'
):
remote_conn
.
run
(
"python3 ./test.py"
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
td_clinet
.
cfgDir
)
tdCases
.
runOneWindows
(
conn
,
fileName
)
else
:
tdDnodes
.
init
(
deployPath
)
...
...
@@ -157,24 +142,27 @@ if __name__ == "__main__":
tdDnodes
.
setValgrind
(
valgrind
)
tdDnodes
.
stopAll
()
is_test_framework
=
0
key_word
=
"tdCases.addLinux"
key_word
=
'tdCases.addLinux'
try
:
if
key_word
in
open
(
fileName
).
read
():
is_test_framework
=
1
except
:
pass
if
is_test_framework
:
moduleName
=
fileName
.
replace
(
".py"
,
""
).
replace
(
"/"
,
"."
)
uModule
=
importlib
.
import_module
(
moduleName
)
try
:
ucase
=
uModule
.
TDTestCase
()
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
del
uModule
except
:
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,
ucase
.
updatecfgDict
)
except
:
tdDnodes
.
deploy
(
1
,{})
else
:
pass
tdDnodes
.
deploy
(
1
,
{})
tdDnodes
.
deploy
(
1
,{})
tdDnodes
.
start
(
1
)
tdCases
.
logSql
(
logSql
)
if
testCluster
:
...
...
@@ -185,25 +173,26 @@ if __name__ == "__main__":
tdCases
.
runOneCluster
(
fileName
)
else
:
tdLog
.
info
(
"Procedures for testing self-deployment"
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
if
fileName
==
"all"
:
tdCases
.
runAllLinux
(
conn
)
else
:
tdCases
.
runOne
Linux
(
conn
,
fileName
,
uModul
e
)
tdCases
.
runOne
Windows
(
conn
,
fileNam
e
)
if
restart
:
if
fileName
==
"all"
:
tdLog
.
info
(
"not need to query "
)
else
:
else
:
sp
=
fileName
.
rsplit
(
"."
,
1
)
if
len
(
sp
)
==
2
and
sp
[
1
]
==
"py"
:
tdDnodes
.
stopAll
()
tdDnodes
.
start
(
1
)
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
time
.
sleep
(
1
)
conn
=
taos
.
connect
(
host
,
config
=
tdDnodes
.
getSimCfgPath
())
tdLog
.
info
(
"Procedures for tdengine deployed in %s"
%
(
host
))
tdLog
.
info
(
"query test after taosd restart"
)
tdCases
.
runOneLinux
(
conn
,
sp
[
0
]
+
"_"
+
"restart.py"
)
else
:
tdLog
.
info
(
"not need to query"
)
conn
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录