Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e900eb0
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看板
未验证
提交
4e900eb0
编写于
7月 28, 2023
作者:
W
wade zhang
提交者:
GitHub
7月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22225 from taosdata/test/TS-3717-3.0
test : add batch create topic and batch consume topic
上级
9c7b5308
a143618e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
218 addition
and
0 deletion
+218
-0
tests/system-test/eco-system/manager/cmul.py
tests/system-test/eco-system/manager/cmul.py
+104
-0
tests/system-test/eco-system/manager/mul.py
tests/system-test/eco-system/manager/mul.py
+114
-0
未找到文件。
tests/system-test/eco-system/manager/cmul.py
0 → 100644
浏览文件 @
4e900eb0
###################################################################
# 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
import
random
from
datetime
import
date
from
datetime
import
datetime
from
datetime
import
timedelta
from
os
import
path
topicName
=
"topic"
topicNum
=
100
# consume topic
def
consume_topic
(
topic_name
,
group
,
consume_cnt
,
index
,
wait
):
consumer
=
Consumer
(
{
"group.id"
:
group
,
"td.connect.user"
:
"root"
,
"td.connect.pass"
:
"taosdata"
,
"enable.auto.commit"
:
"true"
,
}
)
print
(
f
"start consumer topic:
{
topic_name
}
group=
{
group
}
index=
{
index
}
..."
)
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
:
datas
=
block
.
fetchall
()
data
=
datas
[
0
][:
50
]
print
(
f
"
{
topic_name
}
_
{
group
}
_
{
index
}
{
cnt
}
{
data
}
"
)
finally
:
consumer
.
unsubscribe
()
consumer
.
close
()
def
consumerThread
(
index
):
global
topicName
,
topicNum
print
(
f
' thread
{
index
}
start...'
)
while
True
:
idx
=
random
.
randint
(
0
,
topicNum
-
1
)
name
=
f
"
{
topicName
}{
idx
}
"
group
=
f
"group_
{
index
}
_
{
idx
}
"
consume_topic
(
name
,
group
,
100
,
index
,
True
)
if
__name__
==
"__main__"
:
print
(
sys
.
argv
)
threadCnt
=
10
if
len
(
sys
.
argv
)
==
1
:
threadCnt
=
int
(
sys
.
argv
[
1
])
threads
=
[]
print
(
f
'consumer with
{
threadCnt
}
threads...'
)
for
i
in
range
(
threadCnt
):
x
=
threading
.
Thread
(
target
=
consumerThread
,
args
=
(
i
,))
x
.
start
()
threads
.
append
(
x
)
# wait
for
i
,
thread
in
enumerate
(
threads
):
thread
.
join
()
print
(
f
'join thread
{
i
}
end.'
)
tests/system-test/eco-system/manager/mul.py
0 → 100644
浏览文件 @
4e900eb0
###################################################################
# 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 -*-
import
os
import
sys
import
random
import
time
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.sqlset
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
())
self
.
setsql
=
TDSetSql
()
# prepareEnv
def
prepareEnv
(
self
):
self
.
dbName
=
"mullevel"
self
.
stbName
=
"meters"
self
.
topicName
=
"topic"
self
.
topicNum
=
100
self
.
loop
=
50000
sql
=
f
"use
{
self
.
dbName
}
"
tdSql
.
execute
(
sql
)
# generate topic sql
self
.
sqls
=
[
f
"select * from
{
self
.
stbName
}
"
,
f
"select * from
{
self
.
stbName
}
where ui < 200"
,
f
"select * from
{
self
.
stbName
}
where fc > 20.1"
,
f
"select * from
{
self
.
stbName
}
where nch like '%%a%%'"
,
f
"select * from
{
self
.
stbName
}
where fc > 20.1"
,
f
"select lower(bin) from
{
self
.
stbName
}
where length(bin) < 10;"
,
f
"select upper(bin) from
{
self
.
stbName
}
where length(nch) > 10;"
,
f
"select upper(bin) from
{
self
.
stbName
}
where ti > 10 or ic < 40;"
,
f
"select * from
{
self
.
stbName
}
where ic < 100 "
]
# prepareEnv
def
createTopics
(
self
):
for
i
in
range
(
self
.
topicNum
):
topicName
=
f
"
{
self
.
topicName
}{
i
}
"
sql
=
random
.
choice
(
self
.
sqls
)
createSql
=
f
"create topic if not exists
{
topicName
}
as
{
sql
}
"
try
:
tdSql
.
execute
(
createSql
,
3
,
True
)
except
:
tdLog
.
info
(
f
" create topic
{
topicName
}
failed."
)
# random del topic
def
managerTopics
(
self
):
for
i
in
range
(
self
.
loop
):
tdLog
.
info
(
f
"start modify loop=
{
i
}
"
)
idx
=
random
.
randint
(
0
,
self
.
topicNum
-
1
)
# delete
topicName
=
f
"
{
self
.
topicName
}{
idx
}
"
sql
=
f
"drop topic if exist
{
topicName
}
"
try
:
tdSql
.
execute
(
sql
,
3
,
True
)
except
:
tdLog
.
info
(
f
" drop topic
{
topicName
}
failed."
)
# create topic
sql
=
random
.
choice
(
self
.
sqls
)
createSql
=
f
"create topic if not exists
{
topicName
}
as
{
sql
}
"
try
:
tdSql
.
execute
(
createSql
,
3
,
True
)
except
:
tdLog
.
info
(
f
" create topic
{
topicName
}
failed."
)
seconds
=
[
0.1
,
0.5
,
3
,
2.5
,
1.5
,
0.4
,
5.2
,
2.6
,
0.4
,
0.2
]
time
.
sleep
(
random
.
choice
(
seconds
))
# run
def
run
(
self
):
# prepare env
self
.
prepareEnv
()
# create topic
self
.
createTopics
()
# modify topic
self
.
managerTopics
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录