Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06f72448
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
06f72448
编写于
5月 28, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(os): case run remote taosd
上级
9175e4ce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
130 deletion
+121
-130
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+101
-117
tests/system-test/test.py
tests/system-test/test.py
+20
-13
未找到文件。
tests/pytest/util/dnodes.py
浏览文件 @
06f72448
...
...
@@ -17,6 +17,10 @@ import os.path
import
platform
import
subprocess
from
time
import
sleep
import
base64
import
json
import
copy
from
fabric2
import
Connection
from
util.log
import
*
...
...
@@ -111,6 +115,7 @@ class TDDnode:
self
.
deployed
=
0
self
.
testCluster
=
False
self
.
valgrind
=
0
self
.
remoteIP
=
""
self
.
cfgDict
=
{
"walLevel"
:
"2"
,
"fsync"
:
"1000"
,
...
...
@@ -137,8 +142,9 @@ class TDDnode:
"telemetryReporting"
:
"0"
}
def
init
(
self
,
path
):
def
init
(
self
,
path
,
remoteIP
=
""
):
self
.
path
=
path
self
.
remoteIP
=
remoteIP
def
setTestCluster
(
self
,
value
):
self
.
testCluster
=
value
...
...
@@ -162,6 +168,24 @@ class TDDnode:
def
addExtraCfg
(
self
,
option
,
value
):
self
.
cfgDict
.
update
({
option
:
value
})
def
remoteExec
(
self
,
updateCfgDict
,
execCmd
):
remote_conn
=
Connection
(
self
.
remoteIP
,
port
=
22
,
user
=
'root'
,
connect_kwargs
=
{
'password'
:
'123456'
})
remote_top_dir
=
'~/test'
valgrindStr
=
''
if
(
self
.
valgrind
==
1
):
valgrindStr
=
'-g'
remoteCfgDict
=
copy
.
deepcopy
(
updateCfgDict
)
if
(
"logDir"
in
remoteCfgDict
):
del
remoteCfgDict
[
"logDir"
]
if
(
"dataDir"
in
remoteCfgDict
):
del
remoteCfgDict
[
"dataDir"
]
if
(
"cfgDir"
in
remoteCfgDict
):
del
remoteCfgDict
[
"cfgDir"
]
remoteCfgDictStr
=
base64
.
b64encode
(
json
.
dumps
(
remoteCfgDict
).
encode
()).
decode
()
execCmdStr
=
base64
.
b64encode
(
execCmd
.
encode
()).
decode
()
with
remote_conn
.
cd
((
remote_top_dir
+
sys
.
path
[
0
].
replace
(
self
.
path
,
''
)).
replace
(
'
\\
'
,
'/'
)):
remote_conn
.
run
(
"python3 ./test.py %s -d %s -e %s"
%
(
valgrindStr
,
remoteCfgDictStr
,
execCmdStr
))
def
deploy
(
self
,
*
updatecfgDict
):
self
.
logDir
=
"%s/sim/dnode%d/log"
%
(
self
.
path
,
self
.
index
)
self
.
dataDir
=
"%s/sim/dnode%d/data"
%
(
self
.
path
,
self
.
index
)
...
...
@@ -229,8 +253,11 @@ class TDDnode:
self
.
cfg
(
value
,
key
)
else
:
self
.
addExtraCfg
(
key
,
value
)
for
key
,
value
in
self
.
cfgDict
.
items
():
self
.
cfg
(
key
,
value
)
if
(
self
.
remoteIP
==
""
):
for
key
,
value
in
self
.
cfgDict
.
items
():
self
.
cfg
(
key
,
value
)
else
:
self
.
remoteExec
(
self
.
cfgDict
,
"tdDnodes.deploy(%d,updateCfgDict)"
%
self
.
index
)
self
.
deployed
=
1
tdLog
.
debug
(
...
...
@@ -268,117 +295,65 @@ class TDDnode:
tdLog
.
exit
(
"dnode:%d is not deployed"
%
(
self
.
index
))
if
self
.
valgrind
==
0
:
cmd
=
"nohup %s -c %s > /dev/null 2>&1 & "
%
(
binPath
,
self
.
cfgDir
)
if
platform
.
system
().
lower
()
==
'windows'
:
cmd
=
"mintty -h never -w hide %s -c %s"
%
(
binPath
,
self
.
cfgDir
)
else
:
cmd
=
"nohup %s -c %s > /dev/null 2>&1 & "
%
(
binPath
,
self
.
cfgDir
)
else
:
valgrindCmdline
=
"valgrind --log-file=
\"
%s/../log/valgrind.log
\"
--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"
%
self
.
cfgDir
cmd
=
"nohup %s %s -c %s 2>&1 & "
%
(
valgrindCmdline
,
binPath
,
self
.
cfgDir
)
if
platform
.
system
().
lower
()
==
'windows'
:
cmd
=
"mintty -h never -w hide %s %s -c %s"
%
(
valgrindCmdline
,
binPath
,
self
.
cfgDir
)
else
:
cmd
=
"nohup %s %s -c %s 2>&1 & "
%
(
valgrindCmdline
,
binPath
,
self
.
cfgDir
)
print
(
cmd
)
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 -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
)
# time.sleep(5)
def
startWin
(
self
):
binPath
=
self
.
getPath
(
"taosd.exe"
)
if
(
binPath
==
""
):
tdLog
.
exit
(
"taosd.exe not found!"
)
if
(
not
self
.
remoteIP
==
""
):
self
.
remoteExec
(
self
.
cfgDict
,
"tdDnodes.deploy(%d,updateCfgDict)
\n
tdDnodes.start(%d)"
%
(
self
.
index
,
self
.
index
))
self
.
running
=
1
else
:
tdLog
.
info
(
"taosd.exe found: %s"
%
binPath
)
taosadapterBinPath
=
self
.
getPath
(
"taosadapter.exe"
)
if
(
taosadapterBinPath
==
""
):
tdLog
.
info
(
"taosAdapter.exe not found!"
)
else
:
tdLog
.
info
(
"taosAdapter.exe found in %s"
%
taosadapterBuildPath
)
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
)
if
(
taosadapterBinPath
!=
""
):
taosadapterCmd
=
"mintty -h never -w hide %s --monitor.writeToTD=false "
%
(
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
)
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
running
=
1
print
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
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
):
binPath
=
self
.
getPath
()
...
...
@@ -402,12 +377,19 @@ class TDDnode:
print
(
cmd
)
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
if
(
self
.
remoteIP
==
""
):
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
else
:
self
.
remoteExec
(
self
.
cfgDict
,
"tdDnodes.deploy(%d,updateCfgDict)
\n
tdDnodes.startWithoutSleep(%d)"
%
(
self
.
index
,
self
.
index
))
self
.
running
=
1
tdLog
.
debug
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
def
stop
(
self
):
if
(
not
self
.
remoteIP
==
""
):
self
.
remoteExec
(
self
.
cfgDict
,
"tdDnodes.stop(%d)"
%
self
.
index
)
return
if
self
.
valgrind
==
0
:
toBeKilled
=
"taosd"
else
:
...
...
@@ -435,6 +417,9 @@ class TDDnode:
tdLog
.
debug
(
"dnode:%d is stopped by kill -INT"
%
(
self
.
index
))
def
forcestop
(
self
):
if
(
not
self
.
remoteIP
==
""
):
self
.
remoteExec
(
self
.
cfgDict
,
"tdDnodes.forcestop(%d)"
%
self
.
index
)
return
if
self
.
valgrind
==
0
:
toBeKilled
=
"taosd"
else
:
...
...
@@ -499,8 +484,10 @@ class TDDnodes:
self
.
dnodes
.
append
(
TDDnode
(
9
))
self
.
dnodes
.
append
(
TDDnode
(
10
))
self
.
simDeployed
=
False
self
.
testCluster
=
False
self
.
valgrind
=
0
def
init
(
self
,
path
):
def
init
(
self
,
path
,
remoteIP
=
""
):
psCmd
=
"ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'"
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
).
decode
(
"utf-8"
)
while
(
processID
):
...
...
@@ -520,9 +507,9 @@ class TDDnodes:
psCmd
,
shell
=
True
).
decode
(
"utf-8"
)
binPath
=
self
.
dnodes
[
0
].
getPath
()
+
"/../../../"
tdLog
.
debug
(
"binPath %s"
%
(
binPath
))
#
tdLog.debug("binPath %s" % (binPath))
binPath
=
os
.
path
.
realpath
(
binPath
)
tdLog
.
debug
(
"binPath real path %s"
%
(
binPath
))
#
tdLog.debug("binPath real path %s" % (binPath))
# cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath)
# tdLog.debug(cmd)
...
...
@@ -545,7 +532,7 @@ class TDDnodes:
self
.
path
=
os
.
path
.
realpath
(
path
)
for
i
in
range
(
len
(
self
.
dnodes
)):
self
.
dnodes
[
i
].
init
(
self
.
path
)
self
.
dnodes
[
i
].
init
(
self
.
path
,
remoteIP
)
self
.
sim
=
TDSimClient
(
self
.
path
)
def
setTestCluster
(
self
,
value
):
...
...
@@ -572,10 +559,7 @@ class TDDnodes:
def
start
(
self
,
index
):
self
.
check
(
index
)
if
platform
.
system
().
lower
()
==
'windows'
:
self
.
dnodes
[
index
-
1
].
startWin
()
else
:
self
.
dnodes
[
index
-
1
].
start
()
self
.
dnodes
[
index
-
1
].
start
()
def
startWithoutSleep
(
self
,
index
):
self
.
check
(
index
)
...
...
tests/system-test/test.py
浏览文件 @
06f72448
...
...
@@ -44,8 +44,9 @@ if __name__ == "__main__":
if
platform
.
system
().
lower
()
==
'windows'
:
windows
=
1
updateCfgDict
=
{}
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'f:p:m:l:scghrd:'
,
[
'file='
,
'path='
,
'master'
,
'logSql'
,
'stop'
,
'cluster'
,
'valgrind'
,
'help'
,
'restart'
,
'updateCfgDict'
])
execCmd
=
""
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'f:p:m:l:scghrd:e:'
,
[
'file='
,
'path='
,
'master'
,
'logSql'
,
'stop'
,
'cluster'
,
'valgrind'
,
'help'
,
'restart'
,
'updateCfgDict'
,
'execCmd'
])
for
key
,
value
in
opts
:
if
key
in
[
'-h'
,
'--help'
]:
tdLog
.
printNoPrefix
(
...
...
@@ -59,6 +60,7 @@ if __name__ == "__main__":
tdLog
.
printNoPrefix
(
'-g valgrind Test Flag'
)
tdLog
.
printNoPrefix
(
'-r taosd restart test'
)
tdLog
.
printNoPrefix
(
'-d update cfg dict, base64 json str'
)
tdLog
.
printNoPrefix
(
'-e eval str to run'
)
sys
.
exit
(
0
)
if
key
in
[
'-r'
,
'--restart'
]:
...
...
@@ -97,6 +99,19 @@ if __name__ == "__main__":
except
:
print
(
'updateCfgDict convert fail.'
)
sys
.
exit
(
0
)
if
key
in
[
'-e'
,
'--execCmd'
]:
try
:
execCmd
=
base64
.
b64decode
(
value
.
encode
()).
decode
()
except
:
print
(
'updateCfgDict convert fail.'
)
sys
.
exit
(
0
)
if
not
execCmd
==
""
:
tdDnodes
.
init
(
deployPath
)
exec
(
execCmd
)
quit
()
if
(
stop
!=
0
):
if
(
valgrind
==
0
):
toBeKilled
=
"taosd"
...
...
@@ -136,7 +151,7 @@ if __name__ == "__main__":
if
windows
:
tdCases
.
logSql
(
logSql
)
tdLog
.
info
(
"Procedures for testing self-deployment"
)
tdDnodes
.
init
(
deployPath
)
tdDnodes
.
init
(
deployPath
,
masterIp
)
tdDnodes
.
setTestCluster
(
testCluster
)
tdDnodes
.
setValgrind
(
valgrind
)
tdDnodes
.
stopAll
()
...
...
@@ -161,15 +176,7 @@ if __name__ == "__main__":
else
:
pass
tdDnodes
.
deploy
(
1
,
updateCfgDict
)
if
masterIp
==
""
or
masterIp
==
"localhost"
:
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 && (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)
tdDnodes
.
start
(
1
)
conn
=
taos
.
connect
(
host
=
"%s"
%
(
host
),
config
=
tdDnodes
.
sim
.
getCfgDir
())
...
...
@@ -178,7 +185,7 @@ if __name__ == "__main__":
else
:
tdCases
.
runAllWindows
(
conn
)
else
:
tdDnodes
.
init
(
deployPath
)
tdDnodes
.
init
(
deployPath
,
masterIp
)
tdDnodes
.
setTestCluster
(
testCluster
)
tdDnodes
.
setValgrind
(
valgrind
)
tdDnodes
.
stopAll
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录