Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c57a04a6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
c57a04a6
编写于
7月 23, 2022
作者:
H
Hui Li
提交者:
GitHub
7月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15325 from taosdata/test/cluster_vnode_case
test : cluster test case about vnode
上级
3543e988
950cf5dc
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
3720 addition
and
2 deletion
+3720
-2
tests/pytest/util/common.py
tests/pytest/util/common.py
+2
-2
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
...t/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
+138
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
...-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
+179
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
...-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
+179
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py
...de1mnode_basic_replica3_insertdatas_stop_follower_sync.py
+496
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
...1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
+497
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py
...c_replica3_insertdatas_stop_follower_unsync_force_stop.py
+521
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py
...de/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py
+558
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
...ode_basic_replica3_insertdatas_stop_leader_forece_stop.py
+580
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
...st/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
+206
-0
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
...ster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
+364
-0
未找到文件。
tests/pytest/util/common.py
浏览文件 @
c57a04a6
...
...
@@ -457,14 +457,14 @@ class TDCom:
def
newcon
(
self
,
host
=
'localhost'
,
port
=
6030
,
user
=
'root'
,
password
=
'taosdata'
):
con
=
taos
.
connect
(
host
=
host
,
user
=
user
,
password
=
password
,
port
=
port
)
print
(
con
)
#
print(con)
return
con
def
newcur
(
self
,
host
=
'localhost'
,
port
=
6030
,
user
=
'root'
,
password
=
'taosdata'
):
cfgPath
=
self
.
getClientCfgPath
()
con
=
taos
.
connect
(
host
=
host
,
user
=
user
,
password
=
password
,
config
=
cfgPath
,
port
=
port
)
cur
=
con
.
cursor
()
print
(
cur
)
#
print(cur)
return
cur
def
newTdSql
(
self
,
host
=
'localhost'
,
port
=
6030
,
user
=
'root'
,
password
=
'taosdata'
):
...
...
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
0 → 100644
浏览文件 @
c57a04a6
# author : wenzhouwww
from
ssl
import
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
TDDnodes
from
util.dnodes
import
TDDnode
from
util.cluster
import
*
import
time
import
socket
import
subprocess
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
))
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
self
.
mnode_list
=
{}
self
.
dnode_list
=
{}
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
check_setup_cluster_status
(
self
):
tdSql
.
query
(
"show mnodes"
)
for
mnode
in
tdSql
.
queryResult
:
name
=
mnode
[
1
]
info
=
mnode
self
.
mnode_list
[
name
]
=
info
tdSql
.
query
(
"show dnodes"
)
for
dnode
in
tdSql
.
queryResult
:
name
=
dnode
[
1
]
info
=
dnode
self
.
dnode_list
[
name
]
=
info
count
=
0
is_leader
=
False
mnode_name
=
''
for
k
,
v
in
self
.
mnode_list
.
items
():
count
+=
1
# only for 1 mnode
mnode_name
=
k
if
v
[
2
]
==
'leader'
:
is_leader
=
True
if
count
==
1
and
is_leader
:
tdLog
.
info
(
"===== depoly cluster success with 1 mnode as leader ====="
)
else
:
tdLog
.
exit
(
"===== depoly cluster fail with 1 mnode as leader ====="
)
for
k
,
v
in
self
.
dnode_list
.
items
():
if
k
==
mnode_name
:
if
v
[
3
]
==
0
:
tdLog
.
info
(
"===== depoly cluster mnode only success at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
tdLog
.
exit
(
"===== depoly cluster mnode only fail at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
continue
def
create_db_check_vgroups
(
self
):
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test replica 1 duration 300"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"show test.vgroups;"
)
vgroups_infos
=
{}
# key is id: value is info list
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
tmp_list
=
[]
for
role
in
vgroup_info
[
3
:
-
4
]:
if
role
in
[
'leader'
,
'follower'
]:
tmp_list
.
append
(
role
)
vgroups_infos
[
vgroup_id
]
=
tmp_list
for
k
,
v
in
vgroups_infos
.
items
():
if
len
(
v
)
==
1
and
v
[
0
]
==
"leader"
:
tdLog
.
info
(
" === create database replica only 1 role leader check success of vgroup_id {} ======"
.
format
(
k
))
else
:
tdLog
.
exit
(
" === create database replica only 1 role leader check fail of vgroup_id {} ======"
.
format
(
k
))
def
getConnection
(
self
,
dnode
):
host
=
dnode
.
cfgDict
[
"fqdn"
]
port
=
dnode
.
cfgDict
[
"serverPort"
]
config_dir
=
dnode
.
cfgDir
return
taos
.
connect
(
host
=
host
,
port
=
int
(
port
),
config
=
config_dir
)
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
create_db_check_vgroups
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
0 → 100644
浏览文件 @
c57a04a6
# author : wenzhouwww
from
ssl
import
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
TDDnodes
from
util.dnodes
import
TDDnode
from
util.cluster
import
*
import
time
import
socket
import
subprocess
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
))
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
self
.
mnode_list
=
{}
self
.
dnode_list
=
{}
self
.
ts
=
1483200000000
self
.
db_name
=
'testdb'
self
.
replica
=
1
self
.
vgroups
=
2
self
.
tb_nums
=
10
self
.
row_nums
=
100
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
check_setup_cluster_status
(
self
):
tdSql
.
query
(
"show mnodes"
)
for
mnode
in
tdSql
.
queryResult
:
name
=
mnode
[
1
]
info
=
mnode
self
.
mnode_list
[
name
]
=
info
tdSql
.
query
(
"show dnodes"
)
for
dnode
in
tdSql
.
queryResult
:
name
=
dnode
[
1
]
info
=
dnode
self
.
dnode_list
[
name
]
=
info
count
=
0
is_leader
=
False
mnode_name
=
''
for
k
,
v
in
self
.
mnode_list
.
items
():
count
+=
1
# only for 1 mnode
mnode_name
=
k
if
v
[
2
]
==
'leader'
:
is_leader
=
True
if
count
==
1
and
is_leader
:
tdLog
.
info
(
"===== depoly cluster success with 1 mnode as leader ====="
)
else
:
tdLog
.
exit
(
"===== depoly cluster fail with 1 mnode as leader ====="
)
for
k
,
v
in
self
.
dnode_list
.
items
():
if
k
==
mnode_name
:
if
v
[
3
]
==
0
:
tdLog
.
info
(
"===== depoly cluster mnode only success at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
tdLog
.
exit
(
"===== depoly cluster mnode only fail at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
continue
def
create_db_check_vgroups
(
self
):
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test replica 1 duration 300"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"show test.vgroups;"
)
vgroups_infos
=
{}
# key is id: value is info list
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
tmp_list
=
[]
for
role
in
vgroup_info
[
3
:
-
4
]:
if
role
in
[
'leader'
,
'follower'
]:
tmp_list
.
append
(
role
)
vgroups_infos
[
vgroup_id
]
=
tmp_list
for
k
,
v
in
vgroups_infos
.
items
():
if
len
(
v
)
==
1
and
v
[
0
]
==
"leader"
:
tdLog
.
info
(
" === create database replica only 1 role leader check success of vgroup_id {} ======"
.
format
(
k
))
else
:
tdLog
.
exit
(
" === create database replica only 1 role leader check fail of vgroup_id {} ======"
.
format
(
k
))
def
create_db_replica_1_insertdatas
(
self
,
dbname
,
replica_num
,
vgroup_nums
,
tb_nums
,
row_nums
):
drop_db_sql
=
"drop database if exists {}"
.
format
(
dbname
)
create_db_sql
=
"create database {} replica {} vgroups {}"
.
format
(
dbname
,
replica_num
,
vgroup_nums
)
tdLog
.
info
(
" ==== create database {} and insert rows begin ====="
.
format
(
dbname
))
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
tb_nums
):
sub_tbname
=
"sub_tb_{}"
.
format
(
i
)
tdSql
.
execute
(
"create table {} using stb1 tags({})"
.
format
(
sub_tbname
,
i
))
# insert datas about new database
for
row_num
in
range
(
row_nums
):
ts
=
self
.
ts
+
1000
*
row_num
tdSql
.
execute
(
f
"insert into
{
sub_tbname
}
values (
{
ts
}
,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
tdLog
.
info
(
" ==== create database {} and insert rows execute end ====="
.
format
(
dbname
))
def
check_insert_status
(
self
,
dbname
,
tb_nums
,
row_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
checkData
(
0
,
0
,
tb_nums
*
row_nums
)
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
checkRows
(
tb_nums
)
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
create_db_check_vgroups
()
self
.
create_db_replica_1_insertdatas
(
self
.
db_name
,
self
.
replica
,
self
.
vgroups
,
self
.
tb_nums
,
self
.
row_nums
)
self
.
check_insert_status
(
self
.
db_name
,
self
.
tb_nums
,
self
.
row_nums
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
0 → 100644
浏览文件 @
c57a04a6
# author : wenzhouwww
from
ssl
import
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
TDDnodes
from
util.dnodes
import
TDDnode
from
util.cluster
import
*
import
time
import
socket
import
subprocess
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
))
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
self
.
mnode_list
=
{}
self
.
dnode_list
=
{}
self
.
ts
=
1483200000000
self
.
db_name
=
'testdb'
self
.
replica
=
3
self
.
vgroups
=
2
self
.
tb_nums
=
10
self
.
row_nums
=
100
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
check_setup_cluster_status
(
self
):
tdSql
.
query
(
"show mnodes"
)
for
mnode
in
tdSql
.
queryResult
:
name
=
mnode
[
1
]
info
=
mnode
self
.
mnode_list
[
name
]
=
info
tdSql
.
query
(
"show dnodes"
)
for
dnode
in
tdSql
.
queryResult
:
name
=
dnode
[
1
]
info
=
dnode
self
.
dnode_list
[
name
]
=
info
count
=
0
is_leader
=
False
mnode_name
=
''
for
k
,
v
in
self
.
mnode_list
.
items
():
count
+=
1
# only for 1 mnode
mnode_name
=
k
if
v
[
2
]
==
'leader'
:
is_leader
=
True
if
count
==
1
and
is_leader
:
tdLog
.
info
(
"===== depoly cluster success with 1 mnode as leader ====="
)
else
:
tdLog
.
exit
(
"===== depoly cluster fail with 1 mnode as leader ====="
)
for
k
,
v
in
self
.
dnode_list
.
items
():
if
k
==
mnode_name
:
if
v
[
3
]
==
0
:
tdLog
.
info
(
"===== depoly cluster mnode only success at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
tdLog
.
exit
(
"===== depoly cluster mnode only fail at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
continue
def
create_db_check_vgroups
(
self
):
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test replica 1 duration 300"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"show test.vgroups;"
)
vgroups_infos
=
{}
# key is id: value is info list
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
tmp_list
=
[]
for
role
in
vgroup_info
[
3
:
-
4
]:
if
role
in
[
'leader'
,
'follower'
]:
tmp_list
.
append
(
role
)
vgroups_infos
[
vgroup_id
]
=
tmp_list
for
k
,
v
in
vgroups_infos
.
items
():
if
len
(
v
)
==
1
and
v
[
0
]
==
"leader"
:
tdLog
.
info
(
" === create database replica only 1 role leader check success of vgroup_id {} ======"
.
format
(
k
))
else
:
tdLog
.
exit
(
" === create database replica only 1 role leader check fail of vgroup_id {} ======"
.
format
(
k
))
def
create_db_replica_3_insertdatas
(
self
,
dbname
,
replica_num
,
vgroup_nums
,
tb_nums
,
row_nums
):
drop_db_sql
=
"drop database if exists {}"
.
format
(
dbname
)
create_db_sql
=
"create database {} replica {} vgroups {}"
.
format
(
dbname
,
replica_num
,
vgroup_nums
)
tdLog
.
info
(
" ==== create database {} and insert rows begin ====="
.
format
(
dbname
))
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
tb_nums
):
sub_tbname
=
"sub_tb_{}"
.
format
(
i
)
tdSql
.
execute
(
"create table {} using stb1 tags({})"
.
format
(
sub_tbname
,
i
))
# insert datas about new database
for
row_num
in
range
(
row_nums
):
ts
=
self
.
ts
+
1000
*
row_num
tdSql
.
execute
(
f
"insert into
{
sub_tbname
}
values (
{
ts
}
,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
tdLog
.
info
(
" ==== create database {} and insert rows execute end ====="
.
format
(
dbname
))
def
check_insert_status
(
self
,
dbname
,
tb_nums
,
row_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
checkData
(
0
,
0
,
tb_nums
*
row_nums
)
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
checkRows
(
tb_nums
)
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
create_db_check_vgroups
()
self
.
create_db_replica_3_insertdatas
(
self
.
db_name
,
self
.
replica
,
self
.
vgroups
,
self
.
tb_nums
,
self
.
row_nums
)
self
.
check_insert_status
(
self
.
db_name
,
self
.
tb_nums
,
self
.
row_nums
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py
0 → 100644
浏览文件 @
c57a04a6
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
0 → 100644
浏览文件 @
c57a04a6
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py
0 → 100644
浏览文件 @
c57a04a6
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py
0 → 100644
浏览文件 @
c57a04a6
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
0 → 100644
浏览文件 @
c57a04a6
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
0 → 100644
浏览文件 @
c57a04a6
# author : wenzhouwww
from
ssl
import
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
TDDnodes
from
util.dnodes
import
TDDnode
from
util.cluster
import
*
import
time
import
socket
import
subprocess
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
self
.
mnode_list
=
{}
self
.
dnode_list
=
{}
self
.
ts
=
1483200000000
self
.
db_name
=
'testdb'
self
.
replica
=
1
self
.
vgroups
=
2
self
.
tb_nums
=
10
self
.
row_nums
=
100
self
.
max_vote_time_cost
=
10
# seconds
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
check_setup_cluster_status
(
self
):
tdSql
.
query
(
"show mnodes"
)
for
mnode
in
tdSql
.
queryResult
:
name
=
mnode
[
1
]
info
=
mnode
self
.
mnode_list
[
name
]
=
info
tdSql
.
query
(
"show dnodes"
)
for
dnode
in
tdSql
.
queryResult
:
name
=
dnode
[
1
]
info
=
dnode
self
.
dnode_list
[
name
]
=
info
count
=
0
is_leader
=
False
mnode_name
=
''
for
k
,
v
in
self
.
mnode_list
.
items
():
count
+=
1
# only for 1 mnode
mnode_name
=
k
if
v
[
2
]
==
'leader'
:
is_leader
=
True
if
count
==
1
and
is_leader
:
tdLog
.
info
(
"===== depoly cluster success with 1 mnode as leader ====="
)
else
:
tdLog
.
exit
(
"===== depoly cluster fail with 1 mnode as leader ====="
)
for
k
,
v
in
self
.
dnode_list
.
items
():
if
k
==
mnode_name
:
if
v
[
3
]
==
0
:
tdLog
.
info
(
"===== depoly cluster mnode only success at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
tdLog
.
exit
(
"===== depoly cluster mnode only fail at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
continue
def
create_db_check_vgroups
(
self
):
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test replica 1 duration 300"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"show test.vgroups;"
)
vgroups_infos
=
{}
# key is id: value is info list
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
tmp_list
=
[]
for
role
in
vgroup_info
[
3
:
-
4
]:
if
role
in
[
'leader'
,
'follower'
]:
tmp_list
.
append
(
role
)
vgroups_infos
[
vgroup_id
]
=
tmp_list
for
k
,
v
in
vgroups_infos
.
items
():
if
len
(
v
)
==
1
and
v
[
0
]
==
"leader"
:
tdLog
.
info
(
" === create database replica only 1 role leader check success of vgroup_id {} ======"
.
format
(
k
))
else
:
tdLog
.
exit
(
" === create database replica only 1 role leader check fail of vgroup_id {} ======"
.
format
(
k
))
def
check_vgroups_init_done
(
self
,
dbname
):
status
=
True
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
vgroup_status
=
[]
for
ind
,
role
in
enumerate
(
vgroup_info
[
3
:
-
4
]):
if
ind
%
2
==
0
:
continue
else
:
vgroup_status
.
append
(
role
)
if
vgroup_status
.
count
(
"leader"
)
!=
1
or
vgroup_status
.
count
(
"follower"
)
!=
2
:
status
=
False
return
status
return
status
def
vote_leader_time_costs
(
self
,
dbname
):
start
=
time
.
time
()
status
=
self
.
check_vgroups_init_done
(
dbname
)
while
not
status
:
time
.
sleep
(
0.1
)
status
=
self
.
check_vgroups_init_done
(
dbname
)
# tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
end
=
time
.
time
()
cost_time
=
end
-
start
tdLog
.
info
(
" ==== database %s vote the leaders success , cost time is %.3f second ====="
%
(
dbname
,
cost_time
)
)
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
if
cost_time
>=
self
.
max_vote_time_cost
:
tdLog
.
exit
(
" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="
%
(
dbname
,
cost_time
)
)
return
cost_time
def
test_init_vgroups_time_costs
(
self
):
tdLog
.
info
(
" ====start check time cost about vgroups vote leaders ==== "
)
tdLog
.
info
(
" ==== current max time cost is set value : {} ======="
.
format
(
self
.
max_vote_time_cost
))
# create database replica 3 vgroups 1
db1
=
'db_1'
create_db_replica_3_vgroups_1
=
"create database {} replica 3 vgroups 1"
.
format
(
db1
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 1 ======'
.
format
(
db1
))
tdSql
.
execute
(
create_db_replica_3_vgroups_1
)
self
.
vote_leader_time_costs
(
db1
)
# create database replica 3 vgroups 10
db2
=
'db_2'
create_db_replica_3_vgroups_10
=
"create database {} replica 3 vgroups 10"
.
format
(
db2
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 10 ======'
.
format
(
db2
))
tdSql
.
execute
(
create_db_replica_3_vgroups_10
)
self
.
vote_leader_time_costs
(
db2
)
# create database replica 3 vgroups 100
db3
=
'db_3'
create_db_replica_3_vgroups_100
=
"create database {} replica 3 vgroups 100"
.
format
(
db3
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 100 ======'
.
format
(
db3
))
tdSql
.
execute
(
create_db_replica_3_vgroups_100
)
self
.
vote_leader_time_costs
(
db3
)
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
test_init_vgroups_time_costs
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
0 → 100644
浏览文件 @
c57a04a6
# author : wenzhouwww
from
errno
import
ESOCKTNOSUPPORT
from
ssl
import
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
TDDnodes
from
util.dnodes
import
TDDnode
from
util.cluster
import
*
import
time
import
random
import
socket
import
subprocess
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
host
=
socket
.
gethostname
()
self
.
mnode_list
=
{}
self
.
dnode_list
=
{}
self
.
ts
=
1483200000000
self
.
db_name
=
'testdb'
self
.
replica
=
1
self
.
vgroups
=
2
self
.
tb_nums
=
10
self
.
row_nums
=
100
self
.
max_vote_time_cost
=
10
# seconds
self
.
stop_dnode
=
None
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
check_setup_cluster_status
(
self
):
tdSql
.
query
(
"show mnodes"
)
for
mnode
in
tdSql
.
queryResult
:
name
=
mnode
[
1
]
info
=
mnode
self
.
mnode_list
[
name
]
=
info
tdSql
.
query
(
"show dnodes"
)
for
dnode
in
tdSql
.
queryResult
:
name
=
dnode
[
1
]
info
=
dnode
self
.
dnode_list
[
name
]
=
info
count
=
0
is_leader
=
False
mnode_name
=
''
for
k
,
v
in
self
.
mnode_list
.
items
():
count
+=
1
# only for 1 mnode
mnode_name
=
k
if
v
[
2
]
==
'leader'
:
is_leader
=
True
if
count
==
1
and
is_leader
:
tdLog
.
info
(
"===== depoly cluster success with 1 mnode as leader ====="
)
else
:
tdLog
.
exit
(
"===== depoly cluster fail with 1 mnode as leader ====="
)
for
k
,
v
in
self
.
dnode_list
.
items
():
if
k
==
mnode_name
:
if
v
[
3
]
==
0
:
tdLog
.
info
(
"===== depoly cluster mnode only success at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
tdLog
.
exit
(
"===== depoly cluster mnode only fail at {} , support_vnodes is {} "
.
format
(
mnode_name
,
v
[
3
]))
else
:
continue
def
create_db_check_vgroups
(
self
):
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test replica 1 duration 300"
)
tdSql
.
execute
(
"use test"
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"show test.vgroups;"
)
vgroups_infos
=
{}
# key is id: value is info list
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
tmp_list
=
[]
for
role
in
vgroup_info
[
3
:
-
4
]:
if
role
in
[
'leader'
,
'follower'
]:
tmp_list
.
append
(
role
)
vgroups_infos
[
vgroup_id
]
=
tmp_list
for
k
,
v
in
vgroups_infos
.
items
():
if
len
(
v
)
==
1
and
v
[
0
]
==
"leader"
:
tdLog
.
info
(
" === create database replica only 1 role leader check success of vgroup_id {} ======"
.
format
(
k
))
else
:
tdLog
.
exit
(
" === create database replica only 1 role leader check fail of vgroup_id {} ======"
.
format
(
k
))
def
_get_stop_dnode
(
self
):
only_dnode_list
=
self
.
dnode_list
.
keys
()
-
self
.
mnode_list
.
keys
()
self
.
stop_dnode
=
random
.
sample
(
only_dnode_list
,
1
)[
0
]
return
self
.
stop_dnode
def
check_vgroups_revote_leader
(
self
,
dbname
):
status
=
True
stop_dnode_id
=
self
.
dnode_list
[
self
.
stop_dnode
][
0
]
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
vgroup_status
=
[]
vgroups_leader_follower
=
vgroup_info
[
3
:
-
4
]
for
ind
,
role
in
enumerate
(
vgroups_leader_follower
):
if
ind
%
2
==
0
:
if
role
==
stop_dnode_id
and
vgroups_leader_follower
[
ind
+
1
]
==
"offline"
:
tdLog
.
info
(
"====== dnode {} has offline , endpoint is {}"
.
format
(
stop_dnode_id
,
self
.
stop_dnode
))
elif
role
==
stop_dnode_id
:
tdLog
.
exit
(
"====== dnode {} has not offline , endpoint is {}"
.
format
(
stop_dnode_id
,
self
.
stop_dnode
))
else
:
continue
else
:
vgroup_status
.
append
(
role
)
if
vgroup_status
.
count
(
"leader"
)
!=
1
or
vgroup_status
.
count
(
"follower"
)
!=
1
or
vgroup_status
.
count
(
"offline"
)
!=
1
:
status
=
False
return
status
return
status
def
wait_stop_dnode_OK
(
self
):
def
_get_status
():
status
=
""
tdSql
.
query
(
"show dnodes"
)
dnode_infos
=
tdSql
.
queryResult
for
dnode_info
in
dnode_infos
:
endpoint
=
dnode_info
[
1
]
dnode_status
=
dnode_info
[
4
]
if
endpoint
==
self
.
stop_dnode
:
status
=
dnode_status
break
return
status
status
=
_get_status
()
while
status
!=
"offline"
:
time
.
sleep
(
0.1
)
status
=
_get_status
()
# tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog
.
info
(
"==== stop_dnode has stopped , endpoint is {}"
.
format
(
self
.
stop_dnode
))
def
wait_start_dnode_OK
(
self
):
def
_get_status
():
status
=
""
tdSql
.
query
(
"show dnodes"
)
dnode_infos
=
tdSql
.
queryResult
for
dnode_info
in
dnode_infos
:
endpoint
=
dnode_info
[
1
]
dnode_status
=
dnode_info
[
4
]
if
endpoint
==
self
.
stop_dnode
:
status
=
dnode_status
break
return
status
status
=
_get_status
()
while
status
!=
"ready"
:
time
.
sleep
(
0.1
)
status
=
_get_status
()
# tdLog.info("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog
.
info
(
"==== stop_dnode has restart , endpoint is {}"
.
format
(
self
.
stop_dnode
))
def
random_stop_One_dnode
(
self
):
self
.
stop_dnode
=
self
.
_get_stop_dnode
()
stop_dnode_id
=
self
.
dnode_list
[
self
.
stop_dnode
][
0
]
tdLog
.
info
(
" ==== dnode {} will offline ,endpoints is {} ===="
.
format
(
stop_dnode_id
,
self
.
stop_dnode
))
tdDnodes
=
cluster
.
dnodes
tdDnodes
[
stop_dnode_id
-
1
].
stoptaosd
()
self
.
wait_stop_dnode_OK
()
# os.system("taos -s 'show dnodes;'")
def
Restart_stop_dnode
(
self
):
tdDnodes
=
cluster
.
dnodes
stop_dnode_id
=
self
.
dnode_list
[
self
.
stop_dnode
][
0
]
tdDnodes
[
stop_dnode_id
-
1
].
starttaosd
()
self
.
wait_start_dnode_OK
()
# os.system("taos -s 'show dnodes;'")
def
check_vgroups_init_done
(
self
,
dbname
):
status
=
True
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
for
vgroup_info
in
tdSql
.
queryResult
:
vgroup_id
=
vgroup_info
[
0
]
vgroup_status
=
[]
for
ind
,
role
in
enumerate
(
vgroup_info
[
3
:
-
4
]):
if
ind
%
2
==
0
:
continue
else
:
vgroup_status
.
append
(
role
)
if
vgroup_status
.
count
(
"leader"
)
!=
1
or
vgroup_status
.
count
(
"follower"
)
!=
2
:
status
=
False
return
status
return
status
def
vote_leader_time_costs
(
self
,
dbname
):
start
=
time
.
time
()
status
=
self
.
check_vgroups_init_done
(
dbname
)
while
not
status
:
time
.
sleep
(
0.1
)
status
=
self
.
check_vgroups_init_done
(
dbname
)
# tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
end
=
time
.
time
()
cost_time
=
end
-
start
tdLog
.
info
(
" ==== database %s vote the leaders success , cost time is %.3f second ====="
%
(
dbname
,
cost_time
)
)
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
if
cost_time
>=
self
.
max_vote_time_cost
:
tdLog
.
exit
(
" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="
%
(
dbname
,
cost_time
)
)
return
cost_time
def
revote_leader_time_costs
(
self
,
dbname
):
start
=
time
.
time
()
status
=
self
.
check_vgroups_revote_leader
(
dbname
)
while
not
status
:
time
.
sleep
(
0.1
)
status
=
self
.
check_vgroups_revote_leader
(
dbname
)
# tdLog.info("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
end
=
time
.
time
()
cost_time
=
end
-
start
tdLog
.
info
(
" ==== database %s revote the leaders success , cost time is %.3f second ====="
%
(
dbname
,
cost_time
)
)
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
if
cost_time
>=
self
.
max_vote_time_cost
:
tdLog
.
exit
(
" ==== database %s revote the leaders cost too large time , cost time is %.3f second ===="
%
(
dbname
,
cost_time
)
)
return
cost_time
def
exec_revote_action
(
self
,
dbname
):
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
before_revote
=
tdSql
.
queryResult
before_vgroups
=
set
()
for
vgroup_info
in
before_revote
:
before_vgroups
.
add
(
vgroup_info
[
3
:
-
4
])
self
.
random_stop_One_dnode
()
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
after_revote
=
tdSql
.
queryResult
after_vgroups
=
set
()
for
vgroup_info
in
after_revote
:
after_vgroups
.
add
(
vgroup_info
[
3
:
-
4
])
vote_act
=
set
(
set
(
after_vgroups
)
-
set
(
before_vgroups
))
if
not
vote_act
:
tdLog
.
exit
(
" ===maybe revote not occured , there is no dnode offline ===="
)
else
:
for
vgroup_info
in
vote_act
:
for
ind
,
role
in
enumerate
(
vgroup_info
):
if
role
==
self
.
dnode_list
[
self
.
stop_dnode
][
0
]:
if
vgroup_info
[
ind
+
1
]
==
"offline"
and
"leader"
in
vgroup_info
:
tdLog
.
info
(
" === revote leader ok , leader is {} now ===="
.
format
(
list
(
vgroup_info
).
index
(
"leader"
)
-
1
))
elif
vgroup_info
[
ind
+
1
]
!=
"offline"
:
tdLog
.
exit
(
" === dnode {} should be offline "
.
format
(
self
.
stop_dnode
))
else
:
continue
break
self
.
revote_leader_time_costs
(
dbname
)
self
.
Restart_stop_dnode
()
def
test_init_vgroups_time_costs
(
self
):
tdLog
.
info
(
" ====start check time cost about vgroups vote leaders ==== "
)
tdLog
.
info
(
" ==== current max time cost is set value : {} ======="
.
format
(
self
.
max_vote_time_cost
))
# create database replica 3 vgroups 1
db1
=
'db_1'
create_db_replica_3_vgroups_1
=
"create database {} replica 3 vgroups 1"
.
format
(
db1
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 1 ======'
.
format
(
db1
))
tdSql
.
execute
(
create_db_replica_3_vgroups_1
)
self
.
vote_leader_time_costs
(
db1
)
self
.
exec_revote_action
(
db1
)
# create database replica 3 vgroups 10
db2
=
'db_2'
create_db_replica_3_vgroups_10
=
"create database {} replica 3 vgroups 10"
.
format
(
db2
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 10 ======'
.
format
(
db2
))
tdSql
.
execute
(
create_db_replica_3_vgroups_10
)
self
.
vote_leader_time_costs
(
db2
)
self
.
exec_revote_action
(
db2
)
# create database replica 3 vgroups 100
db3
=
'db_3'
create_db_replica_3_vgroups_100
=
"create database {} replica 3 vgroups 100"
.
format
(
db3
)
tdLog
.
info
(
'=======database {} replica 3 vgroups 100 ======'
.
format
(
db3
))
tdSql
.
execute
(
create_db_replica_3_vgroups_100
)
self
.
vote_leader_time_costs
(
db3
)
self
.
exec_revote_action
(
db3
)
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
test_init_vgroups_time_costs
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录