Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17c7a8e7
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看板
未验证
提交
17c7a8e7
编写于
7月 22, 2022
作者:
H
Hui Li
提交者:
GitHub
7月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15284 from taosdata/test3.0/lihui
test: add test case for tmq
上级
b81a04f1
7f56e6f1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
46 deletion
+72
-46
tests/system-test/7-tmq/tmqCommon.py
tests/system-test/7-tmq/tmqCommon.py
+12
-0
tests/system-test/7-tmq/tmqDnodeRestart.py
tests/system-test/7-tmq/tmqDnodeRestart.py
+55
-17
tests/system-test/7-tmq/tmqDropNtb.py
tests/system-test/7-tmq/tmqDropNtb.py
+2
-14
tests/system-test/7-tmq/tmqDropStbCtb.py
tests/system-test/7-tmq/tmqDropStbCtb.py
+3
-15
未找到文件。
tests/system-test/7-tmq/tmqCommon.py
浏览文件 @
17c7a8e7
...
...
@@ -535,6 +535,18 @@ class TMQCom:
column_value_str
=
column_value_str
.
rstrip
()[:
-
1
]
insert_sql
=
f
'insert into
{
dbname
}
.
{
tbname_prefix
}{
tblIdx
+
tbname_index_start_num
}
values (
{
column_value_str
}
);'
tsql
.
execute
(
insert_sql
)
def
waitSubscriptionExit
(
self
,
tsql
,
max_wait_count
=
20
):
wait_cnt
=
0
while
(
wait_cnt
<
max_wait_count
):
tsql
.
query
(
"show subscriptions"
)
if
tsql
.
getRows
()
==
0
:
break
else
:
time
.
sleep
(
2
)
wait_cnt
+=
1
tdLog
.
info
(
"wait subscriptions exit for %d s"
%
wait_cnt
)
def
close
(
self
):
self
.
cursor
.
close
()
...
...
tests/system-test/7-tmq/tmqDnodeRestart.py
浏览文件 @
17c7a8e7
...
...
@@ -18,8 +18,8 @@ class TDTestCase:
def
__init__
(
self
):
self
.
snapshot
=
0
self
.
vgroups
=
2
self
.
ctbNum
=
100
self
.
rowsPerTbl
=
1000
0
self
.
ctbNum
=
100
0
self
.
rowsPerTbl
=
1000
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
...
...
@@ -38,8 +38,8 @@ class TDTestCase:
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
100
,
'rowsPerTbl'
:
1000
0
,
'ctbNum'
:
100
0
,
'rowsPerTbl'
:
1000
,
'batchNum'
:
100
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
3
,
...
...
@@ -83,8 +83,8 @@ class TDTestCase:
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
100
,
'rowsPerTbl'
:
1000
0
,
'ctbNum'
:
100
0
,
'rowsPerTbl'
:
1000
,
'batchNum'
:
100
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
5
,
...
...
@@ -117,13 +117,13 @@ class TDTestCase:
tdSql
.
execute
(
sqlString
)
consumerId
=
0
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
topicList
=
topicFromStb1
ifcheckdata
=
0
ifManualCommit
=
0
keyList
=
'group.id:cgrp1,\
enable.auto.commit:true,\
auto.commit.interval.ms:
5
00,\
auto.commit.interval.ms:
30
00,\
auto.offset.reset:earliest'
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
...
...
@@ -147,10 +147,46 @@ class TDTestCase:
tdSql
.
query
(
queryString
)
totalRowsFromQury
=
tdSql
.
getRows
()
tdLog
.
info
(
"act consume rows: %d,
expect consume
rows: %d"
%
(
totalConsumeRows
,
totalRowsFromQury
))
if
totalConsumeRows
!=
totalRowsFromQury
:
tdLog
.
info
(
"act consume rows: %d,
act query
rows: %d"
%
(
totalConsumeRows
,
totalRowsFromQury
))
if
not
(
totalConsumeRows
==
totalRowsFromQury
)
:
tdLog
.
exit
(
"tmq consume rows error!"
)
# tdLog.info("****************************************************************************")
# tmqCom.initConsumerTable()
# consumerId = 1
# expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2
# topicList = topicFromStb1
# ifcheckdata = 0
# ifManualCommit = 0
# keyList = 'group.id:cgrp2,\
# enable.auto.commit:true,\
# auto.commit.interval.ms:3000,\
# auto.offset.reset:earliest'
# tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
# tdLog.info("start consume processor")
# tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
# expectRows = 1
# resultList = tmqCom.selectConsumeResult(expectRows)
# totalConsumeRows = 0
# for i in range(expectRows):
# totalConsumeRows += resultList[i]
# tdSql.query(queryString)
# totalRowsFromQury = tdSql.getRows()
# tdLog.info("act consume rows: %d, act query rows: %d"%(totalConsumeRows, totalRowsFromQury))
# if not (totalConsumeRows == totalRowsFromQury):
# tdLog.exit("tmq consume rows error!")
# tdLog.info("****************************************************************************")
tmqCom
.
waitSubscriptionExit
(
tdSql
)
tdSql
.
query
(
"drop topic %s"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
...
...
@@ -168,8 +204,8 @@ class TDTestCase:
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
100
,
'rowsPerTbl'
:
1000
0
,
'ctbNum'
:
100
0
,
'rowsPerTbl'
:
1000
,
'batchNum'
:
3000
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
5
,
...
...
@@ -201,7 +237,7 @@ class TDTestCase:
tdSql
.
execute
(
sqlString
)
consumerId
=
1
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
+
100000
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
topicList
=
topicFromStb1
ifcheckdata
=
0
ifManualCommit
=
0
...
...
@@ -220,8 +256,10 @@ class TDTestCase:
tdDnodes
.
start
(
1
)
time
.
sleep
(
3
)
tdLog
.
info
(
"create some new child table and insert data "
)
tmqCom
.
insert_data_with_autoCreateTbl
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"stbName"
],
"ctb"
,
paraDict
[
"ctbNum"
],
paraDict
[
"rowsPerTbl"
],
paraDict
[
"batchNum"
])
# tdLog.info("create some new child table and insert data ")
# paraDict["batchNum"] = 1000
# paraDict["ctbPrefix"] = 'newCtb'
# tmqCom.insert_data_with_autoCreateTbl(tdSql,paraDict["dbName"],paraDict["stbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"])
tdLog
.
info
(
"insert process end, and start to check consume result"
)
expectRows
=
1
...
...
@@ -242,9 +280,9 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"======== test case 2 end ...... "
)
def
run
(
self
):
tdSql
.
prepare
()
#
tdSql.prepare()
self
.
prepareTestEnv
()
#
self.tmqCase1()
self
.
tmqCase1
()
self
.
tmqCase2
()
def
stop
(
self
):
...
...
tests/system-test/7-tmq/tmqDropNtb.py
浏览文件 @
17c7a8e7
...
...
@@ -25,18 +25,6 @@ class TDTestCase:
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
def
waitSubscriptionExit
(
self
,
max_wait_count
=
20
):
wait_cnt
=
0
while
(
wait_cnt
<
max_wait_count
):
tdSql
.
query
(
"show subscriptions"
)
if
tdSql
.
getRows
()
==
0
:
break
else
:
time
.
sleep
(
1
)
wait_cnt
+=
1
tdLog
.
info
(
"wait subscriptions exit for %d s"
%
wait_cnt
)
# drop some ntbs
def
tmqCase1
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 1: "
)
...
...
@@ -115,7 +103,7 @@ class TDTestCase:
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
self
.
waitSubscriptionExit
(
)
tmqCom
.
waitSubscriptionExit
(
tdSql
)
tdSql
.
query
(
"drop topic %s"
%
topicFromDb
)
tdLog
.
info
(
"success dorp topic: %s"
%
topicFromDb
)
...
...
@@ -208,7 +196,7 @@ class TDTestCase:
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
self
.
waitSubscriptionExit
(
)
tmqCom
.
waitSubscriptionExit
(
tdSql
)
tdSql
.
query
(
"drop topic %s"
%
topicFromDb
)
tdLog
.
info
(
"success dorp topic: %s"
%
topicFromDb
)
...
...
tests/system-test/7-tmq/tmqDropStbCtb.py
浏览文件 @
17c7a8e7
...
...
@@ -24,19 +24,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
def
waitSubscriptionExit
(
self
,
max_wait_count
=
20
):
wait_cnt
=
0
while
(
wait_cnt
<
max_wait_count
):
tdSql
.
query
(
"show subscriptions"
)
if
tdSql
.
getRows
()
==
0
:
break
else
:
time
.
sleep
(
2
)
wait_cnt
+=
1
tdLog
.
info
(
"wait subscriptions exit for %d s"
%
wait_cnt
)
def
prepareTestEnv
(
self
):
tdLog
.
printNoPrefix
(
"======== prepare test env include database, stable, ctables, and insert data: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
...
...
@@ -169,7 +157,7 @@ class TDTestCase:
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
self
.
waitSubscriptionExit
(
)
tmqCom
.
waitSubscriptionExit
(
tdSql
)
tdSql
.
query
(
"drop topic %s"
%
topicFromDb
)
tdLog
.
info
(
"success dorp topic: %s"
%
topicFromDb
)
...
...
@@ -258,7 +246,7 @@ class TDTestCase:
tdLog
.
exit
(
"tmq consume rows error with snapshot = 0!"
)
tdLog
.
info
(
"wait subscriptions exit ...."
)
self
.
waitSubscriptionExit
(
)
tmqCom
.
waitSubscriptionExit
(
tdSql
)
tdSql
.
query
(
"drop topic %s"
%
topicFromDb
)
tdLog
.
info
(
"success dorp topic: %s"
%
topicFromDb
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录