Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ca628593
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ca628593
编写于
6月 27, 2023
作者:
H
Hui Li
提交者:
GitHub
6月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21864 from taosdata/test/TD-24925-3.0
test: add forbid stream and topic case to splitVGroup.py
上级
472c23d8
fa4873df
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
214 addition
and
12 deletion
+214
-12
tests/system-test/0-others/splitVGroup.py
tests/system-test/0-others/splitVGroup.py
+48
-12
tests/system-test/eco-system/util/Consumer.py
tests/system-test/eco-system/util/Consumer.py
+82
-0
tests/system-test/eco-system/util/restartDnodes.py
tests/system-test/eco-system/util/restartDnodes.py
+84
-0
未找到文件。
tests/system-test/0-others/splitVGroup.py
浏览文件 @
ca628593
...
...
@@ -328,9 +328,28 @@ class TDTestCase:
tdLog
.
exit
(
"split vgroup transaction is not finished after executing 50s"
)
return
False
# split error
def
expectSplitError
(
self
,
dbName
):
vgids
=
self
.
getVGroup
(
dbName
)
selid
=
random
.
choice
(
vgids
)
sql
=
f
"split vgroup
{
selid
}
"
tdLog
.
info
(
sql
)
tdSql
.
error
(
sql
)
# expect split ok
def
expectSplitOk
(
self
,
dbName
):
# split vgroup
vgList1
=
self
.
getVGroup
(
dbName
)
self
.
splitVGroup
(
dbName
)
vgList2
=
self
.
getVGroup
(
dbName
)
vgNum1
=
len
(
vgList1
)
+
1
vgNum2
=
len
(
vgList2
)
if
vgNum1
!=
vgNum2
:
tdLog
.
exit
(
f
" vglist len=
{
vgNum1
}
is not same for expect
{
vgNum2
}
"
)
return
# split empty database
def
splitEmptyDB
(
self
):
dbName
=
"emptydb"
vgNum
=
2
# create database
...
...
@@ -339,17 +358,33 @@ class TDTestCase:
tdSql
.
execute
(
sql
)
# split vgroup
self
.
splitVGroup
(
dbName
)
vgList
=
self
.
getVGroup
(
dbName
)
vgNum1
=
len
(
vgList
)
vgNum2
=
vgNum
+
1
if
vgNum1
!=
vgNum2
:
tdLog
.
exit
(
f
" vglist len=
{
vgNum1
}
is not same for expect
{
vgNum2
}
"
)
return
self
.
expectSplitOk
(
dbName
)
# forbid
def
checkForbid
(
self
):
# stream
tdLog
.
info
(
"check forbid split having stream..."
)
tdSql
.
execute
(
"create database streamdb;"
)
tdSql
.
execute
(
"use streamdb;"
)
tdSql
.
execute
(
"create table ta(ts timestamp, age int);"
)
tdSql
.
execute
(
"create stream ma into sta as select count(*) from ta interval(1s);"
)
self
.
expectSplitError
(
"streamdb"
)
tdSql
.
execute
(
"drop stream ma;"
)
self
.
expectSplitOk
(
"streamdb"
)
# topic
tdLog
.
info
(
"check forbid split having topic..."
)
tdSql
.
execute
(
"create database topicdb wal_retention_period 10;"
)
tdSql
.
execute
(
"use topicdb;"
)
tdSql
.
execute
(
"create table ta(ts timestamp, age int);"
)
tdSql
.
execute
(
"create topic toa as select * from ta;"
)
self
.
expectSplitError
(
"topicdb"
)
tdSql
.
execute
(
"drop topic toa;"
)
self
.
expectSplitOk
(
"topicdb"
)
# run
def
run
(
self
):
# prepare env
self
.
prepareEnv
()
...
...
@@ -360,12 +395,13 @@ class TDTestCase:
# check two db query result same
self
.
checkResult
()
tdLog
.
info
(
f
"split vgroup i=
{
i
}
passed."
)
# split empty db
self
.
splitEmptyDB
()
# check topic and stream forib
self
.
checkForbid
()
# stop
def
stop
(
self
):
...
...
tests/system-test/eco-system/util/Consumer.py
0 → 100644
浏览文件 @
ca628593
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
#
# The option for wal_retetion_period and wal_retention_size is work well
#
import
taos
from
taos.tmq
import
Consumer
import
os
import
sys
import
threading
import
json
import
time
from
datetime
import
date
from
datetime
import
datetime
from
datetime
import
timedelta
from
os
import
path
# consume topic
def
consume_topic
(
topic_name
,
consume_cnt
,
wait
):
print
(
"start consume..."
)
consumer
=
Consumer
(
{
"group.id"
:
"tg2"
,
"td.connect.user"
:
"root"
,
"td.connect.pass"
:
"taosdata"
,
"enable.auto.commit"
:
"true"
,
}
)
print
(
"start subscrite..."
)
consumer
.
subscribe
([
topic_name
])
cnt
=
0
try
:
while
True
and
cnt
<
consume_cnt
:
res
=
consumer
.
poll
(
1
)
if
not
res
:
if
wait
:
continue
else
:
break
err
=
res
.
error
()
if
err
is
not
None
:
raise
err
val
=
res
.
value
()
cnt
+=
1
print
(
f
" consume
{
cnt
}
"
)
for
block
in
val
:
print
(
block
.
fetchall
())
finally
:
consumer
.
unsubscribe
()
consumer
.
close
()
if
__name__
==
"__main__"
:
print
(
sys
.
argv
)
if
len
(
sys
.
argv
)
<
2
:
print
(
" please input topic name for consume . -c for wait"
)
else
:
wait
=
False
if
"-c"
==
sys
.
argv
[
1
]:
wait
=
True
topic
=
sys
.
argv
[
2
]
else
:
topic
=
sys
.
argv
[
1
]
print
(
f
' wait=
{
wait
}
topic=
{
topic
}
'
)
consume_topic
(
topic
,
10000000
,
wait
)
\ No newline at end of file
tests/system-test/eco-system/util/restartDnodes.py
0 → 100644
浏览文件 @
ca628593
import
time
import
os
import
subprocess
import
random
import
platform
class
dnode
():
def
__init__
(
self
,
pid
,
path
):
self
.
pid
=
pid
self
.
path
=
path
# run exePath no wait finished
def
runNoWait
(
exePath
):
if
platform
.
system
().
lower
()
==
'windows'
:
cmd
=
f
"mintty -h never
{
exePath
}
"
else
:
cmd
=
f
"nohup
{
exePath
}
> /dev/null 2>&1 & "
if
os
.
system
(
cmd
)
!=
0
:
return
False
else
:
return
True
# get online dnodes
def
getDnodes
():
cmd
=
"ps aux | grep taosd | awk '{{print $2,$11,$12,$13}}'"
result
=
os
.
system
(
cmd
)
result
=
subprocess
.
check_output
(
cmd
,
shell
=
True
)
strout
=
result
.
decode
(
'utf-8'
).
split
(
"
\n
"
)
dnodes
=
[]
for
line
in
strout
:
cols
=
line
.
split
(
' '
)
if
len
(
cols
)
!=
4
:
continue
exepath
=
cols
[
1
]
if
len
(
exepath
)
<
5
:
continue
if
exepath
[
-
5
:]
!=
'taosd'
:
continue
# add to list
path
=
cols
[
1
]
+
" "
+
cols
[
2
]
+
" "
+
cols
[
3
]
dnodes
.
append
(
dnode
(
cols
[
0
],
path
))
print
(
" show dnodes cnt=%d...
\n
"
%
(
len
(
dnodes
)))
for
dn
in
dnodes
:
print
(
f
" pid=
{
dn
.
pid
}
path=
{
dn
.
path
}
"
)
return
dnodes
def
restartDnodes
(
dnodes
,
cnt
,
seconds
):
print
(
f
"start dnode cnt=
{
cnt
}
wait=
{
seconds
}
s"
)
selects
=
random
.
sample
(
dnodes
,
cnt
)
for
select
in
selects
:
print
(
f
" kill -9
{
select
.
pid
}
"
)
cmd
=
f
"kill -9
{
select
.
pid
}
"
os
.
system
(
cmd
)
print
(
f
" restart
{
select
.
path
}
"
)
if
runNoWait
(
select
.
path
)
==
False
:
print
(
f
"run
{
select
.
path
}
failed."
)
raise
Exception
(
"exe failed."
)
print
(
f
" sleep
{
seconds
}
s ..."
)
time
.
sleep
(
seconds
)
def
run
():
# kill seconds interval
killLoop
=
10
minKill
=
1
maxKill
=
10
for
i
in
range
(
killLoop
):
dnodes
=
getDnodes
()
killCnt
=
0
if
len
(
dnodes
)
>
0
:
killCnt
=
random
.
randint
(
1
,
len
(
dnodes
))
restartDnodes
(
dnodes
,
killCnt
,
random
.
randint
(
1
,
5
))
seconds
=
random
.
randint
(
minKill
,
maxKill
)
print
(
f
"----------- kill loop i=
{
i
}
killCnt=
{
killCnt
}
done. do sleep
{
seconds
}
s ...
\n
"
)
time
.
sleep
(
seconds
)
if
__name__
==
'__main__'
:
run
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录