Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
827c7bea
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
827c7bea
编写于
12月 22, 2020
作者:
L
liuyq-617
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2496] add parameter
上级
965b6b0c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
12 deletion
+43
-12
tests/pytest/concurrent_inquiry.py
tests/pytest/concurrent_inquiry.py
+43
-12
未找到文件。
tests/pytest/concurrent_inquiry.py
浏览文件 @
827c7bea
...
...
@@ -38,7 +38,7 @@ class ConcurrentInquiry:
# stableNum = 2,subtableNum = 1000,insertRows = 100):
def
__init__
(
self
,
ts
,
host
,
user
,
password
,
dbname
,
stb_prefix
,
subtb_prefix
,
n_Therads
,
r_Therads
,
probabilities
,
loop
,
stableNum
,
subtableNum
,
insertRows
):
stableNum
,
subtableNum
,
insertRows
,
mix_table
):
self
.
n_numOfTherads
=
n_Therads
self
.
r_numOfTherads
=
r_Therads
self
.
ts
=
ts
...
...
@@ -60,6 +60,7 @@ class ConcurrentInquiry:
self
.
stableNum
=
stableNum
self
.
subtableNum
=
subtableNum
self
.
insertRows
=
insertRows
self
.
mix_table
=
mix_table
def
SetThreadsNum
(
self
,
num
):
self
.
numOfTherads
=
num
...
...
@@ -195,7 +196,13 @@ class ConcurrentInquiry:
pick_func
+=
alias
sel_col_list
.
append
(
pick_func
)
sql
=
sql
+
','
.
join
(
sel_col_list
)
+
' from '
+
random
.
choice
(
self
.
stb_list
+
self
.
subtb_list
)
+
' '
#select col & func
sql
=
sql
+
','
.
join
(
sel_col_list
)
#select col & func
if
self
.
mix_table
==
0
:
sql
=
sql
+
' from '
+
random
.
choice
(
self
.
stb_list
+
self
.
subtb_list
)
+
' '
elif
self
.
mix_table
==
1
:
sql
=
sql
+
' from '
+
random
.
choice
(
self
.
subtb_list
)
+
' '
else
:
sql
=
sql
+
' from '
+
random
.
choice
(
self
.
stb_list
)
+
' '
con_func
=
[
self
.
con_where
,
self
.
con_interval
,
self
.
con_limit
,
self
.
con_group
,
self
.
con_order
,
self
.
con_fill
]
sel_con
=
random
.
sample
(
con_func
,
random
.
randint
(
0
,
len
(
con_func
)))
sel_con_list
=
[]
...
...
@@ -212,8 +219,23 @@ class ConcurrentInquiry:
col_intersection
=
[]
tag_intersection
=
[]
subtable
=
None
if
bool
(
random
.
getrandbits
(
1
)):
if
self
.
mix_table
==
0
:
if
bool
(
random
.
getrandbits
(
1
)):
subtable
=
True
tbname
=
random
.
sample
(
self
.
subtb_list
,
2
)
for
i
in
tbname
:
col_list
.
append
(
self
.
subtb_stru_list
[
self
.
subtb_list
.
index
(
i
)])
tag_list
.
append
(
self
.
subtb_stru_list
[
self
.
subtb_list
.
index
(
i
)])
col_intersection
=
list
(
set
(
col_list
[
0
]).
intersection
(
set
(
col_list
[
1
])))
tag_intersection
=
list
(
set
(
tag_list
[
0
]).
intersection
(
set
(
tag_list
[
1
])))
else
:
tbname
=
random
.
sample
(
self
.
stb_list
,
2
)
for
i
in
tbname
:
col_list
.
append
(
self
.
stb_stru_list
[
self
.
stb_list
.
index
(
i
)])
tag_list
.
append
(
self
.
stb_stru_list
[
self
.
stb_list
.
index
(
i
)])
col_intersection
=
list
(
set
(
col_list
[
0
]).
intersection
(
set
(
col_list
[
1
])))
tag_intersection
=
list
(
set
(
tag_list
[
0
]).
intersection
(
set
(
tag_list
[
1
])))
elif
self
.
mix_table
==
1
:
subtable
=
True
tbname
=
random
.
sample
(
self
.
subtb_list
,
2
)
for
i
in
tbname
:
...
...
@@ -228,12 +250,9 @@ class ConcurrentInquiry:
tag_list
.
append
(
self
.
stb_stru_list
[
self
.
stb_list
.
index
(
i
)])
col_intersection
=
list
(
set
(
col_list
[
0
]).
intersection
(
set
(
col_list
[
1
])))
tag_intersection
=
list
(
set
(
tag_list
[
0
]).
intersection
(
set
(
tag_list
[
1
])))
con_rand
=
random
.
randint
(
0
,
len
(
condition_list
))
col_rand
=
random
.
randint
(
0
,
len
(
col_list
))
tag_rand
=
random
.
randint
(
0
,
len
(
tag_list
))
sql
=
'select '
#select
sel_col_tag
=
[]
...
...
@@ -247,12 +266,16 @@ class ConcurrentInquiry:
sql
=
sql
+
' from '
+
str
(
tbname
[
0
])
+
' t1,'
+
str
(
tbname
[
1
])
+
' t2 '
#select col & func
join_section
=
None
temp
=
None
if
subtable
:
join_section
=
''
.
join
(
random
.
choices
(
col_intersection
))
sql
+=
'where t1._c0 = t2._c0 and '
+
't1.'
+
join_section
+
'=t2.'
+
join_section
temp
=
random
.
choices
(
col_intersection
)
join_section
=
temp
.
pop
()
sql
+=
'where t1._c0 = t2._c0 and '
+
't1.'
+
str
(
join_section
)
+
'=t2.'
+
str
(
join_section
)
else
:
join_section
=
''
.
join
(
random
.
choices
(
col_intersection
+
tag_intersection
))
sql
+=
'where t1._c0 = t2._c0 and '
+
't1.'
+
join_section
+
'=t2.'
+
join_section
temp
=
random
.
choices
(
col_intersection
+
tag_intersection
)
join_section
=
temp
.
pop
()
print
(
random
.
choices
(
col_intersection
))
sql
+=
'where t1._c0 = t2._c0 and '
+
't1.'
+
str
(
join_section
)
+
'=t2.'
+
str
(
join_section
)
return
sql
def
random_pick
(
self
):
...
...
@@ -516,12 +539,20 @@ parser.add_argument(
default
=
2
,
type
=
int
,
help
=
'Number of stables (default: 2)'
)
parser
.
add_argument
(
'-m'
,
'--mix-stable-subtable'
,
action
=
'store'
,
default
=
0
,
type
=
int
,
help
=
'0:stable & substable ,1:subtable ,2:stable (default: 0)'
)
args
=
parser
.
parse_args
()
q
=
ConcurrentInquiry
(
args
.
ts
,
args
.
host_name
,
args
.
user
,
args
.
password
,
args
.
db_name
,
args
.
stb_name_prefix
,
args
.
subtb_name_prefix
,
args
.
number_of_native_threads
,
args
.
number_of_rest_threads
,
args
.
probabilities
,
args
.
loop_per_thread
,
args
.
number_of_stables
,
args
.
number_of_tables
,
args
.
number_of_records
)
args
.
probabilities
,
args
.
loop_per_thread
,
args
.
number_of_stables
,
args
.
number_of_tables
,
args
.
number_of_records
,
args
.
mix_stable_subtable
)
if
args
.
create_table
:
q
.
gen_data
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录