Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6297055f
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6297055f
编写于
6月 17, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test case
上级
78307f91
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
128 addition
and
20 deletion
+128
-20
tests/system-test/2-query/first.py
tests/system-test/2-query/first.py
+51
-20
tests/system-test/2-query/hyperloglog.py
tests/system-test/2-query/hyperloglog.py
+77
-0
未找到文件。
tests/system-test/2-query/first.py
浏览文件 @
6297055f
...
...
@@ -48,12 +48,26 @@ class TDTestCase:
return
""
.
join
(
random
.
choices
(
population
,
k
=
length
))
def
first_check_base
(
self
):
tdSql
.
prepare
()
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
}
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table stb_1 using stb tags('beijing')"
)
tdSql
.
execute
(
"insert into stb_1(ts) values(%d)"
%
(
self
.
ts
-
1
))
column_list
=
[
'col1'
,
'col2'
,
'col3'
,
'col4'
,
'col5'
,
'col6'
,
'col7'
,
'col8'
,
'col9'
,
'col10'
,
'col11'
,
'col12'
,
'col13'
]
for
i
in
[
'stb_1'
,
'db.stb_1'
,
'stb_1'
,
'db.stb_1'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -63,31 +77,32 @@ class TDTestCase:
# tdSql.query(f"select first(*) from {i}")
# tdSql.checkRows(1)
# tdSql.checkData(0, 1, None)
for
i
in
range
(
1
,
14
)
:
for
i
in
column_list
:
for
j
in
[
'stb_1'
,
'db.stb_1'
,
'stb_1'
,
'db.stb_1'
]:
tdSql
.
query
(
f
"select first(
col
{
i
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select first(
{
i
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
for
i
in
range
(
1
,
14
):
for
k
,
v
in
column_dict
.
items
(
):
for
j
in
[
'stb_1'
,
'db.stb_1'
,
'stb'
,
'db.stb'
]:
tdSql
.
query
(
f
"select first(
col
{
i
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select first(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
if
i
>=
1
and
i
<
9
:
if
v
==
'tinyint'
or
v
==
'smallint'
or
v
==
'int'
or
v
==
'bigint'
or
v
==
'tinyint unsigned'
or
v
==
'smallint unsigned'
\
or
v
==
'int unsigned'
or
v
==
'bigint unsigned'
:
tdSql
.
checkData
(
0
,
0
,
1
)
# float,double
elif
i
>=
9
and
i
<
11
:
elif
v
==
'float'
or
v
==
'double'
:
tdSql
.
checkData
(
0
,
0
,
0.1
)
# bool
elif
i
==
11
:
elif
v
==
'bool'
:
tdSql
.
checkData
(
0
,
0
,
False
)
# binary
elif
i
==
12
:
elif
'binary'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
binary_str
}
1'
)
# nchar
elif
i
==
13
:
elif
'nchar'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}
1'
)
#!bug TD-16569
tdSql
.
query
(
"select first(*),last(*) from stb where ts < 23 interval(1s)"
)
...
...
@@ -98,6 +113,21 @@ class TDTestCase:
dbname
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
stbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
child_table_num
=
20
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
}
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups 4"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
# build 20 child tables,every table insert 10 rows
...
...
@@ -131,28 +161,29 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
j
+
i
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
0.1
,
j
+
0.1
,
j
%
2
,
j
+
1
,
j
+
1
))
for
i
in
range
(
1
,
14
):
for
k
,
v
in
column_dict
.
items
(
):
for
j
in
[
f
'
{
stbname
}
_
{
i
}
'
,
f
'
{
dbname
}
.
{
stbname
}
_
{
i
}
'
,
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
tdSql
.
query
(
f
"select first(
col
{
i
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select first(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
if
i
>=
1
and
i
<
9
:
if
v
==
'tinyint'
or
v
==
'smallint'
or
v
==
'int'
or
v
==
'bigint'
or
v
==
'tinyint unsigned'
or
v
==
'smallint unsigned'
\
or
v
==
'int unsigned'
or
v
==
'bigint unsigned'
:
tdSql
.
checkData
(
0
,
0
,
1
)
# float,double
elif
i
>=
9
and
i
<
11
:
elif
v
==
'float'
or
v
==
'double'
:
tdSql
.
checkData
(
0
,
0
,
0.1
)
# bool
elif
i
==
11
:
elif
v
==
'bool'
:
tdSql
.
checkData
(
0
,
0
,
False
)
# binary
elif
i
==
12
:
elif
'binary'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
binary_str
}
1'
)
# nchar
elif
i
==
13
:
elif
'nchar'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}
1'
)
#!bug TD-16569
tdSql
.
query
(
f
"select first(*),last(*) from
{
stbname
}
where ts < 23 interval(1s)"
)
tdSql
.
checkRows
(
0
)
#
tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)")
#
tdSql.checkRows(0)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
...
...
tests/system-test/2-query/hyperloglog.py
浏览文件 @
6297055f
...
...
@@ -214,6 +214,79 @@ class TDTestCase:
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags (
{
i
+
1
}
)'
)
{
i
%
32767
},
{
i
%
127
},
{
i
*
1.11111
},
{
i
*
1000.1111
},
{
i
%
2
}
def
__create_stable
(
self
,
stbname
=
'stb'
,
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
},
tag_dict
=
{
'ts_tag'
:
'timestamp'
,
't1'
:
'tinyint'
,
't2'
:
'smallint'
,
't3'
:
'int'
,
't4'
:
'bigint'
,
't5'
:
'tinyint unsigned'
,
't6'
:
'smallint unsigned'
,
't7'
:
'int unsigned'
,
't8'
:
'bigint unsigned'
,
't9'
:
'float'
,
't10'
:
'double'
,
't11'
:
'bool'
,
't12'
:
'binary(20)'
,
't13'
:
'nchar(20)'
}):
column_sql
=
''
tag_sql
=
''
for
k
,
v
in
column_dict
.
items
():
column_sql
+=
f
"
{
k
}
{
v
}
,"
for
k
,
v
in
tag_dict
.
items
():
tag_sql
+=
f
"
{
k
}
{
v
}
,"
tdSql
.
execute
(
f
'create table is not exists
{
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
)
def
__insert_data
(
self
):
pass
def
__hyperloglog_check_distribute
(
self
):
dbname
=
"dbtest"
stbname
=
"stb"
childtable_num
=
20
vgroups_num
=
4
row_num
=
10
ts
=
1537146000000
binary_str
=
'taosdata'
nchar_str
=
'涛思数据'
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
}
tag_dict
=
{
'loc'
:
'nchar(20)'
}
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups
{
vgroups_num
}
"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
self
.
__create_stable
(
stbname
,
column_dict
,
tag_dict
)
for
i
in
range
(
childtable_num
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
query
(
'show tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
vgroup_list_set
=
set
(
vgroup_list
)
for
i
in
vgroup_list_set
:
vgroups_num
=
vgroup_list
.
count
(
i
)
if
vgroups_num
>=
2
:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
else
:
tdLog
.
exit
(
'This scene does not meet the requirements with {vgroups_num} vgroup!
\n
'
)
for
i
in
range
(
row_num
):
tdSql
.
execute
(
f
"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
binary_str
}
%d', '
{
nchar_str
}
%d')"
%
(
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
for
k
in
column_dict
.
keys
():
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
stbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
stbname
}
group by
{
k
}
"
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
__insert_data
(
self
,
rows
):
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
...
...
@@ -311,6 +384,10 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step4:after wal, all check again "
)
self
.
all_test
()
tdLog
.
printNoPrefix
(
"==========step5: distribute scene check"
)
self
.
__hyperloglog_check_distribute
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录