Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4639a04c
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看板
提交
4639a04c
编写于
6月 23, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test case
上级
98501b01
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
119 deletion
+117
-119
tests/system-test/2-query/To_unixtimestamp.py
tests/system-test/2-query/To_unixtimestamp.py
+30
-0
tests/system-test/2-query/timezone.py
tests/system-test/2-query/timezone.py
+87
-119
未找到文件。
tests/system-test/2-query/To_unixtimestamp.py
浏览文件 @
4639a04c
...
...
@@ -12,7 +12,37 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
# name of normal table
self
.
ntbname
=
'ntb'
# name of stable
self
.
stbname
=
'stb'
# structure of column
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'c1'
:
'int'
,
'c2'
:
'float'
,
'c3'
:
'binary(20)'
,
'c4'
:
'nchar(20)'
}
# structure of tag
self
.
tag_dict
=
{
't0'
:
'int'
}
# number of child tables
self
.
tbnum
=
2
# values of tag,the number of values should equal to tbnum
self
.
tag_values
=
[
f
'10'
,
f
'100'
]
# values of rows, structure should be same as column
self
.
values_list
=
[
f
'now,10,99.99,"2020-1-1 00:00:00"'
,
f
'today(),100,11.111,22.222222'
]
self
.
error_param
=
[
1
,
'now()'
]
def
run
(
self
):
# sourcery skip: extract-duplicate-method
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create tables=========="
)
...
...
tests/system-test/2-query/timezone.py
浏览文件 @
4639a04c
...
...
@@ -2,7 +2,7 @@
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.sqlset
import
*
import
platform
import
os
if
platform
.
system
().
lower
()
==
'windows'
:
...
...
@@ -14,10 +14,39 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
arithmetic_operators
=
[
'+'
,
'-'
,
'*'
,
'/'
]
self
.
arithmetic_values
=
[
0
,
1
,
100
,
15.5
]
# name of normal table
self
.
ntbname
=
'ntb'
# name of stable
self
.
stbname
=
'stb'
# structure of column
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'c1'
:
'int'
,
'c2'
:
'float'
,
'c3'
:
'double'
}
# structure of tag
self
.
tag_dict
=
{
't0'
:
'int'
}
# number of child tables
self
.
tbnum
=
2
# values of tag,the number of values should equal to tbnum
self
.
tag_values
=
[
f
'10'
,
f
'100'
]
# values of rows, structure should be same as column
self
.
values_list
=
[
f
'now,10,99.99,11.111111'
,
f
'today(),100,11.111,22.222222'
def
run
(
self
):
# sourcery skip: extract-duplicate-method
tdSql
.
prepare
()
# get system timezone
]
self
.
error_param
=
[
1
,
'now()'
]
def
get_system_timezone
(
self
):
if
platform
.
system
().
lower
()
==
'windows'
:
time_zone_1
=
tzlocal
.
get_localzone_name
()
time_zone_2
=
time
.
strftime
(
'(UTC, %z)'
)
...
...
@@ -32,122 +61,61 @@ class TDTestCase:
time_zone_2
=
os
.
popen
(
'date "+(%Z, %z)"'
).
read
().
strip
()
time_zone
=
time_zone_1
+
" "
+
time_zone_2
print
(
"expected time zone: "
+
time_zone
)
tdLog
.
printNoPrefix
(
"==========step1:create tables=========="
)
tdSql
.
execute
(
'''create table if not exists ntb
(ts timestamp, c1 int, c2 float,c3 double)
'''
)
tdSql
.
execute
(
'''create table if not exists stb
(ts timestamp, c1 int, c2 float,c3 double) tags(t0 int)
'''
)
tdSql
.
execute
(
'''create table if not exists stb_1 using stb tags(100)
'''
)
tdLog
.
printNoPrefix
(
"==========step2:insert data=========="
)
tdSql
.
execute
(
"insert into ntb values(now,10,99.99,11.111111)(today(),100,11.111,22.222222)"
)
tdSql
.
execute
(
"insert into stb_1 values(now,111,99.99,11.111111)(today(),1,11.111,22.222222)"
)
tdLog
.
printNoPrefix
(
"==========step3:query data=========="
)
return
time_zone
def
tb_type_check
(
self
,
tb_type
):
if
tb_type
in
[
'normal_table'
,
'child_table'
]:
tdSql
.
checkRows
(
len
(
self
.
values_list
))
elif
tb_type
==
'stable'
:
tdSql
.
checkRows
(
len
(
self
.
values_list
*
self
.
tbnum
))
def
data_check
(
self
,
timezone
,
tbname
,
tb_type
):
tdSql
.
query
(
f
"select timezone() from
{
tbname
}
"
)
self
.
tb_type_check
(
tb_type
)
tdSql
.
checkData
(
0
,
0
,
timezone
)
for
symbol
in
self
.
arithmetic_operators
:
tdSql
.
query
(
f
"select timezone()
{
symbol
}
null from
{
tbname
}
"
)
self
.
tb_type_check
(
tb_type
)
tdSql
.
checkData
(
0
,
0
,
None
)
for
i
in
self
.
arithmetic_values
:
for
symbol
in
self
.
arithmetic_operators
:
tdSql
.
query
(
f
"select timezone()
{
symbol
}{
i
}
from
{
tbname
}
"
)
self
.
tb_type_check
(
tb_type
)
if
symbol
==
'+'
:
tdSql
.
checkData
(
0
,
0
,
i
)
elif
symbol
==
'-'
:
tdSql
.
checkData
(
0
,
0
,
-
i
)
elif
symbol
in
[
'*'
,
'/'
,
'%'
]:
if
i
==
0
and
symbol
==
'/'
:
tdSql
.
checkData
(
0
,
0
,
None
)
else
:
tdSql
.
checkData
(
0
,
0
,
0
)
for
param
in
self
.
error_param
:
tdSql
.
error
(
f
'select timezone(
{
param
}
) from
{
tbname
}
'
)
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
(
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
(
timezone
,
self
.
ntbname
,
'normal_table'
)
tdSql
.
execute
(
'drop database db'
)
def
timezone_check_stb
(
self
,
timezone
):
tdSql
.
prepare
()
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
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
self
.
data_check
(
timezone
,
self
.
stbname
,
'stable'
)
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
timezone
,
f
'
{
self
.
stbname
}
_
{
i
}
'
,
'child_table'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
timezone
=
self
.
get_system_timezone
()
self
.
timezone_check_ntb
(
timezone
)
self
.
timezone_check_stb
(
timezone
)
tdSql
.
query
(
"select timezone() from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from db.stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from db.stb_1 "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
error
(
"select timezone(1) from stb"
)
tdSql
.
error
(
"select timezone(1) from db.stb"
)
tdSql
.
error
(
"select timezone(1) from ntb"
)
tdSql
.
error
(
"select timezone(1) from db.ntb"
)
tdSql
.
error
(
"select timezone(1) from stb_1"
)
tdSql
.
error
(
"select timezone(1) from db.stb_1"
)
tdSql
.
error
(
"select timezone(now()) from stb"
)
tdSql
.
error
(
"select timezone(now()) from db.stb"
)
tdSql
.
query
(
f
"select * from ntb where timezone()='
{
time_zone
}
'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1.5 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1.5 from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()-100 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()*100 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()/10 from ntb"
)
# tdSql.query("select timezone()/0 from ntb")
tdSql
.
query
(
"select timezone()+null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
# tdSql.query("select timezone()")
tdSql
.
query
(
"select timezone()+null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()+null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录