Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3f5386e
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看板
提交
a3f5386e
编写于
4月 04, 2023
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add consumer for topic
上级
064cf2f3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
11 deletion
+45
-11
tests/system-test/0-others/walRetention.py
tests/system-test/0-others/walRetention.py
+45
-11
未找到文件。
tests/system-test/0-others/walRetention.py
浏览文件 @
a3f5386e
...
...
@@ -16,6 +16,7 @@
#
import
taos
from
taos.tmq
import
Consumer
from
util.log
import
*
from
util.cases
import
*
...
...
@@ -328,16 +329,17 @@ class TDTestCase:
if
j
%
100
==
0
:
tdSql
.
execute
(
f
"flush database
{
self
.
dbname
}
"
)
tdLog
.
info
(
" insert row cost time = %ds rows = %d"
%
(
cost
,
j
))
self
.
consume_topic
(
"topic1"
,
5
)
if
cost
>
insertTime
and
j
>
100
0
:
if
cost
>
insertTime
and
j
>
100
:
tdLog
.
info
(
" insert finished. cost time = %ds rows = %d"
%
(
cost
,
j
))
return
# create tmq
def
create_tmq
(
self
):
sql
=
f
"create topic topic1
_
{
self
.
dbname
}
as select ts, col1, concat(col12,t12) from
{
self
.
stbname
}
;"
sql
=
f
"create topic topic1 as select ts, col1, concat(col12,t12) from
{
self
.
stbname
}
;"
tdSql
.
execute
(
sql
)
sql
=
f
"create topic topic2
_
{
self
.
dbname
}
as select * from
{
self
.
stbname
}
;"
sql
=
f
"create topic topic2 as select * from
{
self
.
stbname
}
;"
tdSql
.
execute
(
sql
)
#tdLog.info(sql)
...
...
@@ -351,23 +353,53 @@ class TDTestCase:
for
dnode
in
os
.
listdir
(
self
.
projDir
):
vnodeDir
=
self
.
projDir
+
f
"
{
dnode
}
/data/vnode/"
print
(
f
"vnodeDir=
{
vnodeDir
}
"
)
if
dnode
==
"psim
"
:
if
os
.
path
.
isdir
(
vnodeDir
)
==
False
or
dnode
[:
5
]
!=
"dnode
"
:
continue
# enum all vnode
for
entry
in
os
.
listdir
(
vnodeDir
):
entryPath
=
path
.
join
(
vnodeDir
,
entry
)
if
os
.
path
.
isdir
(
entryPath
):
if
path
.
exists
(
path
.
join
(
entryPath
,
"vnode.json"
)):
try
:
vnode
=
VNode
(
i
,
entryPath
,
self
.
wal_period
,
self
.
wal_size
)
vnodes
.
append
(
vnode
)
except
:
continue
vnode
=
VNode
(
int
(
dnode
[
5
:]),
entryPath
,
self
.
wal_period
,
self
.
wal_size
)
vnodes
.
append
(
vnode
)
# do check
for
vnode
in
vnodes
:
vnode
.
check_retention
()
# consume topic
def
consume_topic
(
self
,
topic_name
,
consume_cnt
):
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
:
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
()
# test db1
def
test_db
(
self
,
dbname
,
checkTime
,
wal_period
,
wal_size_kb
):
...
...
@@ -375,7 +407,7 @@ class TDTestCase:
stable
=
"meters"
tbname
=
"d"
vgroups
=
6
count
=
2
0
count
=
1
0
# do
self
.
create_database
(
dbname
,
wal_period
,
wal_size_kb
,
vgroups
)
...
...
@@ -400,6 +432,7 @@ class TDTestCase:
tdLog
.
info
(
f
"
{
dbname
}
stop insert ..."
)
tdLog
.
info
(
f
"
{
dbname
}
test_db end."
)
# run
def
run
(
self
):
# period
...
...
@@ -408,7 +441,8 @@ class TDTestCase:
#self.test_db("db2", 5, 10*24*3600, 2*1024) # 2M size
# period + size
self
.
test_db
(
"db"
,
checkTime
=
5
*
60
,
wal_period
=
60
,
wal_size_kb
=
10
)
#self.test_db("db", checkTime = 5*60, wal_period = 60, wal_size_kb=10)
self
.
test_db
(
"db"
,
checkTime
=
1
*
60
,
wal_period
=
0
,
wal_size_kb
=
0
)
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录