Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
af775af6
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看板
提交
af775af6
编写于
4月 26, 2023
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add test case for alter replica
上级
81a4e02e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
115 addition
and
0 deletion
+115
-0
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/system-test/1-insert/alter_replica.py
tests/system-test/1-insert/alter_replica.py
+114
-0
未找到文件。
tests/parallel_test/cases.task
浏览文件 @
af775af6
...
...
@@ -142,6 +142,7 @@
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_replica.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
...
...
tests/system-test/1-insert/alter_replica.py
0 → 100644
浏览文件 @
af775af6
import
taos
import
sys
import
time
import
socket
import
os
import
threading
import
datetime
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
checkVgroups
(
self
,
dbName
,
vgNum
):
sleepNum
=
vgNum
*
60
flag
=
0
while
(
sleepNum
>
0
):
sql
=
f
'show
{
dbName
}
.vgroups'
tdSql
.
query
(
sql
)
flag
=
0
for
vgid
in
range
(
vgNum
)
:
v1_status
=
tdSql
.
queryResult
[
vgid
][
4
]
v2_status
=
tdSql
.
queryResult
[
vgid
][
6
]
v3_status
=
tdSql
.
queryResult
[
vgid
][
8
]
if
((
v1_status
==
'leader'
)
and
(
v2_status
==
'follower'
)
and
(
v3_status
==
'follower'
))
\
or
((
v2_status
==
'leader'
)
and
(
v1_status
==
'follower'
)
and
(
v3_status
==
'follower'
))
\
or
((
v3_status
==
'leader'
)
and
(
v2_status
==
'follower'
)
and
(
v1_status
==
'follower'
)):
continue
else
:
sleepNum
=
sleepNum
-
1
time
.
sleep
(
1
)
flag
=
1
break
if
(
0
==
flag
):
return
0
tdLog
.
debug
(
"vgroup[%d] status: %s, %s, %s"
%
(
vgid
,
v1_status
,
v2_status
,
v3_status
))
return
-
1
def
alter_replica
(
self
):
# create db and alter replica
tdLog
.
debug
(
"====alter db repica 1===="
)
vgNum
=
3
dbName
=
'db1'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
# create db, stable, child tables, and insert data, then alter replica
tdLog
.
debug
(
"====alter db repica 2===="
)
dbName
=
'db2'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'use
{
dbName
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'create stable stb (ts timestamp, c int) tags (t int)'
tdSql
.
execute
(
sql
)
sql
=
f
'create table ctb using stb tags (1)'
tdSql
.
execute
(
sql
)
sql
=
f
'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
# firstly create db, stable, child tables, and insert data, then drop stable, and then alter replica
tdLog
.
debug
(
"====alter db repica 3===="
)
dbName
=
'db3'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'use
{
dbName
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'create stable stb (ts timestamp, c int) tags (t int)'
tdSql
.
execute
(
sql
)
sql
=
f
'create table ctb using stb tags (1)'
tdSql
.
execute
(
sql
)
sql
=
f
'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
tdSql
.
execute
(
sql
)
sql
=
f
'drop table stb'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
def
run
(
self
):
self
.
alter_replica
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录