Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
788473ff
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
788473ff
编写于
7月 30, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test cases
上级
1fbbd30a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
95 addition
and
95 deletion
+95
-95
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
...-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
+7
-7
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
...ode_basic_replica3_insertdatas_stop_leader_forece_stop.py
+49
-49
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py
...mnode_basic_replica3_querydatas_stop_leader_force_stop.py
+39
-39
未找到文件。
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
浏览文件 @
788473ff
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
taos
import
sys
import
sys
import
time
import
time
import
os
import
os
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -26,9 +26,9 @@ class TDTestCase:
...
@@ -26,9 +26,9 @@ class TDTestCase:
self
.
dnode_list
=
{}
self
.
dnode_list
=
{}
self
.
ts
=
1483200000000
self
.
ts
=
1483200000000
self
.
db_name
=
'testdb'
self
.
db_name
=
'testdb'
self
.
replica
=
3
self
.
replica
=
3
self
.
vgroups
=
2
self
.
vgroups
=
2
self
.
tb_nums
=
10
self
.
tb_nums
=
10
self
.
row_nums
=
100
self
.
row_nums
=
100
def
getBuildPath
(
self
):
def
getBuildPath
(
self
):
...
@@ -101,7 +101,7 @@ class TDTestCase:
...
@@ -101,7 +101,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
(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
):
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
query
(
"show stables"
)
...
@@ -145,7 +145,7 @@ class TDTestCase:
...
@@ -145,7 +145,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
(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
):
for
i
in
range
(
tb_nums
):
sub_tbname
=
"sub_tb_{}"
.
format
(
i
)
sub_tbname
=
"sub_tb_{}"
.
format
(
i
)
tdSql
.
execute
(
"create table {} using stb1 tags({})"
.
format
(
sub_tbname
,
i
))
tdSql
.
execute
(
"create table {} using stb1 tags({})"
.
format
(
sub_tbname
,
i
))
...
@@ -164,7 +164,7 @@ class TDTestCase:
...
@@ -164,7 +164,7 @@ class TDTestCase:
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
'stb1'
))
tdSql
.
checkRows
(
tb_nums
)
tdSql
.
checkRows
(
tb_nums
)
def
run
(
self
):
def
run
(
self
):
self
.
check_setup_cluster_status
()
self
.
check_setup_cluster_status
()
self
.
create_db_check_vgroups
()
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
.
create_db_replica_3_insertdatas
(
self
.
db_name
,
self
.
replica
,
self
.
vgroups
,
self
.
tb_nums
,
self
.
row_nums
)
...
@@ -176,4 +176,4 @@ class TDTestCase:
...
@@ -176,4 +176,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
浏览文件 @
788473ff
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
taos
import
sys
import
sys
import
time
import
time
import
os
import
os
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -28,9 +28,9 @@ class TDTestCase:
...
@@ -28,9 +28,9 @@ class TDTestCase:
self
.
ts
=
1483200000000
self
.
ts
=
1483200000000
self
.
ts_step
=
1000
self
.
ts_step
=
1000
self
.
db_name
=
'testdb'
self
.
db_name
=
'testdb'
self
.
replica
=
3
self
.
replica
=
3
self
.
vgroups
=
1
self
.
vgroups
=
1
self
.
tb_nums
=
10
self
.
tb_nums
=
10
self
.
row_nums
=
100
self
.
row_nums
=
100
self
.
stop_dnode_id
=
None
self
.
stop_dnode_id
=
None
self
.
loop_restart_times
=
10
self
.
loop_restart_times
=
10
...
@@ -193,7 +193,7 @@ class TDTestCase:
...
@@ -193,7 +193,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
(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
):
for
i
in
range
(
5
):
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
execute
(
"create table sub_tb_{} using stb1 tags({})"
.
format
(
i
,
i
))
tdSql
.
query
(
"show stables"
)
tdSql
.
query
(
"show stables"
)
...
@@ -225,7 +225,7 @@ class TDTestCase:
...
@@ -225,7 +225,7 @@ class TDTestCase:
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
def
create_stable_insert_datas
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
):
def
create_stable_insert_datas
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
tdSql
.
execute
(
...
@@ -234,8 +234,8 @@ class TDTestCase:
...
@@ -234,8 +234,8 @@ class TDTestCase:
tags (t1 int)
tags (t1 int)
'''
.
format
(
stablename
)
'''
.
format
(
stablename
)
)
)
for
i
in
range
(
tb_nums
):
for
i
in
range
(
tb_nums
):
sub_tbname
=
"sub_{}_{}"
.
format
(
stablename
,
i
)
sub_tbname
=
"sub_{}_{}"
.
format
(
stablename
,
i
)
tdSql
.
execute
(
"create table {} using {} tags({})"
.
format
(
sub_tbname
,
stablename
,
i
))
tdSql
.
execute
(
"create table {} using {} tags({})"
.
format
(
sub_tbname
,
stablename
,
i
))
# insert datas about new database
# insert datas about new database
...
@@ -245,11 +245,11 @@ class TDTestCase:
...
@@ -245,11 +245,11 @@ class TDTestCase:
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) "
)
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
.
notice
(
" ==== stable {} insert rows execute end ====="
.
format
(
stablename
))
tdLog
.
notice
(
" ==== stable {} insert rows execute end ====="
.
format
(
stablename
))
def
append_rows_of_exists_tables
(
self
,
dbname
,
stablename
,
tbname
,
append_nums
):
def
append_rows_of_exists_tables
(
self
,
dbname
,
stablename
,
tbname
,
append_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
for
row_num
in
range
(
append_nums
):
for
row_num
in
range
(
append_nums
):
tdSql
.
execute
(
f
"insert into
{
tbname
}
values (now,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
tdSql
.
execute
(
f
"insert into
{
tbname
}
values (now,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
...
@@ -257,9 +257,9 @@ class TDTestCase:
...
@@ -257,9 +257,9 @@ class TDTestCase:
os
.
system
(
"taos -s 'select count(*) from {}.{}';"
.
format
(
dbname
,
stablename
))
os
.
system
(
"taos -s 'select count(*) from {}.{}';"
.
format
(
dbname
,
stablename
))
def
check_insert_rows
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
,
append_rows
):
def
check_insert_rows
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
,
append_rows
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
while
not
tdSql
.
queryResult
:
while
not
tdSql
.
queryResult
:
...
@@ -267,8 +267,8 @@ class TDTestCase:
...
@@ -267,8 +267,8 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
count
=
0
count
=
0
while
not
status_OK
:
while
not
status_OK
:
if
count
>
self
.
try_check_times
:
if
count
>
self
.
try_check_times
:
os
.
system
(
"taos -s ' show {}.vgroups; '"
.
format
(
dbname
))
os
.
system
(
"taos -s ' show {}.vgroups; '"
.
format
(
dbname
))
...
@@ -282,14 +282,14 @@ class TDTestCase:
...
@@ -282,14 +282,14 @@ class TDTestCase:
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
tdLog
.
notice
(
" ==== check insert rows first failed , this is {}_th retry check rows of database {} ===="
.
format
(
count
,
dbname
))
tdLog
.
notice
(
" ==== check insert rows first failed , this is {}_th retry check rows of database {} ===="
.
format
(
count
,
dbname
))
count
+=
1
count
+=
1
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
while
not
tdSql
.
queryResult
:
while
not
tdSql
.
queryResult
:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
status_OK
=
self
.
mycheckRows
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
)
,
tb_nums
)
status_OK
=
self
.
mycheckRows
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
)
,
tb_nums
)
count
=
0
count
=
0
while
not
status_OK
:
while
not
status_OK
:
if
count
>
self
.
try_check_times
:
if
count
>
self
.
try_check_times
:
os
.
system
(
"taos -s ' show {}.vgroups;'"
.
format
(
dbname
))
os
.
system
(
"taos -s ' show {}.vgroups;'"
.
format
(
dbname
))
...
@@ -309,7 +309,7 @@ class TDTestCase:
...
@@ -309,7 +309,7 @@ class TDTestCase:
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
vgroup_infos
=
newTdSql
.
queryResult
vgroup_infos
=
newTdSql
.
queryResult
for
vgroup_info
in
vgroup_infos
:
for
vgroup_info
in
vgroup_infos
:
leader_infos
=
vgroup_info
[
3
:
-
4
]
leader_infos
=
vgroup_info
[
3
:
-
4
]
# print(vgroup_info)
# print(vgroup_info)
for
ind
,
role
in
enumerate
(
leader_infos
):
for
ind
,
role
in
enumerate
(
leader_infos
):
if
role
==
'leader'
:
if
role
==
'leader'
:
...
@@ -321,7 +321,7 @@ class TDTestCase:
...
@@ -321,7 +321,7 @@ class TDTestCase:
return
self
.
stop_dnode_id
return
self
.
stop_dnode_id
def
wait_stop_dnode_OK
(
self
):
def
wait_stop_dnode_OK
(
self
):
def
_get_status
():
def
_get_status
():
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
...
@@ -334,7 +334,7 @@ class TDTestCase:
...
@@ -334,7 +334,7 @@ class TDTestCase:
if
id
==
self
.
stop_dnode_id
:
if
id
==
self
.
stop_dnode_id
:
status
=
dnode_status
status
=
dnode_status
break
break
return
status
return
status
status
=
_get_status
()
status
=
_get_status
()
while
status
!=
"offline"
:
while
status
!=
"offline"
:
...
@@ -344,7 +344,7 @@ class TDTestCase:
...
@@ -344,7 +344,7 @@ class TDTestCase:
tdLog
.
notice
(
"==== stop_dnode has stopped , id is {}"
.
format
(
self
.
stop_dnode_id
))
tdLog
.
notice
(
"==== stop_dnode has stopped , id is {}"
.
format
(
self
.
stop_dnode_id
))
def
wait_start_dnode_OK
(
self
):
def
wait_start_dnode_OK
(
self
):
def
_get_status
():
def
_get_status
():
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
status
=
""
status
=
""
...
@@ -356,7 +356,7 @@ class TDTestCase:
...
@@ -356,7 +356,7 @@ class TDTestCase:
if
id
==
self
.
stop_dnode_id
:
if
id
==
self
.
stop_dnode_id
:
status
=
dnode_status
status
=
dnode_status
break
break
return
status
return
status
status
=
_get_status
()
status
=
_get_status
()
while
status
!=
"ready"
:
while
status
!=
"ready"
:
...
@@ -366,7 +366,7 @@ class TDTestCase:
...
@@ -366,7 +366,7 @@ class TDTestCase:
tdLog
.
notice
(
"==== stop_dnode has restart , id is {}"
.
format
(
self
.
stop_dnode_id
))
tdLog
.
notice
(
"==== stop_dnode has restart , id is {}"
.
format
(
self
.
stop_dnode_id
))
def
get_leader_infos
(
self
,
dbname
):
def
get_leader_infos
(
self
,
dbname
):
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
vgroup_infos
=
newTdSql
.
queryResult
vgroup_infos
=
newTdSql
.
queryResult
...
@@ -386,7 +386,7 @@ class TDTestCase:
...
@@ -386,7 +386,7 @@ class TDTestCase:
tdLog
.
exit
(
" ===maybe revote not occured , there is no dnode offline ===="
)
tdLog
.
exit
(
" ===maybe revote not occured , there is no dnode offline ===="
)
else
:
else
:
for
vgroup_info
in
vote_act
:
for
vgroup_info
in
vote_act
:
for
ind
,
role
in
enumerate
(
vgroup_info
):
for
ind
,
role
in
enumerate
(
vgroup_info
):
if
role
==
self
.
stop_dnode_id
:
if
role
==
self
.
stop_dnode_id
:
if
vgroup_info
[
ind
+
1
]
==
"offline"
and
"leader"
in
vgroup_info
:
if
vgroup_info
[
ind
+
1
]
==
"offline"
and
"leader"
in
vgroup_info
:
...
@@ -400,12 +400,12 @@ class TDTestCase:
...
@@ -400,12 +400,12 @@ class TDTestCase:
return
check_status
return
check_status
def
force_stop_dnode
(
self
,
dnode_id
):
def
force_stop_dnode
(
self
,
dnode_id
):
tdSql
.
query
(
"show dnodes"
)
tdSql
.
query
(
"show dnodes"
)
port
=
None
port
=
None
for
dnode_info
in
tdSql
.
queryResult
:
for
dnode_info
in
tdSql
.
queryResult
:
if
dnode_id
==
dnode_info
[
0
]:
if
dnode_id
==
dnode_info
[
0
]:
port
=
dnode_info
[
1
].
split
(
":"
)[
-
1
]
port
=
dnode_info
[
1
].
split
(
":"
)[
-
1
]
break
break
else
:
else
:
continue
continue
...
@@ -427,25 +427,25 @@ class TDTestCase:
...
@@ -427,25 +427,25 @@ class TDTestCase:
self
.
create_database
(
dbname
=
db_name
,
replica_num
=
self
.
replica
,
vgroup_nums
=
1
)
self
.
create_database
(
dbname
=
db_name
,
replica_num
=
self
.
replica
,
vgroup_nums
=
1
)
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
stablename
,
tb_nums
=
10
,
row_nums
=
10
)
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
stablename
,
tb_nums
=
10
,
row_nums
=
10
)
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
db_name
)
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
db_name
)
# check rows of datas
# check rows of datas
self
.
check_insert_rows
(
db_name
,
stablename
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
self
.
check_insert_rows
(
db_name
,
stablename
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
# get leader info before stop
# get leader info before stop
before_leader_infos
=
self
.
get_leader_infos
(
db_name
)
before_leader_infos
=
self
.
get_leader_infos
(
db_name
)
# begin stop dnode
# begin stop dnode
# force stop taosd by kill -9
# force stop taosd by kill -9
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
self
.
wait_stop_dnode_OK
()
self
.
wait_stop_dnode_OK
()
# vote leaders check
# vote leaders check
# get leader info after stop
# get leader info after stop
after_leader_infos
=
self
.
get_leader_infos
(
db_name
)
after_leader_infos
=
self
.
get_leader_infos
(
db_name
)
revote_status
=
self
.
check_revote_leader_success
(
db_name
,
before_leader_infos
,
after_leader_infos
)
revote_status
=
self
.
check_revote_leader_success
(
db_name
,
before_leader_infos
,
after_leader_infos
)
# append rows of stablename when dnode stop make sure revote leaders
# append rows of stablename when dnode stop make sure revote leaders
...
@@ -470,7 +470,7 @@ class TDTestCase:
...
@@ -470,7 +470,7 @@ class TDTestCase:
else
:
else
:
tdLog
.
notice
(
"===== leader of database {} is not ok , append rows fail ====="
.
format
(
db_name
))
tdLog
.
notice
(
"===== leader of database {} is not ok , append rows fail ====="
.
format
(
db_name
))
# begin start dnode
# begin start dnode
start
=
time
.
time
()
start
=
time
.
time
()
tdDnodes
[
self
.
stop_dnode_id
-
1
].
starttaosd
()
tdDnodes
[
self
.
stop_dnode_id
-
1
].
starttaosd
()
self
.
wait_start_dnode_OK
()
self
.
wait_start_dnode_OK
()
...
@@ -478,29 +478,29 @@ class TDTestCase:
...
@@ -478,29 +478,29 @@ class TDTestCase:
time_cost
=
int
(
end
-
start
)
time_cost
=
int
(
end
-
start
)
if
time_cost
>
self
.
max_restart_time
:
if
time_cost
>
self
.
max_restart_time
:
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
# create new stables again
# create new stables again
tdLog
.
notice
(
" ==== create new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
tdLog
.
notice
(
" ==== create new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
)
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
)
tdLog
.
notice
(
" ==== check new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
tdLog
.
notice
(
" ==== check new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
self
.
check_insert_rows
(
db_name
,
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
self
.
check_insert_rows
(
db_name
,
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
def
unsync_run_case
(
self
):
def
unsync_run_case
(
self
):
def
_restart_dnode_of_db_unsync
(
dbname
):
def
_restart_dnode_of_db_unsync
(
dbname
):
tdDnodes
=
cluster
.
dnodes
tdDnodes
=
cluster
.
dnodes
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
dbname
)
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
dbname
)
# begin restart dnode
# begin restart dnode
# force stop taosd by kill -9
# force stop taosd by kill -9
# get leader info before stop
# get leader info before stop
before_leader_infos
=
self
.
get_leader_infos
(
db_name
)
before_leader_infos
=
self
.
get_leader_infos
(
db_name
)
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
self
.
wait_stop_dnode_OK
()
self
.
wait_stop_dnode_OK
()
# check revote leader when restart servers
# check revote leader when restart servers
# get leader info after stop
# get leader info after stop
after_leader_infos
=
self
.
get_leader_infos
(
db_name
)
after_leader_infos
=
self
.
get_leader_infos
(
db_name
)
revote_status
=
self
.
check_revote_leader_success
(
db_name
,
before_leader_infos
,
after_leader_infos
)
revote_status
=
self
.
check_revote_leader_success
(
db_name
,
before_leader_infos
,
after_leader_infos
)
# append rows of stablename when dnode stop make sure revote leaders
# append rows of stablename when dnode stop make sure revote leaders
...
@@ -520,30 +520,30 @@ class TDTestCase:
...
@@ -520,30 +520,30 @@ class TDTestCase:
tdLog
.
notice
(
" ==== check new stable {} when dnode {} offline ===="
.
format
(
'new_stb1'
,
self
.
stop_dnode_id
))
tdLog
.
notice
(
" ==== check new stable {} when dnode {} offline ===="
.
format
(
'new_stb1'
,
self
.
stop_dnode_id
))
self
.
check_insert_rows
(
db_name
,
'new_stb1'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
self
.
check_insert_rows
(
db_name
,
'new_stb1'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
# create new stables again
# create new stables again
tdLog
.
notice
(
" ==== create new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
tdLog
.
notice
(
" ==== create new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
)
self
.
create_stable_insert_datas
(
dbname
=
db_name
,
stablename
=
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
)
tdLog
.
notice
(
" ==== check new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
tdLog
.
notice
(
" ==== check new stable {} when dnode {} restart ===="
.
format
(
'new_stb2'
,
self
.
stop_dnode_id
))
self
.
check_insert_rows
(
db_name
,
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
self
.
check_insert_rows
(
db_name
,
'new_stb2'
,
tb_nums
=
10
,
row_nums
=
10
,
append_rows
=
0
)
tdDnodes
[
self
.
stop_dnode_id
-
1
].
starttaosd
()
tdDnodes
[
self
.
stop_dnode_id
-
1
].
starttaosd
()
start
=
time
.
time
()
start
=
time
.
time
()
self
.
wait_start_dnode_OK
()
self
.
wait_start_dnode_OK
()
end
=
time
.
time
()
end
=
time
.
time
()
time_cost
=
int
(
end
-
start
)
time_cost
=
int
(
end
-
start
)
if
time_cost
>
self
.
max_restart_time
:
if
time_cost
>
self
.
max_restart_time
:
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
def
_create_threading
(
dbname
):
def
_create_threading
(
dbname
):
self
.
current_thread
=
threading
.
Thread
(
target
=
_restart_dnode_of_db_unsync
,
args
=
(
dbname
,))
self
.
current_thread
=
threading
.
Thread
(
target
=
_restart_dnode_of_db_unsync
,
args
=
(
dbname
,))
return
self
.
current_thread
return
self
.
current_thread
'''
'''
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
'''
'''
for
loop
in
range
(
self
.
loop_restart_times
):
for
loop
in
range
(
self
.
loop_restart_times
):
db_name
=
"unsync_db_{}"
.
format
(
loop
)
db_name
=
"unsync_db_{}"
.
format
(
loop
)
...
@@ -553,7 +553,7 @@ class TDTestCase:
...
@@ -553,7 +553,7 @@ class TDTestCase:
tdLog
.
notice
(
" ===== restart dnode of database {} in an unsync threading ===== "
.
format
(
db_name
))
tdLog
.
notice
(
" ===== restart dnode of database {} in an unsync threading ===== "
.
format
(
db_name
))
# create sync threading and start it
# create sync threading and start it
self
.
current_thread
=
_create_threading
(
db_name
)
self
.
current_thread
=
_create_threading
(
db_name
)
self
.
current_thread
.
start
()
self
.
current_thread
.
start
()
...
@@ -564,7 +564,7 @@ class TDTestCase:
...
@@ -564,7 +564,7 @@ class TDTestCase:
self
.
current_thread
.
join
()
self
.
current_thread
.
join
()
def
run
(
self
):
def
run
(
self
):
# basic insert and check of cluster
# basic insert and check of cluster
self
.
check_setup_cluster_status
()
self
.
check_setup_cluster_status
()
...
@@ -577,4 +577,4 @@ class TDTestCase:
...
@@ -577,4 +577,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py
浏览文件 @
788473ff
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
...
@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import
taos
import
taos
import
sys
import
sys
import
time
import
time
import
os
import
os
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -30,9 +30,9 @@ class TDTestCase:
...
@@ -30,9 +30,9 @@ class TDTestCase:
self
.
ts
=
1483200000000
self
.
ts
=
1483200000000
self
.
ts_step
=
1000
self
.
ts_step
=
1000
self
.
db_name
=
'testdb'
self
.
db_name
=
'testdb'
self
.
replica
=
3
self
.
replica
=
3
self
.
vgroups
=
1
self
.
vgroups
=
1
self
.
tb_nums
=
10
self
.
tb_nums
=
10
self
.
row_nums
=
100
self
.
row_nums
=
100
self
.
stop_dnode_id
=
None
self
.
stop_dnode_id
=
None
self
.
loop_restart_times
=
5
self
.
loop_restart_times
=
5
...
@@ -40,7 +40,7 @@ class TDTestCase:
...
@@ -40,7 +40,7 @@ class TDTestCase:
self
.
max_restart_time
=
10
self
.
max_restart_time
=
10
self
.
try_check_times
=
10
self
.
try_check_times
=
10
self
.
query_times
=
100
self
.
query_times
=
100
def
getBuildPath
(
self
):
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
@@ -103,7 +103,7 @@ class TDTestCase:
...
@@ -103,7 +103,7 @@ class TDTestCase:
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
drop_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
create_db_sql
)
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
def
create_stable_insert_datas
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
):
def
create_stable_insert_datas
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
tdSql
.
execute
(
...
@@ -112,7 +112,7 @@ class TDTestCase:
...
@@ -112,7 +112,7 @@ class TDTestCase:
tags (t1 int)
tags (t1 int)
'''
.
format
(
stablename
)
'''
.
format
(
stablename
)
)
)
for
i
in
range
(
tb_nums
):
for
i
in
range
(
tb_nums
):
sub_tbname
=
"sub_{}_{}"
.
format
(
stablename
,
i
)
sub_tbname
=
"sub_{}_{}"
.
format
(
stablename
,
i
)
tdSql
.
execute
(
"create table {} using {} tags({})"
.
format
(
sub_tbname
,
stablename
,
i
))
tdSql
.
execute
(
"create table {} using {} tags({})"
.
format
(
sub_tbname
,
stablename
,
i
))
...
@@ -123,11 +123,11 @@ class TDTestCase:
...
@@ -123,11 +123,11 @@ class TDTestCase:
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) "
)
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
.
notice
(
" ==== stable {} insert rows execute end ====="
.
format
(
stablename
))
tdLog
.
notice
(
" ==== stable {} insert rows execute end ====="
.
format
(
stablename
))
def
append_rows_of_exists_tables
(
self
,
dbname
,
stablename
,
tbname
,
append_nums
):
def
append_rows_of_exists_tables
(
self
,
dbname
,
stablename
,
tbname
,
append_nums
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
for
row_num
in
range
(
append_nums
):
for
row_num
in
range
(
append_nums
):
tdSql
.
execute
(
f
"insert into
{
tbname
}
values (now,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
tdSql
.
execute
(
f
"insert into
{
tbname
}
values (now,
{
row_num
}
,
{
row_num
}
, 10 ,1 ,
{
row_num
}
,
{
row_num
}
,true,'bin_
{
row_num
}
','nchar_
{
row_num
}
',now) "
)
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
...
@@ -137,7 +137,7 @@ class TDTestCase:
...
@@ -137,7 +137,7 @@ class TDTestCase:
def
check_insert_rows
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
,
append_rows
):
def
check_insert_rows
(
self
,
dbname
,
stablename
,
tb_nums
,
row_nums
,
append_rows
):
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
execute
(
"use {}"
.
format
(
dbname
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
while
not
tdSql
.
queryResult
:
while
not
tdSql
.
queryResult
:
...
@@ -145,8 +145,8 @@ class TDTestCase:
...
@@ -145,8 +145,8 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
))
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
count
=
0
count
=
0
while
not
status_OK
:
while
not
status_OK
:
if
count
>
self
.
try_check_times
:
if
count
>
self
.
try_check_times
:
os
.
system
(
"taos -s ' show {}.vgroups; '"
.
format
(
dbname
))
os
.
system
(
"taos -s ' show {}.vgroups; '"
.
format
(
dbname
))
...
@@ -160,14 +160,14 @@ class TDTestCase:
...
@@ -160,14 +160,14 @@ class TDTestCase:
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
status_OK
=
self
.
mycheckData
(
"select count(*) from {}.{}"
.
format
(
dbname
,
stablename
)
,
0
,
0
,
tb_nums
*
row_nums
+
append_rows
)
tdLog
.
notice
(
" ==== check insert rows first failed , this is {}_th retry check rows of database {}"
.
format
(
count
,
dbname
))
tdLog
.
notice
(
" ==== check insert rows first failed , this is {}_th retry check rows of database {}"
.
format
(
count
,
dbname
))
count
+=
1
count
+=
1
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
while
not
tdSql
.
queryResult
:
while
not
tdSql
.
queryResult
:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
tdSql
.
query
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
))
status_OK
=
self
.
mycheckRows
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
)
,
tb_nums
)
status_OK
=
self
.
mycheckRows
(
"select distinct tbname from {}.{}"
.
format
(
dbname
,
stablename
)
,
tb_nums
)
count
=
0
count
=
0
while
not
status_OK
:
while
not
status_OK
:
if
count
>
self
.
try_check_times
:
if
count
>
self
.
try_check_times
:
os
.
system
(
"taos -s ' show {}.vgroups;'"
.
format
(
dbname
))
os
.
system
(
"taos -s ' show {}.vgroups;'"
.
format
(
dbname
))
...
@@ -186,7 +186,7 @@ class TDTestCase:
...
@@ -186,7 +186,7 @@ class TDTestCase:
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
tdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
vgroup_infos
=
tdSql
.
queryResult
vgroup_infos
=
tdSql
.
queryResult
for
vgroup_info
in
vgroup_infos
:
for
vgroup_info
in
vgroup_infos
:
leader_infos
=
vgroup_info
[
3
:
-
4
]
leader_infos
=
vgroup_info
[
3
:
-
4
]
# print(vgroup_info)
# print(vgroup_info)
for
ind
,
role
in
enumerate
(
leader_infos
):
for
ind
,
role
in
enumerate
(
leader_infos
):
if
role
==
'leader'
:
if
role
==
'leader'
:
...
@@ -198,7 +198,7 @@ class TDTestCase:
...
@@ -198,7 +198,7 @@ class TDTestCase:
return
self
.
stop_dnode_id
return
self
.
stop_dnode_id
def
wait_stop_dnode_OK
(
self
):
def
wait_stop_dnode_OK
(
self
):
def
_get_status
():
def
_get_status
():
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
...
@@ -211,7 +211,7 @@ class TDTestCase:
...
@@ -211,7 +211,7 @@ class TDTestCase:
if
id
==
self
.
stop_dnode_id
:
if
id
==
self
.
stop_dnode_id
:
status
=
dnode_status
status
=
dnode_status
break
break
return
status
return
status
status
=
_get_status
()
status
=
_get_status
()
while
status
!=
"offline"
:
while
status
!=
"offline"
:
...
@@ -229,7 +229,7 @@ class TDTestCase:
...
@@ -229,7 +229,7 @@ class TDTestCase:
tdLog
.
info
(
" ===maybe revote not occured , there is no dnode offline ===="
)
tdLog
.
info
(
" ===maybe revote not occured , there is no dnode offline ===="
)
else
:
else
:
for
vgroup_info
in
vote_act
:
for
vgroup_info
in
vote_act
:
for
ind
,
role
in
enumerate
(
vgroup_info
):
for
ind
,
role
in
enumerate
(
vgroup_info
):
if
role
==
self
.
stop_dnode_id
:
if
role
==
self
.
stop_dnode_id
:
if
vgroup_info
[
ind
+
1
]
==
"offline"
and
"leader"
in
vgroup_info
:
if
vgroup_info
[
ind
+
1
]
==
"offline"
and
"leader"
in
vgroup_info
:
...
@@ -243,7 +243,7 @@ class TDTestCase:
...
@@ -243,7 +243,7 @@ class TDTestCase:
return
check_status
return
check_status
def
wait_start_dnode_OK
(
self
):
def
wait_start_dnode_OK
(
self
):
def
_get_status
():
def
_get_status
():
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
status
=
""
status
=
""
...
@@ -255,7 +255,7 @@ class TDTestCase:
...
@@ -255,7 +255,7 @@ class TDTestCase:
if
id
==
self
.
stop_dnode_id
:
if
id
==
self
.
stop_dnode_id
:
status
=
dnode_status
status
=
dnode_status
break
break
return
status
return
status
status
=
_get_status
()
status
=
_get_status
()
while
status
!=
"ready"
:
while
status
!=
"ready"
:
...
@@ -349,10 +349,10 @@ class TDTestCase:
...
@@ -349,10 +349,10 @@ class TDTestCase:
tdLog
.
info
(
"%s(%d) failed: sql:%s, queryRows:%d != expect:%d"
%
args
)
tdLog
.
info
(
"%s(%d) failed: sql:%s, queryRows:%d != expect:%d"
%
args
)
check_status
=
False
check_status
=
False
return
check_status
return
check_status
def
get_leader_infos
(
self
,
dbname
):
def
get_leader_infos
(
self
,
dbname
):
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
=
tdCom
.
newTdSql
()
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
newTdSql
.
query
(
"show {}.vgroups"
.
format
(
dbname
))
vgroup_infos
=
newTdSql
.
queryResult
vgroup_infos
=
newTdSql
.
queryResult
...
@@ -369,7 +369,7 @@ class TDTestCase:
...
@@ -369,7 +369,7 @@ class TDTestCase:
port
=
None
port
=
None
for
dnode_info
in
tdSql
.
queryResult
:
for
dnode_info
in
tdSql
.
queryResult
:
if
dnode_id
==
dnode_info
[
0
]:
if
dnode_id
==
dnode_info
[
0
]:
port
=
dnode_info
[
1
].
split
(
":"
)[
-
1
]
port
=
dnode_info
[
1
].
split
(
":"
)[
-
1
]
break
break
else
:
else
:
continue
continue
...
@@ -383,9 +383,9 @@ class TDTestCase:
...
@@ -383,9 +383,9 @@ class TDTestCase:
os
.
system
(
ps_kill_taosd
)
os
.
system
(
ps_kill_taosd
)
def
basic_query_task
(
self
,
dbname
,
stablename
):
def
basic_query_task
(
self
,
dbname
,
stablename
):
sql
=
"select * from {}.{} ;"
.
format
(
dbname
,
stablename
)
sql
=
"select * from {}.{} ;"
.
format
(
dbname
,
stablename
)
count
=
0
count
=
0
while
count
<
self
.
query_times
:
while
count
<
self
.
query_times
:
os
.
system
(
''' taos -s '{}' >>/dev/null '''
.
format
(
sql
))
os
.
system
(
''' taos -s '{}' >>/dev/null '''
.
format
(
sql
))
...
@@ -398,35 +398,35 @@ class TDTestCase:
...
@@ -398,35 +398,35 @@ class TDTestCase:
self
.
thread_list
.
append
(
task
)
self
.
thread_list
.
append
(
task
)
for
thread
in
self
.
thread_list
:
for
thread
in
self
.
thread_list
:
thread
.
start
()
thread
.
start
()
return
self
.
thread_list
return
self
.
thread_list
def
stop_follower_when_query_going
(
self
):
def
stop_follower_when_query_going
(
self
):
tdDnodes
=
cluster
.
dnodes
tdDnodes
=
cluster
.
dnodes
self
.
create_database
(
dbname
=
self
.
db_name
,
replica_num
=
self
.
replica
,
vgroup_nums
=
1
)
self
.
create_database
(
dbname
=
self
.
db_name
,
replica_num
=
self
.
replica
,
vgroup_nums
=
1
)
self
.
create_stable_insert_datas
(
dbname
=
self
.
db_name
,
stablename
=
"stb1"
,
tb_nums
=
self
.
tb_nums
,
row_nums
=
self
.
row_nums
)
self
.
create_stable_insert_datas
(
dbname
=
self
.
db_name
,
stablename
=
"stb1"
,
tb_nums
=
self
.
tb_nums
,
row_nums
=
self
.
row_nums
)
# let query task start
# let query task start
self
.
thread_list
=
self
.
multi_thread_query_task
(
10
,
self
.
db_name
,
'stb1'
)
self
.
thread_list
=
self
.
multi_thread_query_task
(
10
,
self
.
db_name
,
'stb1'
)
# force stop follower
# force stop follower
for
loop
in
range
(
self
.
loop_restart_times
):
for
loop
in
range
(
self
.
loop_restart_times
):
tdLog
.
debug
(
" ==== this is {}_th restart follower of database {} ==== "
.
format
(
loop
,
self
.
db_name
))
tdLog
.
debug
(
" ==== this is {}_th restart follower of database {} ==== "
.
format
(
loop
,
self
.
db_name
))
# get leader info before stop
# get leader info before stop
before_leader_infos
=
self
.
get_leader_infos
(
self
.
db_name
)
before_leader_infos
=
self
.
get_leader_infos
(
self
.
db_name
)
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
self
.
db_name
)
self
.
stop_dnode_id
=
self
.
_get_stop_dnode_id
(
self
.
db_name
)
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
self
.
force_stop_dnode
(
self
.
stop_dnode_id
)
start
=
time
.
time
()
start
=
time
.
time
()
# get leader info after stop
# get leader info after stop
after_leader_infos
=
self
.
get_leader_infos
(
self
.
db_name
)
after_leader_infos
=
self
.
get_leader_infos
(
self
.
db_name
)
revote_status
=
self
.
check_revote_leader_success
(
self
.
db_name
,
before_leader_infos
,
after_leader_infos
)
revote_status
=
self
.
check_revote_leader_success
(
self
.
db_name
,
before_leader_infos
,
after_leader_infos
)
while
not
revote_status
:
while
not
revote_status
:
...
@@ -434,7 +434,7 @@ class TDTestCase:
...
@@ -434,7 +434,7 @@ class TDTestCase:
revote_status
=
self
.
check_revote_leader_success
(
self
.
db_name
,
before_leader_infos
,
after_leader_infos
)
revote_status
=
self
.
check_revote_leader_success
(
self
.
db_name
,
before_leader_infos
,
after_leader_infos
)
end
=
time
.
time
()
end
=
time
.
time
()
time_cost
=
end
-
start
time_cost
=
end
-
start
tdLog
.
debug
(
" ==== revote leader of database {} cost time {} ===="
.
format
(
self
.
db_name
,
time_cost
))
tdLog
.
debug
(
" ==== revote leader of database {} cost time {} ===="
.
format
(
self
.
db_name
,
time_cost
))
self
.
wait_stop_dnode_OK
()
self
.
wait_stop_dnode_OK
()
...
@@ -444,22 +444,22 @@ class TDTestCase:
...
@@ -444,22 +444,22 @@ class TDTestCase:
self
.
wait_start_dnode_OK
()
self
.
wait_start_dnode_OK
()
end
=
time
.
time
()
end
=
time
.
time
()
time_cost
=
int
(
end
-
start
)
time_cost
=
int
(
end
-
start
)
if
time_cost
>
self
.
max_restart_time
:
if
time_cost
>
self
.
max_restart_time
:
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
tdLog
.
exit
(
" ==== restart dnode {} cost too much time , please check ===="
.
format
(
self
.
stop_dnode_id
))
for
thread
in
self
.
thread_list
:
for
thread
in
self
.
thread_list
:
thread
.
join
()
thread
.
join
()
def
run
(
self
):
def
run
(
self
):
# basic check of cluster
# basic check of cluster
self
.
check_setup_cluster_status
()
self
.
check_setup_cluster_status
()
self
.
stop_follower_when_query_going
()
self
.
stop_follower_when_query_going
()
def
stop
(
self
):
def
stop
(
self
):
...
@@ -467,4 +467,4 @@ class TDTestCase:
...
@@ -467,4 +467,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录