Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4cf36c00
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看板
未验证
提交
4cf36c00
编写于
6月 24, 2022
作者:
C
cpwu
提交者:
GitHub
6月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14208 from taosdata/3.0test/jcy
test:update test case
上级
f7ece71f
b2537cb4
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
208 addition
and
552 deletion
+208
-552
tests/pytest/util/sqlset.py
tests/pytest/util/sqlset.py
+1
-1
tests/system-test/2-query/Now.py
tests/system-test/2-query/Now.py
+80
-422
tests/system-test/2-query/To_unixtimestamp.py
tests/system-test/2-query/To_unixtimestamp.py
+30
-0
tests/system-test/2-query/first.py
tests/system-test/2-query/first.py
+10
-10
tests/system-test/2-query/timezone.py
tests/system-test/2-query/timezone.py
+87
-119
未找到文件。
tests/pytest/util/sqlset.py
浏览文件 @
4cf36c00
...
...
@@ -15,7 +15,7 @@ from util.sql import tdSql
class
TDSetSql
:
def
init
(
self
,
conn
,
logSql
):
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
stbname
=
'stb'
def
set_create_normaltable_sql
(
self
,
ntbname
=
'ntb'
,
...
...
tests/system-test/2-query/Now.py
浏览文件 @
4cf36c00
此差异已折叠。
点击以展开。
tests/system-test/2-query/To_unixtimestamp.py
浏览文件 @
4cf36c00
...
...
@@ -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/first.py
浏览文件 @
4cf36c00
...
...
@@ -60,10 +60,10 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
#!bug TD-16561
#
for i in ['stb','db.stb']:
#
tdSql.query(f"select first(*) from {i}")
#
tdSql.checkRows(1)
#
tdSql.checkData(0, 1, None)
for
i
in
[
'stb'
,
'db.stb'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
for
i
in
column_list
:
for
j
in
[
'stb_1'
,
'db.stb_1'
,
'stb_1'
,
'db.stb_1'
]:
tdSql
.
query
(
f
"select first(
{
i
}
) from
{
j
}
"
)
...
...
@@ -125,10 +125,10 @@ class TDTestCase:
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
#!bug TD-16561
#
for i in [f'{stbname}', f'{dbname}.{stbname}']:
#
tdSql.query(f"select first(*) from {i}")
#
tdSql.checkRows(1)
#
tdSql.checkData(0, 1, None)
for
i
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
'show tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
...
...
@@ -170,8 +170,8 @@ class TDTestCase:
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/timezone.py
浏览文件 @
4cf36c00
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录