Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8c7329f9
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
8c7329f9
编写于
7月 30, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test cases
上级
8998435f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
105 addition
and
105 deletion
+105
-105
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
+36
-36
tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py
...stem-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py
+14
-14
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py
...-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py
+14
-14
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py
...test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py
+18
-18
tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py
...s/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py
+9
-9
tests/system-test/6-cluster/clusterCommonCheck.py
tests/system-test/6-cluster/clusterCommonCheck.py
+14
-14
未找到文件。
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
浏览文件 @
8c7329f9
...
...
@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
import
os
from
util.log
import
*
from
util.sql
import
*
...
...
@@ -13,7 +13,7 @@ import time
import
socket
import
subprocess
from
multiprocessing
import
Process
import
threading
import
threading
import
time
import
inspect
import
ctypes
...
...
@@ -37,7 +37,7 @@ class TDTestCase:
self
.
host
=
self
.
master_dnode
.
cfgDict
[
"fqdn"
]
conn1
=
taos
.
connect
(
self
.
master_dnode
.
cfgDict
[
"fqdn"
]
,
config
=
self
.
master_dnode
.
cfgDir
)
tdSql
.
init
(
conn1
.
cursor
())
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
...
@@ -63,7 +63,7 @@ class TDTestCase:
if
res
==
0
:
raise
ValueError
(
"invalid thread id"
)
elif
res
!=
1
:
# """if it returns a number greater than one, you're in trouble,
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes
.
pythonapi
.
PyThreadState_SetAsyncExc
(
tid
,
None
)
raise
SystemError
(
"PyThreadState_SetAsyncExc failed"
)
...
...
@@ -74,7 +74,7 @@ class TDTestCase:
def
createDbTbale
(
self
,
dbcountStart
,
dbcountStop
,
stbname
,
chilCount
):
# fisrt add data : db\stable\childtable\general table
for
couti
in
range
(
dbcountStart
,
dbcountStop
):
tdLog
.
debug
(
"drop database if exists db%d"
%
couti
)
tdSql
.
execute
(
"drop database if exists db%d"
%
couti
)
...
...
@@ -98,7 +98,7 @@ class TDTestCase:
def
insertTabaleData
(
self
,
dbcountStart
,
dbcountStop
,
stbname
,
chilCount
,
ts_start
,
rowCount
):
# insert data : create childtable and data
for
couti
in
range
(
dbcountStart
,
dbcountStop
):
tdSql
.
execute
(
"use db%d"
%
couti
)
pre_insert
=
"insert into "
...
...
@@ -115,7 +115,7 @@ class TDTestCase:
# print(sql)
tdSql
.
execute
(
sql
)
sql
=
"insert into %s_%d values "
%
(
stbname
,
i
)
# end sql
# end sql
if
sql
!=
pre_insert
:
# print(sql)
print
(
len
(
sql
))
...
...
@@ -134,13 +134,13 @@ class TDTestCase:
for
i
in
range
(
stableCount
):
tdSql
.
query
(
"select count(*) from %s%d"
%
(
stbname
,
i
))
tdSql
.
checkData
(
0
,
0
,
rowsPerSTable
)
return
return
def
depoly_cluster
(
self
,
dnodes_nums
):
def
depoly_cluster
(
self
,
dnodes_nums
):
testCluster
=
False
valgrind
=
0
valgrind
=
0
hostname
=
socket
.
gethostname
()
dnodes
=
[]
start_port
=
6030
...
...
@@ -154,7 +154,7 @@ class TDTestCase:
dnode
.
addExtraCfg
(
"monitorPort"
,
7043
)
dnode
.
addExtraCfg
(
"secondEp"
,
f
"
{
hostname
}
:
{
start_port_sec
}
"
)
dnodes
.
append
(
dnode
)
self
.
TDDnodes
=
MyDnodes
(
dnodes
)
self
.
TDDnodes
.
init
(
""
)
self
.
TDDnodes
.
setTestCluster
(
testCluster
)
...
...
@@ -162,11 +162,11 @@ class TDTestCase:
self
.
TDDnodes
.
stopAll
()
for
dnode
in
self
.
TDDnodes
.
dnodes
:
self
.
TDDnodes
.
deploy
(
dnode
.
index
,{})
for
dnode
in
self
.
TDDnodes
.
dnodes
:
self
.
TDDnodes
.
starttaosd
(
dnode
.
index
)
# create cluster
# create cluster
for
dnode
in
self
.
TDDnodes
.
dnodes
[
1
:]:
# print(dnode.cfgDict)
dnode_id
=
dnode
.
cfgDict
[
"fqdn"
]
+
":"
+
dnode
.
cfgDict
[
"serverPort"
]
...
...
@@ -175,7 +175,7 @@ class TDTestCase:
cmd
=
f
" taos -h
{
dnode_first_host
}
-P
{
dnode_first_port
}
-s ' create dnode
\"
{
dnode_id
}
\"
' ;"
print
(
cmd
)
os
.
system
(
cmd
)
time
.
sleep
(
2
)
tdLog
.
info
(
" create cluster with %d dnode done! "
%
dnodes_nums
)
...
...
@@ -185,8 +185,8 @@ class TDTestCase:
time
.
sleep
(
1
)
statusReadyBumber
=
0
tdSql
.
query
(
"show dnodes;"
)
if
tdSql
.
checkRows
(
dnodenumber
)
:
print
(
"dnode is %d nodes"
%
dnodenumber
)
if
tdSql
.
checkRows
(
dnodenumber
)
:
print
(
"dnode is %d nodes"
%
dnodenumber
)
for
i
in
range
(
dnodenumber
):
if
tdSql
.
queryResult
[
i
][
4
]
!=
'ready'
:
status
=
tdSql
.
queryResult
[
i
][
4
]
...
...
@@ -203,15 +203,15 @@ class TDTestCase:
else
:
print
(
"%d mnodes is not ready in 10s "
%
dnodenumber
)
return
False
def
check3mnode
(
self
):
count
=
0
while
count
<
10
:
time
.
sleep
(
1
)
tdSql
.
query
(
"show mnodes;"
)
if
tdSql
.
checkRows
(
3
)
:
print
(
"mnode is three nodes"
)
if
tdSql
.
checkRows
(
3
)
:
print
(
"mnode is three nodes"
)
if
tdSql
.
queryResult
[
0
][
2
]
==
'leader'
:
if
tdSql
.
queryResult
[
1
][
2
]
==
'follower'
:
if
tdSql
.
queryResult
[
2
][
2
]
==
'follower'
:
...
...
@@ -221,19 +221,19 @@ class TDTestCase:
if
tdSql
.
queryResult
[
1
][
2
]
==
'leader'
:
if
tdSql
.
queryResult
[
2
][
2
]
==
'follower'
:
print
(
"three mnodes is ready in 10s"
)
break
break
elif
tdSql
.
queryResult
[
0
][
2
]
==
'follower'
:
if
tdSql
.
queryResult
[
1
][
2
]
==
'follower'
:
if
tdSql
.
queryResult
[
2
][
2
]
==
'leader'
:
print
(
"three mnodes is ready in 10s"
)
break
break
count
+=
1
else
:
print
(
"three mnodes is not ready in 10s "
)
return
-
1
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
tdSql
.
checkData
(
0
,
3
,
'ready'
)
tdSql
.
checkData
(
1
,
1
,
'%s:6130'
%
self
.
host
)
...
...
@@ -263,8 +263,8 @@ class TDTestCase:
return
-
1
tdSql
.
error
(
"drop mnode on dnode 1;"
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
tdSql
.
checkData
(
0
,
2
,
'offline'
)
tdSql
.
checkData
(
0
,
3
,
'ready'
)
...
...
@@ -291,8 +291,8 @@ class TDTestCase:
return
-
1
tdSql
.
error
(
"drop mnode on dnode 2;"
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
tdSql
.
checkData
(
0
,
2
,
'leader'
)
tdSql
.
checkData
(
0
,
3
,
'ready'
)
...
...
@@ -320,8 +320,8 @@ class TDTestCase:
print
(
"stop mnodes on dnode 3 failed in 10s"
)
return
-
1
tdSql
.
error
(
"drop mnode on dnode 3;"
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
tdSql
.
checkData
(
0
,
2
,
'leader'
)
tdSql
.
checkData
(
0
,
3
,
'ready'
)
...
...
@@ -348,8 +348,8 @@ class TDTestCase:
tdSql
.
checkData
(
4
,
1
,
'%s:6430'
%
self
.
host
)
tdSql
.
checkData
(
0
,
4
,
'ready'
)
tdSql
.
checkData
(
4
,
4
,
'ready'
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show mnodes;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
tdSql
.
checkData
(
0
,
2
,
'leader'
)
tdSql
.
checkData
(
0
,
3
,
'ready'
)
...
...
@@ -364,7 +364,7 @@ class TDTestCase:
tdSql
.
error
(
"create mnode on dnode 2"
)
tdSql
.
query
(
"show dnodes;"
)
print
(
tdSql
.
queryResult
)
tdLog
.
debug
(
"stop all of mnode "
)
tdLog
.
debug
(
"stop all of mnode "
)
# drop follower of mnode and insert data
self
.
createDbTbale
(
dbcountStart
,
dbcountStop
,
stbname
,
tablesPerStb
)
...
...
@@ -378,7 +378,7 @@ class TDTestCase:
rowsPerTable
))
threads
.
start
()
dropcount
=
0
dropcount
=
0
while
dropcount
<=
10
:
for
i
in
range
(
1
,
3
):
tdLog
.
debug
(
"drop mnode on dnode %d"
%
(
i
+
1
))
...
...
@@ -415,7 +415,7 @@ class TDTestCase:
return
taos
.
connect
(
host
=
host
,
port
=
int
(
port
),
config
=
config_dir
)
def
run
(
self
):
def
run
(
self
):
# print(self.master_dnode.cfgDict)
self
.
buildcluster
(
5
)
self
.
five_dnode_three_mnode
(
5
)
...
...
@@ -425,4 +425,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py
浏览文件 @
8c7329f9
...
...
@@ -3,7 +3,7 @@ from numpy import row_stack
import
taos
import
sys
import
time
import
os
import
os
from
util.log
import
*
from
util.sql
import
*
...
...
@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from
util.cluster
import
*
sys
.
path
.
append
(
"./6-cluster"
)
from
clusterCommonCreate
import
*
from
clusterCommonCheck
import
clusterComCheck
from
clusterCommonCheck
import
clusterComCheck
import
time
import
socket
import
subprocess
from
multiprocessing
import
Process
import
threading
import
threading
import
time
import
inspect
import
ctypes
...
...
@@ -57,7 +57,7 @@ class TDTestCase:
if
res
==
0
:
raise
ValueError
(
"invalid thread id"
)
elif
res
!=
1
:
# """if it returns a number greater than one, you're in trouble,
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes
.
pythonapi
.
PyThreadState_SetAsyncExc
(
tid
,
None
)
raise
SystemError
(
"PyThreadState_SetAsyncExc failed"
)
...
...
@@ -68,7 +68,7 @@ class TDTestCase:
def
insertData
(
self
,
countstart
,
countstop
):
# fisrt add data : db\stable\childtable\general table
for
couti
in
range
(
countstart
,
countstop
):
tdLog
.
debug
(
"drop database if exists db%d"
%
couti
)
tdSql
.
execute
(
"drop database if exists db%d"
%
couti
)
...
...
@@ -110,7 +110,7 @@ class TDTestCase:
"rowsPerTbl"
:
100
,
"batchNum"
:
5000
}
dnodeNumbers
=
int
(
dnodeNumbers
)
mnodeNums
=
int
(
mnodeNums
)
vnodeNumbers
=
int
(
dnodeNumbers
-
mnodeNums
)
...
...
@@ -118,7 +118,7 @@ class TDTestCase:
rowsPerStb
=
paraDict
[
"ctbNum"
]
*
paraDict
[
"rowsPerTbl"
]
rowsall
=
rowsPerStb
*
paraDict
[
'stbNumbers'
]
dbNumbers
=
1
tdLog
.
info
(
"first check dnode and mnode"
)
tdSql
.
query
(
"show dnodes;"
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
...
...
@@ -133,7 +133,7 @@ class TDTestCase:
tdSql
.
execute
(
"create mnode on dnode 3"
)
clusterComCheck
.
checkMnodeStatus
(
3
)
# add some error operations and
# add some error operations and
tdLog
.
info
(
"Confirm the status of the dnode again"
)
tdSql
.
error
(
"create mnode on dnode 2"
)
tdSql
.
query
(
"show dnodes;"
)
...
...
@@ -142,7 +142,7 @@ class TDTestCase:
# create database and stable
clusterComCreate
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
paraDict
[
"vgroups"
],
paraDict
[
'replica'
])
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdDnodes
=
cluster
.
dnodes
stopcount
=
0
...
...
@@ -174,7 +174,7 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
elif
stopRole
==
"vnode"
:
for
i
in
range
(
vnodeNumbers
):
tdDnodes
[
i
+
mnodeNums
].
stoptaosd
()
...
...
@@ -186,7 +186,7 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
# dnodeNumbers don't include database of schema
if
clusterComCheck
.
checkDnodes
(
dnodeNumbers
):
...
...
@@ -197,7 +197,7 @@ class TDTestCase:
tdLog
.
exit
(
"one or more of dnodes failed to start "
)
# self.check3mnode()
stopcount
+=
1
clusterComCheck
.
checkDnodes
(
dnodeNumbers
)
clusterComCheck
.
checkDbRows
(
dbNumbers
)
...
...
@@ -211,7 +211,7 @@ class TDTestCase:
# tdSql.query("select * from %s"%stableName)
# tdSql.checkRows(rowsPerStb)
def
run
(
self
):
def
run
(
self
):
# print(self.master_dnode.cfgDict)
self
.
fiveDnodeThreeMnode
(
dnodeNumbers
=
5
,
mnodeNums
=
3
,
restartNumbers
=
1
,
stopRole
=
'dnode'
)
...
...
@@ -220,4 +220,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py
浏览文件 @
8c7329f9
...
...
@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
import
os
from
util.log
import
*
from
util.sql
import
*
...
...
@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from
util.cluster
import
*
sys
.
path
.
append
(
"./6-cluster"
)
from
clusterCommonCreate
import
*
from
clusterCommonCheck
import
clusterComCheck
from
clusterCommonCheck
import
clusterComCheck
import
time
import
socket
import
subprocess
from
multiprocessing
import
Process
import
threading
import
threading
import
time
import
inspect
import
ctypes
...
...
@@ -56,7 +56,7 @@ class TDTestCase:
if
res
==
0
:
raise
ValueError
(
"invalid thread id"
)
elif
res
!=
1
:
# """if it returns a number greater than one, you're in trouble,
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes
.
pythonapi
.
PyThreadState_SetAsyncExc
(
tid
,
None
)
raise
SystemError
(
"PyThreadState_SetAsyncExc failed"
)
...
...
@@ -82,13 +82,13 @@ class TDTestCase:
'ctbPrefix'
:
'ctb'
,
'ctbNum'
:
1
,
}
dnodeNumbers
=
int
(
dnodeNumbers
)
mnodeNums
=
int
(
mnodeNums
)
vnodeNumbers
=
int
(
dnodeNumbers
-
mnodeNums
)
allDbNumbers
=
(
paraDict
[
'dbNumbers'
]
*
restartNumbers
)
allStbNumbers
=
(
paraDict
[
'stbNumbers'
]
*
restartNumbers
)
tdLog
.
info
(
"first check dnode and mnode"
)
tdSql
.
query
(
"show dnodes;"
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
...
...
@@ -105,14 +105,14 @@ class TDTestCase:
tdSql
.
execute
(
"create mnode on dnode 3"
)
clusterComCheck
.
checkMnodeStatus
(
3
)
# add some error operations and
# add some error operations and
tdLog
.
info
(
"Confirm the status of the dnode again"
)
tdSql
.
error
(
"create mnode on dnode 2"
)
tdSql
.
query
(
"show dnodes;"
)
print
(
tdSql
.
queryResult
)
clusterComCheck
.
checkDnodes
(
dnodeNumbers
)
tdLog
.
info
(
"create database and stable"
)
tdLog
.
info
(
"create database and stable"
)
tdDnodes
=
cluster
.
dnodes
stopcount
=
0
threads
=
[]
...
...
@@ -124,7 +124,7 @@ class TDTestCase:
for
tr
in
threads
:
tr
.
start
()
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdLog
.
info
(
"Take turns stopping Mnodes "
)
while
stopcount
<
restartNumbers
:
tdLog
.
info
(
" restart loop: %d"
%
stopcount
)
if
stopRole
==
"mnode"
:
...
...
@@ -132,7 +132,7 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
elif
stopRole
==
"vnode"
:
for
i
in
range
(
vnodeNumbers
):
tdDnodes
[
i
+
mnodeNums
].
stoptaosd
()
...
...
@@ -144,7 +144,7 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
# dnodeNumbers don't include database of schema
if
clusterComCheck
.
checkDnodes
(
dnodeNumbers
):
...
...
@@ -155,7 +155,7 @@ class TDTestCase:
tdLog
.
exit
(
"one or more of dnodes failed to start "
)
# self.check3mnode()
stopcount
+=
1
for
tr
in
threads
:
tr
.
join
()
tdLog
.
info
(
"check dnode number:"
)
...
...
@@ -170,7 +170,7 @@ class TDTestCase:
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
def
run
(
self
):
def
run
(
self
):
# print(self.master_dnode.cfgDict)
self
.
fiveDnodeThreeMnode
(
dnodeNumbers
=
5
,
mnodeNums
=
3
,
restartNumbers
=
10
,
stopRole
=
'mnode'
)
...
...
@@ -179,4 +179,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py
浏览文件 @
8c7329f9
...
...
@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
import
os
from
util.log
import
*
from
util.sql
import
*
...
...
@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from
util.cluster
import
*
sys
.
path
.
append
(
"./6-cluster"
)
from
clusterCommonCreate
import
*
from
clusterCommonCheck
import
clusterComCheck
from
clusterCommonCheck
import
clusterComCheck
import
time
import
socket
import
subprocess
from
multiprocessing
import
Process
import
threading
import
threading
import
time
import
inspect
import
ctypes
...
...
@@ -31,7 +31,7 @@ class TDTestCase:
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
print
(
tdSql
)
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
...
@@ -56,7 +56,7 @@ class TDTestCase:
if
res
==
0
:
raise
ValueError
(
"invalid thread id"
)
elif
res
!=
1
:
# """if it returns a number greater than one, you're in trouble,
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes
.
pythonapi
.
PyThreadState_SetAsyncExc
(
tid
,
None
)
raise
SystemError
(
"PyThreadState_SetAsyncExc failed"
)
...
...
@@ -67,7 +67,7 @@ class TDTestCase:
def
insertData
(
self
,
countstart
,
countstop
):
# fisrt add data : db\stable\childtable\general table
for
couti
in
range
(
countstart
,
countstop
):
tdLog
.
debug
(
"drop database if exists db%d"
%
couti
)
tdSql
.
execute
(
"drop database if exists db%d"
%
couti
)
...
...
@@ -106,13 +106,13 @@ class TDTestCase:
'ctbPrefix'
:
'ctb'
,
'ctbNum'
:
1
,
}
dnodeNumbers
=
int
(
dnodeNumbers
)
mnodeNums
=
int
(
mnodeNums
)
vnodeNumbers
=
int
(
dnodeNumbers
-
mnodeNums
)
allStbNumbers
=
(
paraDict
[
'stbNumbers'
]
*
restartNumbers
)
dbNumbers
=
1
print
(
tdSql
)
tdLog
.
info
(
"first check dnode and mnode"
)
tdSql
.
query
(
"show dnodes;"
)
...
...
@@ -128,7 +128,7 @@ class TDTestCase:
tdSql
.
execute
(
"create mnode on dnode 3"
)
clusterComCheck
.
checkMnodeStatus
(
3
)
# add some error operations and
# add some error operations and
tdLog
.
info
(
"Confirm the status of the dnode again"
)
tdSql
.
error
(
"create mnode on dnode 2"
)
tdSql
.
query
(
"show dnodes;"
)
...
...
@@ -137,12 +137,12 @@ class TDTestCase:
# create database and stable
clusterComCreate
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
paraDict
[
"vgroups"
],
paraDict
[
'replica'
])
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdDnodes
=
cluster
.
dnodes
stopcount
=
0
threads
=
[]
for
i
in
range
(
restartNumbers
):
stableName
=
'%s%d'
%
(
paraDict
[
'stbName'
],
i
)
newTdSql
=
tdCom
.
newTdSql
()
...
...
@@ -151,7 +151,7 @@ class TDTestCase:
for
tr
in
threads
:
tr
.
start
()
tdLog
.
info
(
"Take turns stopping Mnodes "
)
tdLog
.
info
(
"Take turns stopping Mnodes "
)
while
stopcount
<
restartNumbers
:
tdLog
.
info
(
" restart loop: %d"
%
stopcount
)
if
stopRole
==
"mnode"
:
...
...
@@ -159,7 +159,7 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
elif
stopRole
==
"vnode"
:
for
i
in
range
(
vnodeNumbers
):
tdDnodes
[
i
+
mnodeNums
].
stoptaosd
()
...
...
@@ -171,19 +171,19 @@ class TDTestCase:
tdDnodes
[
i
].
stoptaosd
()
# sleep(10)
tdDnodes
[
i
].
starttaosd
()
# sleep(10)
# sleep(10)
# dnodeNumbers don't include database of schema
if
clusterComCheck
.
checkDnodes
(
dnodeNumbers
):
tdLog
.
info
(
"123"
)
else
:
print
(
"456"
)
self
.
stopThread
(
threads
)
tdLog
.
exit
(
"one or more of dnodes failed to start "
)
# self.check3mnode()
stopcount
+=
1
for
tr
in
threads
:
tr
.
join
()
clusterComCheck
.
checkDnodes
(
dnodeNumbers
)
...
...
@@ -197,7 +197,7 @@ class TDTestCase:
tdSql
.
checkRows
(
allStbNumbers
)
def
run
(
self
):
def
run
(
self
):
# print(self.master_dnode.cfgDict)
self
.
fiveDnodeThreeMnode
(
dnodeNumbers
=
5
,
mnodeNums
=
3
,
restartNumbers
=
2
,
stopRole
=
'vnode'
)
...
...
@@ -206,4 +206,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py
浏览文件 @
8c7329f9
...
...
@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
import
os
from
util.log
import
*
from
util.sql
import
*
...
...
@@ -15,13 +15,13 @@ from test import tdDnodes
sys
.
path
.
append
(
"./6-cluster"
)
from
clusterCommonCreate
import
*
from
clusterCommonCheck
import
*
from
clusterCommonCheck
import
*
import
time
import
socket
import
subprocess
from
multiprocessing
import
Process
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
...
...
@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers
=
int
(
dnodenumbers
)
mnodeNums
=
int
(
mnodeNums
)
dbNumbers
=
1
tdLog
.
info
(
"first check dnode and mnode"
)
tdSql
.
query
(
"show dnodes;"
)
tdSql
.
checkData
(
0
,
1
,
'%s:6030'
%
self
.
host
)
...
...
@@ -84,7 +84,7 @@ class TDTestCase:
tdSql
.
execute
(
"create mnode on dnode 3"
)
clusterComCheck
.
checkMnodeStatus
(
3
)
# add some error operations and
# add some error operations and
tdLog
.
info
(
"Confirm the status of the dnode again"
)
tdSql
.
error
(
"create mnode on dnode 2"
)
tdSql
.
query
(
"show dnodes;"
)
...
...
@@ -100,20 +100,20 @@ class TDTestCase:
# tdLog.info("check whether 2 mnode status is offline")
# clusterComCheck.check3mnode2off()
# tdSql.error("create user user1 pass '123';")
tdLog
.
info
(
"start one mnode"
)
tdDnodes
[
0
].
starttaosd
()
clusterComCheck
.
check3mnodeoff
(
2
)
clusterComCreate
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
paraDict
[
"vgroups"
],
paraDict
[
'replica'
])
clusterComCheck
.
checkDb
(
dbNumbers
,
1
,
'db0'
)
def
run
(
self
):
def
run
(
self
):
# print(self.master_dnode.cfgDict)
self
.
fiveDnodeThreeMnode
(
dnodenumbers
=
5
,
mnodeNums
=
3
,
restartNumber
=
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
tests/system-test/6-cluster/clusterCommonCheck.py
浏览文件 @
8c7329f9
...
...
@@ -48,10 +48,10 @@ class ClusterComCheck:
if
tdSql
.
queryResult
[
i
][
4
]
==
"ready"
:
status
+=
1
tdLog
.
info
(
status
)
if
status
==
dnodeNumbers
:
tdLog
.
success
(
"it find cluster with %d dnodes and check that all cluster dnodes are ready within 30s! "
%
dnodeNumbers
)
return
True
return
True
count
+=
1
time
.
sleep
(
1
)
else
:
...
...
@@ -77,15 +77,15 @@ class ClusterComCheck:
def
checkDb
(
self
,
dbNumbers
,
restartNumber
,
dbNameIndex
):
count
=
0
alldbNumbers
=
(
dbNumbers
*
restartNumber
)
+
2
while
count
<
5
:
while
count
<
5
:
query_status
=
0
for
j
in
range
(
dbNumbers
):
for
i
in
range
(
alldbNumbers
):
tdSql
.
query
(
"show databases;"
)
if
"%s_%d"
%
(
dbNameIndex
,
j
)
==
tdSql
.
queryResult
[
i
][
0
]
:
if
"%s_%d"
%
(
dbNameIndex
,
j
)
==
tdSql
.
queryResult
[
i
][
0
]
:
if
tdSql
.
queryResult
[
i
][
15
]
==
"ready"
:
query_status
+=
1
tdLog
.
debug
(
"check %s_%d that status is ready "
%
(
dbNameIndex
,
j
))
tdLog
.
debug
(
"check %s_%d that status is ready "
%
(
dbNameIndex
,
j
))
else
:
continue
# print(query_status)
...
...
@@ -107,7 +107,7 @@ class ClusterComCheck:
for
i
in
range
(
stableCount
):
tdSql
.
query
(
"select count(*) from %s%d"
%
(
stbname
,
i
))
tdSql
.
checkData
(
0
,
0
,
rowsPerSTable
)
return
return
def
checkMnodeStatus
(
self
,
mnodeNums
):
self
.
mnodeNums
=
int
(
mnodeNums
)
...
...
@@ -118,15 +118,15 @@ class ClusterComCheck:
while
count
<
10
:
time
.
sleep
(
1
)
tdSql
.
query
(
"show mnodes;"
)
if
tdSql
.
checkRows
(
self
.
mnodeNums
)
:
if
tdSql
.
checkRows
(
self
.
mnodeNums
)
:
tdLog
.
success
(
"cluster has %d mnodes"
%
self
.
mnodeNums
)
if
self
.
mnodeNums
==
1
:
if
tdSql
.
queryResult
[
0
][
2
]
==
'leader'
and
tdSql
.
queryResult
[
0
][
3
]
==
'ready'
:
tdLog
.
success
(
"%d mnodes is ready in 10s"
%
self
.
mnodeNums
)
return
True
count
+=
1
elif
self
.
mnodeNums
==
3
:
return
True
count
+=
1
elif
self
.
mnodeNums
==
3
:
if
tdSql
.
queryResult
[
0
][
2
]
==
'leader'
and
tdSql
.
queryResult
[
0
][
3
]
==
'ready'
:
if
tdSql
.
queryResult
[
1
][
2
]
==
'follower'
and
tdSql
.
queryResult
[
1
][
3
]
==
'ready'
:
if
tdSql
.
queryResult
[
2
][
2
]
==
'follower'
and
tdSql
.
queryResult
[
2
][
3
]
==
'ready'
:
...
...
@@ -141,9 +141,9 @@ class ClusterComCheck:
if
tdSql
.
queryResult
[
0
][
2
]
==
'follower'
and
tdSql
.
queryResult
[
0
][
3
]
==
'ready'
:
if
tdSql
.
queryResult
[
1
][
2
]
==
'follower'
and
tdSql
.
queryResult
[
1
][
3
]
==
'ready'
:
tdLog
.
success
(
"%d mnodes is ready in 10s"
%
self
.
mnodeNums
)
return
True
return
True
count
+=
1
elif
self
.
mnodeNums
==
2
:
elif
self
.
mnodeNums
==
2
:
if
tdSql
.
queryResult
[
0
][
2
]
==
'leader'
and
tdSql
.
queryResult
[
0
][
3
]
==
'ready'
:
if
tdSql
.
queryResult
[
1
][
2
]
==
'follower'
and
tdSql
.
queryResult
[
1
][
3
]
==
'ready'
:
tdLog
.
success
(
"%d mnodes is ready in 10s"
%
self
.
mnodeNums
)
...
...
@@ -157,7 +157,7 @@ class ClusterComCheck:
tdLog
.
debug
(
tdSql
.
queryResult
)
tdLog
.
exit
(
"cluster of %d mnodes is not ready in 10s "
%
self
.
mnodeNums
)
def
check3mnodeoff
(
self
,
offlineDnodeNo
,
mnodeNums
=
3
):
...
...
@@ -224,7 +224,7 @@ class ClusterComCheck:
else
:
tdLog
.
debug
(
tdSql
.
queryResult
)
tdLog
.
exit
(
"stop mnodes on dnode %d failed in 10s "
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录