Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d0126422
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
d0126422
编写于
8月 10, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test case
上级
75511b17
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
310 addition
and
240 deletion
+310
-240
tests/system-test/2-query/Now.py
tests/system-test/2-query/Now.py
+10
-9
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+10
-9
tests/system-test/2-query/To_iso8601.py
tests/system-test/2-query/To_iso8601.py
+11
-9
tests/system-test/2-query/last.py
tests/system-test/2-query/last.py
+14
-27
tests/system-test/2-query/percentile.py
tests/system-test/2-query/percentile.py
+8
-7
tests/system-test/2-query/stateduration.py
tests/system-test/2-query/stateduration.py
+242
-165
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+10
-9
tests/system-test/2-query/timezone.py
tests/system-test/2-query/timezone.py
+5
-5
未找到文件。
tests/system-test/2-query/Now.py
浏览文件 @
d0126422
...
...
@@ -9,12 +9,13 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
()
,
True
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
dbname
=
'db'
# name of normal table
self
.
ntbname
=
'
ntb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.
ntb'
# name of stable
self
.
stbname
=
'
stb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.
stb'
# structure of column
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
...
...
@@ -72,19 +73,19 @@ class TDTestCase:
def
now_check_ntb
(
self
):
for
time_unit
in
self
.
db_percision
:
tdSql
.
execute
(
f
'create database
db
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
value
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
value
}
)'
)
self
.
data_check
(
self
.
ntbname
,
'normal table'
)
tdSql
.
execute
(
'drop database db
'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
now_check_stb
(
self
):
for
time_unit
in
self
.
db_percision
:
tdSql
.
execute
(
f
'create database
db
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
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_values
[
0
]
}
)"
)
...
...
@@ -93,7 +94,7 @@ class TDTestCase:
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
f
'
{
self
.
stbname
}
_
{
i
}
'
,
'child table'
)
self
.
data_check
(
self
.
stbname
,
'stable'
)
tdSql
.
execute
(
'drop database db
'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
self
.
now_check_ntb
()
...
...
tests/system-test/2-query/Timediff.py
浏览文件 @
d0126422
...
...
@@ -19,9 +19,10 @@ class TDTestCase:
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'
]
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
ctbname
=
'ctb'
self
.
dbname
=
'db'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
self
.
subtractor
=
1
# unit:s
def
check_tbtype
(
self
,
tb_type
):
if
tb_type
.
lower
()
==
'ntb'
:
...
...
@@ -139,9 +140,9 @@ class TDTestCase:
tdSql
.
error
(
f
'select timediff(c0,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
def
function_check_ntb
(
self
):
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
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
.
ntbname
}
(ts timestamp,c0 int)'
)
for
ts
in
self
.
ts_str
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
...
...
@@ -151,9 +152,9 @@ class TDTestCase:
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
def
function_check_stb
(
self
):
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
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
:
...
...
tests/system-test/2-query/To_iso8601.py
浏览文件 @
d0126422
...
...
@@ -15,16 +15,18 @@ class TDTestCase:
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1640966400000
# 2022-1-1 00:00:00.000
self
.
dbname
=
'db'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
def
check_customize_param_ms
(
self
):
time_zone
=
time
.
strftime
(
'%z'
)
tdSql
.
execute
(
'create database db1
precision "ms"'
)
tdSql
.
execute
(
'use db1
'
)
tdSql
.
execute
(
'create table if not exists ntb
(ts timestamp, c1 int, c2 timestamp)'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "ms"'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table if not exists
{
self
.
ntbname
}
(ts timestamp, c1 int, c2 timestamp)'
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into ntb values(%d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
self
.
ts
+
i
))
tdSql
.
query
(
'select to_iso8601(ts) from ntb'
)
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
}
,
{
i
+
1
}
,
{
self
.
ts
+
i
}
)"
)
tdSql
.
query
(
f
'select to_iso8601(ts) from
{
self
.
ntbname
}
'
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
time_zone
}
'
)
...
...
@@ -36,17 +38,17 @@ class TDTestCase:
'-00:00'
,
'-01:00'
,
'-02:00'
,
'-03:00'
,
'-04:00'
,
'-05:00'
,
'-06:00'
,
'-07:00'
,
'-08:00'
,
'-09:00'
,
'-10:00'
,
'-11:00'
,
'-12:00'
,
\
'z'
,
'Z'
]
for
j
in
timezone_list
:
tdSql
.
query
(
f
'select to_iso8601(ts,"
{
j
}
") from
ntb
'
)
tdSql
.
query
(
f
'select to_iso8601(ts,"
{
j
}
") from
{
self
.
ntbname
}
'
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
j
}
'
)
error_param_list
=
[
0
,
100.5
,
'a'
,
'!'
]
for
i
in
error_param_list
:
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
ntb
'
)
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
{
self
.
ntbname
}
'
)
#! bug TD-16372:对于错误的时区,缺少校验
error_timezone_param
=
[
'+13'
,
'-13'
,
'+1300'
,
'-1300'
,
'+0001'
,
'-0001'
,
'-0330'
,
'-0530'
]
for
i
in
error_timezone_param
:
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
ntb
'
)
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
{
self
.
ntbname
}
'
)
def
check_base_function
(
self
):
tdSql
.
prepare
()
...
...
tests/system-test/2-query/last.py
浏览文件 @
d0126422
...
...
@@ -37,7 +37,7 @@ class TDTestCase:
def
last_check_stb_tb_base
(
self
):
tdSql
.
prepare
()
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
stbname
=
f
'db.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
...
...
@@ -61,7 +61,7 @@ class TDTestCase:
tdSql
.
execute
(
f
"create table
{
stbname
}
_1 using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_1(ts) values(%d)"
%
(
self
.
ts
-
1
))
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'db.
{
stbname
}
_1'
]:
for
i
in
[
f
'
{
stbname
}
_1'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
...
...
@@ -71,7 +71,7 @@ class TDTestCase:
# tdSql.checkRows(1)
# tdSql.checkData(0, 1, None)
for
i
in
column_dict
.
keys
():
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
) from
{
stbname
}
_1 group by
{
list
(
column_dict
.
keys
())[
-
1
]
}
"
)
...
...
@@ -79,12 +79,12 @@ class TDTestCase:
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
"insert into
{
stbname
}
_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
[
f
'
{
stbname
}
_1'
,
f
'db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
...
@@ -103,7 +103,7 @@ class TDTestCase:
# nchar
elif
'nchar'
in
v
.
lower
():
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}{
self
.
rowNum
}
'
)
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
,
{
list
(
column_dict
.
keys
())[
1
]
}
,
{
list
(
column_dict
.
keys
())[
2
]
}
) from
{
stbname
}
_1"
)
tdSql
.
checkData
(
0
,
2
,
10
)
...
...
@@ -113,7 +113,7 @@ class TDTestCase:
def
last_check_ntb_base
(
self
):
tdSql
.
prepare
()
ntbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
ntbname
=
f
'db.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
...
...
@@ -135,11 +135,8 @@ class TDTestCase:
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
f
"select last(*) from db.
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
for
i
in
column_dict
.
keys
():
for
j
in
[
f
'
{
ntbname
}
'
,
f
'db.
{
ntbname
}
'
]:
for
j
in
[
f
'
{
ntbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
...
...
@@ -148,11 +145,8 @@ class TDTestCase:
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
f
"select last(*) from db.
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
ntbname
}
'
,
f
'db.
{
ntbname
}
'
]:
for
j
in
[
f
'
{
ntbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
...
@@ -178,8 +172,8 @@ class TDTestCase:
def
last_check_stb_distribute
(
self
):
# prepare data for vgroup 4
dbname
=
tdCom
.
getLongName
(
10
,
"letters"
)
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
vgroup_num
=
4
stbname
=
f
'
{
dbname
}
.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
vgroup_num
=
2
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
...
...
@@ -208,11 +202,7 @@ class TDTestCase:
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
# for i in [f'{stbname}', f'{dbname}.{stbname}']:
# tdSql.query(f"select last(*) from {i}")
# tdSql.checkRows(1)
# tdSql.checkData(0, 1, None)
tdSql
.
query
(
'show tables'
)
tdSql
.
query
(
f
'show
{
dbname
}
.tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
...
...
@@ -222,20 +212,17 @@ class TDTestCase:
if
vgroups_num
>=
2
:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
# else:
# tdLog.exit(
# f'This scene does not meet the requirements with {vgroups_num} vgroup!\n')
for
i
in
range
(
self
.
tbnum
):
for
j
in
range
(
self
.
rowNum
):
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
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
...
tests/system-test/2-query/percentile.py
浏览文件 @
d0126422
...
...
@@ -23,13 +23,14 @@ from util.sqlset import TDSetSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
()
,
True
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
dbname
=
'db'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
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
=
{
...
...
@@ -100,10 +101,9 @@ class TDTestCase:
return
intData
,
floatData
def
check_tags
(
self
,
tags
,
param
,
num
,
value
):
tdSql
.
query
(
f
'select percentile(
{
tags
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
num
}
'
)
print
(
tdSql
.
queryResult
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
def
function_check_ntb
(
self
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
intData
,
floatData
=
self
.
insert_data
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
for
k
,
v
in
self
.
column_dict
.
items
():
...
...
@@ -116,8 +116,9 @@ class TDTestCase:
else
:
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
param
))
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
function_check_ctb
(
self
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
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_values
[
0
]
}
)"
)
...
...
@@ -143,7 +144,7 @@ class TDTestCase:
data_num
=
tdSql
.
queryResult
[
0
][
0
]
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkData
(
0
,
0
,
data_num
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
self
.
function_check_ntb
()
self
.
function_check_ctb
()
...
...
tests/system-test/2-query/stateduration.py
浏览文件 @
d0126422
此差异已折叠。
点击以展开。
tests/system-test/2-query/timetruncate.py
浏览文件 @
d0126422
...
...
@@ -21,9 +21,10 @@ class TDTestCase:
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'
]
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
ctbname
=
'ctb'
self
.
dbname
=
'db'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
def
check_ms_timestamp
(
self
,
unit
,
date_time
):
if
unit
.
lower
()
==
'1a'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
...
...
@@ -140,9 +141,9 @@ class TDTestCase:
tdSql
.
error
(
f
'select timetruncate(ts,
{
unit
}
) from
{
self
.
stbname
}
'
)
def
function_check_ntb
(
self
):
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
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
.
ntbname
}
(ts timestamp,c0 int)'
)
for
ts
in
self
.
ts_str
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
...
...
@@ -150,9 +151,9 @@ class TDTestCase:
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
def
function_check_stb
(
self
):
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
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
:
...
...
tests/system-test/2-query/timezone.py
浏览文件 @
d0126422
...
...
@@ -17,10 +17,11 @@ class TDTestCase:
self
.
setsql
=
TDSetSql
()
self
.
arithmetic_operators
=
[
'+'
,
'-'
,
'*'
,
'/'
]
self
.
arithmetic_values
=
[
0
,
1
,
100
,
15.5
]
self
.
dbname
=
'db'
# name of normal table
self
.
ntbname
=
'
ntb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.
ntb'
# name of stable
self
.
stbname
=
'
stb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.
stb'
# structure of column
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
...
...
@@ -60,7 +61,6 @@ class TDTestCase:
time_zone_1
=
os
.
popen
(
'ls -l /etc/localtime|awk -F/
\'
{print $(NF-1) "/" $NF}
\'
'
).
read
().
strip
()
time_zone_2
=
os
.
popen
(
'date "+(%Z, %z)"'
).
read
().
strip
()
time_zone
=
time_zone_1
+
" "
+
time_zone_2
print
(
"expected time zone: "
+
time_zone
)
return
time_zone
def
tb_type_check
(
self
,
tb_type
):
...
...
@@ -94,7 +94,7 @@ class TDTestCase:
tdSql
.
query
(
f
"select * from
{
tbname
}
where timezone()='
{
timezone
}
'"
)
self
.
tb_type_check
(
tb_type
)
def
timezone_check_ntb
(
self
,
timezone
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
value
in
self
.
values_list
:
tdSql
.
execute
(
...
...
@@ -102,7 +102,7 @@ class TDTestCase:
self
.
data_check
(
timezone
,
self
.
ntbname
,
'normal_table'
)
tdSql
.
execute
(
'drop database db'
)
def
timezone_check_stb
(
self
,
timezone
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
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 if not exists
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
i
]
}
)'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录