Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4fdf17c
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看板
未验证
提交
d4fdf17c
编写于
2月 22, 2023
作者:
S
sunpeng
提交者:
GitHub
2月 22, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build: delete TaosConsumer and TaosTmq from taospy (#20076) (#20091)
上级
bd79f4c2
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
645 addition
and
620 deletion
+645
-620
tests/pytest/crash_gen/crash_gen_main.py
tests/pytest/crash_gen/crash_gen_main.py
+589
-568
tests/system-test/0-others/user_manage.py
tests/system-test/0-others/user_manage.py
+56
-52
未找到文件。
tests/pytest/crash_gen/crash_gen_main.py
浏览文件 @
d4fdf17c
此差异已折叠。
点击以展开。
tests/system-test/0-others/user_manage.py
浏览文件 @
d4fdf17c
...
...
@@ -12,12 +12,13 @@
# -*- coding: utf-8 -*-
import
taos
from
util.log
import
*
from
taos.tmq
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sqlset
import
*
from
taos.tmq
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
...
...
@@ -29,7 +30,7 @@ class TDTestCase:
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
...
...
@@ -45,7 +46,7 @@ class TDTestCase:
'col13'
:
f
'nchar(
{
self
.
nchar_length
}
)'
}
self
.
tag_dict
=
{
'ts_tag'
:
'timestamp'
,
'ts_tag'
:
'timestamp'
,
't1'
:
'tinyint'
,
't2'
:
'smallint'
,
't3'
:
'int'
,
...
...
@@ -67,25 +68,28 @@ class TDTestCase:
f
'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"'
]
self
.
tbnum
=
1
def
prepare_data
(
self
):
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
def
create_user
(
self
):
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_read'
,
'jiacy1_write'
,
'jiacy1_none'
,
'jiacy0_all'
,
'jiacy0_read'
,
'jiacy0_write'
,
'jiacy0_none'
]:
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_read'
,
'jiacy1_write'
,
'jiacy1_none'
,
'jiacy0_all'
,
'jiacy0_read'
,
'jiacy0_write'
,
'jiacy0_none'
]:
if
'jiacy1'
in
user_name
.
lower
():
tdSql
.
execute
(
f
'create user
{
user_name
}
pass "123" sysinfo 1'
)
elif
'jiacy0'
in
user_name
.
lower
():
tdSql
.
execute
(
f
'create user
{
user_name
}
pass "123" sysinfo 0'
)
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_read'
,
'jiacy0_all'
,
'jiacy0_read'
]:
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_read'
,
'jiacy0_all'
,
'jiacy0_read'
]:
tdSql
.
execute
(
f
'grant read on db to
{
user_name
}
'
)
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_write'
,
'jiacy0_all'
,
'jiacy0_write'
]:
for
user_name
in
[
'jiacy1_all'
,
'jiacy1_write'
,
'jiacy0_all'
,
'jiacy0_write'
]:
tdSql
.
execute
(
f
'grant write on db to
{
user_name
}
'
)
def
user_privilege_check
(
self
):
jiacy1_read_conn
=
taos
.
connect
(
user
=
'jiacy1_read'
,
password
=
'123'
)
jiacy1_read_conn
=
taos
.
connect
(
user
=
'jiacy1_read'
,
password
=
'123'
)
sql
=
"create table ntb (ts timestamp,c0 int)"
expectErrNotOccured
=
True
try
:
...
...
@@ -94,32 +98,34 @@ class TDTestCase:
expectErrNotOccured
=
False
if
expectErrNotOccured
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
else
:
self
.
queryRows
=
0
self
.
queryCols
=
0
self
.
queryResult
=
None
tdLog
.
info
(
f
"sql:
{
sql
}
, expect error occured"
)
pass
def
drop_topic
(
self
):
jiacy1_all_conn
=
taos
.
connect
(
user
=
'jiacy1_all'
,
password
=
'123'
)
jiacy1_read_conn
=
taos
.
connect
(
user
=
'jiacy1_read'
,
password
=
'123'
)
jiacy1_write_conn
=
taos
.
connect
(
user
=
'jiacy1_write'
,
password
=
'123'
)
jiacy1_none_conn
=
taos
.
connect
(
user
=
'jiacy1_none'
,
password
=
'123'
)
jiacy0_all_conn
=
taos
.
connect
(
user
=
'jiacy0_all'
,
password
=
'123'
)
jiacy0_read_conn
=
taos
.
connect
(
user
=
'jiacy0_read'
,
password
=
'123'
)
jiacy0_write_conn
=
taos
.
connect
(
user
=
'jiacy0_write'
,
password
=
'123'
)
jiacy0_none_conn
=
taos
.
connect
(
user
=
'jiacy0_none'
,
password
=
'123'
)
jiacy1_all_conn
=
taos
.
connect
(
user
=
'jiacy1_all'
,
password
=
'123'
)
jiacy1_read_conn
=
taos
.
connect
(
user
=
'jiacy1_read'
,
password
=
'123'
)
jiacy1_write_conn
=
taos
.
connect
(
user
=
'jiacy1_write'
,
password
=
'123'
)
jiacy1_none_conn
=
taos
.
connect
(
user
=
'jiacy1_none'
,
password
=
'123'
)
jiacy0_all_conn
=
taos
.
connect
(
user
=
'jiacy0_all'
,
password
=
'123'
)
jiacy0_read_conn
=
taos
.
connect
(
user
=
'jiacy0_read'
,
password
=
'123'
)
jiacy0_write_conn
=
taos
.
connect
(
user
=
'jiacy0_write'
,
password
=
'123'
)
jiacy0_none_conn
=
taos
.
connect
(
user
=
'jiacy0_none'
,
password
=
'123'
)
tdSql
.
execute
(
'create topic root_db as select * from db.stb'
)
for
user
in
[
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
for
user
in
[
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
user
.
execute
(
f
'create topic db_jiacy as select * from db.stb'
)
user
.
execute
(
'drop topic db_jiacy'
)
for
user
in
[
jiacy1_write_conn
,
jiacy1_none_conn
,
jiacy0_write_conn
,
jiacy0_none_conn
,
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
for
user
in
[
jiacy1_write_conn
,
jiacy1_none_conn
,
jiacy0_write_conn
,
jiacy0_none_conn
,
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
sql_list
=
[]
if
user
in
[
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
if
user
in
[
jiacy1_all_conn
,
jiacy1_read_conn
,
jiacy0_all_conn
,
jiacy0_read_conn
]:
sql_list
=
[
'drop topic root_db'
]
elif
user
in
[
jiacy1_write_conn
,
jiacy1_none_conn
,
jiacy0_write_conn
,
jiacy0_none_conn
]:
sql_list
=
[
'drop topic root_db'
,
'create topic db_jiacy as select * from db.stb'
]
elif
user
in
[
jiacy1_write_conn
,
jiacy1_none_conn
,
jiacy0_write_conn
,
jiacy0_none_conn
]:
sql_list
=
[
'drop topic root_db'
,
'create topic db_jiacy as select * from db.stb'
]
for
sql
in
sql_list
:
expectErrNotOccured
=
True
try
:
...
...
@@ -128,33 +134,26 @@ class TDTestCase:
expectErrNotOccured
=
False
if
expectErrNotOccured
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
else
:
self
.
queryRows
=
0
self
.
queryCols
=
0
self
.
queryResult
=
None
tdLog
.
info
(
f
"sql:
{
sql
}
, expect error occured"
)
def
tmq_commit_cb_print
(
tmq
,
resp
,
param
=
None
):
print
(
f
"commit:
{
resp
}
, tmq:
{
tmq
}
, param:
{
param
}
"
)
def
subscribe_topic
(
self
):
print
(
"create topic"
)
tdSql
.
execute
(
'create topic db_topic as select * from db.stb'
)
tdSql
.
execute
(
'grant subscribe on db_topic to jiacy1_all'
)
print
(
"build consumer"
)
conf
=
TaosTmqConf
()
conf
.
set
(
"group.id"
,
"tg2"
)
conf
.
set
(
"td.connect.user"
,
"jiacy1_all"
)
conf
.
set
(
"td.connect.pass"
,
"123"
)
conf
.
set
(
"enable.auto.commit"
,
"true"
)
conf
.
set_auto_commit_cb
(
self
.
tmq_commit_cb_print
,
None
)
tmq
=
conf
.
new_consumer
()
tmq
=
Consumer
({
"group.id"
:
"tg2"
,
"td.connect.user"
:
"jiacy1_all"
,
"td.connect.pass"
:
"123"
,
"enable.auto.commit"
:
"true"
})
print
(
"build topic list"
)
topic_list
=
TaosTmqList
()
topic_list
.
append
(
"db_topic"
)
tmq
.
subscribe
([
"db_topic"
])
print
(
"basic consume loop"
)
tmq
.
subscribe
(
topic_list
)
sub_list
=
tmq
.
subscription
()
print
(
"subscribed topics: "
,
sub_list
)
c
=
0
l
=
0
for
i
in
range
(
10
):
...
...
@@ -163,19 +162,22 @@ class TDTestCase:
res
=
tmq
.
poll
(
10
)
print
(
f
"loop
{
l
}
"
)
l
+=
1
if
res
:
if
not
res
:
print
(
f
"received empty message at loop
{
l
}
(committed
{
c
}
)"
)
continue
if
res
.
error
():
print
(
f
"consumer error at loop
{
l
}
(committed
{
c
}
)
{
res
.
error
()
}
"
)
continue
c
+=
1
topic
=
res
.
get_topic_name
()
vg
=
res
.
get_vgroup_id
()
db
=
res
.
get_db_name
(
)
print
(
f
"topic:
{
topic
}
\n
vgroup id:
{
vg
}
\n
db:
{
db
}
"
)
topic
=
res
.
topic
()
db
=
res
.
database
()
print
(
f
"topic:
{
topic
}
\n
db:
{
db
}
"
)
for
row
in
res
:
print
(
row
)
print
(
row
.
fetchall
()
)
print
(
"* committed"
)
tmq
.
commit
(
res
)
else
:
print
(
f
"received empty message at loop
{
l
}
(committed
{
c
}
)"
)
pass
def
run
(
self
):
tdSql
.
prepare
()
...
...
@@ -184,9 +186,11 @@ class TDTestCase:
self
.
drop_topic
()
self
.
user_privilege_check
()
self
.
subscribe_topic
()
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录