Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9d3ceb1b
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看板
提交
9d3ceb1b
编写于
10月 26, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test:update test case for coverage
上级
9e65d3a2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
185 addition
and
33 deletion
+185
-33
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+55
-28
tests/system-test/2-query/avg.py
tests/system-test/2-query/avg.py
+49
-4
tests/system-test/2-query/stddev.py
tests/system-test/2-query/stddev.py
+79
-0
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+2
-1
未找到文件。
tests/system-test/2-query/Timediff.py
浏览文件 @
9d3ceb1b
...
...
@@ -16,6 +16,7 @@ class TDTestCase:
'2020-5-1 00:00:00.001002001'
]
self
.
rest_tag
=
str
(
conn
).
lower
().
split
(
'.'
)[
0
].
replace
(
"<taos"
,
""
)
self
.
db_param_precision
=
[
'ms'
,
'us'
,
'ns'
]
self
.
time_unit
=
[
'1w'
,
'1d'
,
'1h'
,
'1m'
,
'1s'
,
'1a'
,
'1u'
,
'1b'
]
self
.
error_unit
=
[
'2w'
,
'2d'
,
'2h'
,
'2m'
,
'2s'
,
'2a'
,
'2u'
,
'1c'
,
'#1'
]
...
...
@@ -101,33 +102,34 @@ class TDTestCase:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000
)))
elif
precision
.
lower
()
==
'ns'
:
self
.
check_tb_type
(
unit
,
tb_type
)
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
if
unit
.
lower
()
==
'1w'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
/
24
/
7
))
elif
unit
.
lower
()
==
'1d'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
/
24
))
elif
unit
.
lower
()
==
'1h'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
))
elif
unit
.
lower
()
==
'1m'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
))
elif
unit
.
lower
()
==
'1s'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)))
elif
unit
.
lower
()
==
'1a'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000
)
-
self
.
subtractor
*
1000
)))
elif
unit
.
lower
()
==
'1u'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
*
1000000
)))
self
.
check_tbtype
(
tb_type
)
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000000
)))
if
self
.
rest_tag
!=
'rest'
:
self
.
check_tb_type
(
unit
,
tb_type
)
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
if
unit
.
lower
()
==
'1w'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
/
24
/
7
))
elif
unit
.
lower
()
==
'1d'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
/
24
))
elif
unit
.
lower
()
==
'1h'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
/
60
))
elif
unit
.
lower
()
==
'1m'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)
/
60
))
elif
unit
.
lower
()
==
'1s'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000000
)
-
self
.
subtractor
)))
elif
unit
.
lower
()
==
'1a'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000000
)
-
self
.
subtractor
*
1000
)))
elif
unit
.
lower
()
==
'1u'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
*
1000000
)))
self
.
check_tbtype
(
tb_type
)
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000000
)))
for
unit
in
self
.
error_unit
:
if
tb_type
.
lower
()
==
'ntb'
:
tdSql
.
error
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
...
...
@@ -162,10 +164,35 @@ class TDTestCase:
date_time
=
self
.
get_time
.
time_transform
(
self
.
ts_str
,
precision
)
self
.
data_check
(
date_time
,
precision
,
'ctb'
)
self
.
data_check
(
date_time
,
precision
,
'stb'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
def
function_without_param
(
self
):
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
precision
}
"'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
for
ts
in
self
.
ts_str
:
tdSql
.
execute
(
f
'insert into
{
self
.
ctbname
}
values("
{
ts
}
",1)'
)
date_time
=
self
.
get_time
.
time_transform
(
self
.
ts_str
,
precision
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
ctbname
}
'
)
if
precision
.
lower
()
==
'ms'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000
)))
elif
precision
.
lower
()
==
'us'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000
)))
elif
precision
.
lower
()
==
'ns'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000000
)))
def
run
(
self
):
# sourcery skip: extract-duplicate-method
self
.
function_check_ntb
()
self
.
function_check_stb
()
self
.
function_without_param
()
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/2-query/avg.py
浏览文件 @
9d3ceb1b
import
taos
import
sys
import
datetime
import
inspect
import
numpy
as
np
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.sqlset
import
TDSetSql
from
util.common
import
*
class
TDTestCase
:
# updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
# "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
...
...
@@ -14,6 +13,51 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
self
.
setsql
=
TDSetSql
()
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
}
self
.
dbname
=
tdCom
.
getLongName
(
3
,
"letters"
)
self
.
row_num
=
10
self
.
ts
=
1537146000000
def
insert_data
(
self
,
column_dict
,
tbname
,
row_num
):
insert_sql
=
self
.
setsql
.
set_insertsql
(
column_dict
,
tbname
)
for
i
in
range
(
row_num
):
insert_list
=
[]
self
.
setsql
.
insert_values
(
column_dict
,
i
,
insert_sql
,
insert_list
,
self
.
ts
)
def
avg_check_unsigned
(
self
):
stbname
=
f
'
{
self
.
dbname
}
.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
tag_dict
=
{
't0'
:
'int'
}
tag_values
=
[
f
'1'
]
tdSql
.
execute
(
f
"create database if not exists
{
self
.
dbname
}
"
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
stbname
,
self
.
column_dict
,
tag_dict
))
tdSql
.
execute
(
f
"create table
{
stbname
}
_1 using
{
stbname
}
tags(
{
tag_values
[
0
]
}
)"
)
self
.
insert_data
(
self
.
column_dict
,
f
'
{
stbname
}
_1'
,
self
.
row_num
)
for
col
in
self
.
column_dict
.
keys
():
col_val_list
=
[]
if
col
.
lower
()
!=
'ts'
:
tdSql
.
query
(
f
'select
{
col
}
from
{
stbname
}
_1'
)
sum_val
=
0
for
col_val
in
tdSql
.
queryResult
:
col_val_list
.
append
(
col_val
[
0
])
col_avg
=
np
.
mean
(
col_val_list
)
tdSql
.
query
(
f
'select avg(
{
col
}
) from
{
stbname
}
_1'
)
tdSql
.
checkEqual
(
col_avg
,
tdSql
.
queryResult
[
0
][
0
])
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
prepare_datas
(
self
,
dbname
=
"db"
):
tdSql
.
execute
(
...
...
@@ -412,6 +456,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step6: avg filter query ============"
)
self
.
avg_func_filter
()
self
.
avg_check_unsigned
()
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/2-query/stddev.py
0 → 100644
浏览文件 @
9d3ceb1b
###################################################################
# 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
random
import
string
import
numpy
as
np
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
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
dbname
=
'db_test'
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
row_num
=
10
self
.
ts
=
1537146000000
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
}
def
insert_data
(
self
,
column_dict
,
tbname
,
row_num
):
insert_sql
=
self
.
setsql
.
set_insertsql
(
column_dict
,
tbname
)
for
i
in
range
(
row_num
):
insert_list
=
[]
self
.
setsql
.
insert_values
(
column_dict
,
i
,
insert_sql
,
insert_list
,
self
.
ts
)
def
stddev_check
(
self
):
stbname
=
f
'
{
self
.
dbname
}
.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
tag_dict
=
{
't0'
:
'int'
}
tag_values
=
[
f
'1'
]
tdSql
.
execute
(
f
"create database if not exists
{
self
.
dbname
}
"
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
stbname
,
self
.
column_dict
,
tag_dict
))
tdSql
.
execute
(
f
"create table
{
stbname
}
_1 using
{
stbname
}
tags(
{
tag_values
[
0
]
}
)"
)
self
.
insert_data
(
self
.
column_dict
,
f
'
{
stbname
}
_1'
,
self
.
row_num
)
for
col
in
self
.
column_dict
.
keys
():
col_val_list
=
[]
if
col
.
lower
()
!=
'ts'
:
tdSql
.
query
(
f
'select
{
col
}
from
{
stbname
}
_1'
)
for
col_val
in
tdSql
.
queryResult
:
col_val_list
.
append
(
col_val
[
0
])
col_std
=
np
.
std
(
col_val_list
)
tdSql
.
query
(
f
'select stddev(
{
col
}
) from
{
stbname
}
_1'
)
tdSql
.
checkEqual
(
col_std
,
tdSql
.
queryResult
[
0
][
0
])
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
self
.
stddev_check
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/2-query/timetruncate.py
浏览文件 @
9d3ceb1b
...
...
@@ -180,7 +180,8 @@ class TDTestCase:
date_time
=
self
.
get_time
.
time_transform
(
self
.
ts_str
,
precision
)
self
.
data_check
(
date_time
,
precision
,
'ctb'
)
self
.
data_check
(
date_time
,
precision
,
'stb'
)
def
run
(
self
):
self
.
function_check_ntb
()
self
.
function_check_stb
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录