Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eb6bc0a6
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看板
提交
eb6bc0a6
编写于
6月 26, 2023
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case
上级
77d2737f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
7 deletion
+18
-7
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+18
-7
未找到文件。
tests/system-test/2-query/Timediff.py
浏览文件 @
eb6bc0a6
...
@@ -4,6 +4,8 @@ from util.cases import *
...
@@ -4,6 +4,8 @@ from util.cases import *
from
util.gettime
import
*
from
util.gettime
import
*
class
TDTestCase
:
class
TDTestCase
:
updatecfgDict
=
{
'keepColumnName'
:
1
}
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
...
@@ -27,14 +29,14 @@ class TDTestCase:
...
@@ -27,14 +29,14 @@ class TDTestCase:
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
self
.
subtractor
=
1
# unit:s
self
.
subtractor
=
1
# unit:s
def
check_tbtype
(
self
,
tb_type
):
def
check_tbtype
(
self
,
tb_type
):
if
tb_type
.
lower
()
==
'ntb'
:
if
tb_type
.
lower
()
==
'ntb'
:
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
ntbname
}
'
)
elif
tb_type
.
lower
()
==
'ctb'
:
elif
tb_type
.
lower
()
==
'ctb'
:
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
ctbname
}
'
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
ctbname
}
'
)
elif
tb_type
.
lower
()
==
'stb'
:
elif
tb_type
.
lower
()
==
'stb'
:
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
stbname
}
'
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
) from
{
self
.
stbname
}
'
)
def
check_tb_type
(
self
,
unit
,
tb_type
):
def
check_tb_type
(
self
,
unit
,
tb_type
):
if
tb_type
.
lower
()
==
'ntb'
:
if
tb_type
.
lower
()
==
'ntb'
:
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
elif
tb_type
.
lower
()
==
'ctb'
:
elif
tb_type
.
lower
()
==
'ctb'
:
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ctbname
}
'
)
tdSql
.
query
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ctbname
}
'
)
...
@@ -43,7 +45,7 @@ class TDTestCase:
...
@@ -43,7 +45,7 @@ class TDTestCase:
def
data_check
(
self
,
date_time
,
precision
,
tb_type
):
def
data_check
(
self
,
date_time
,
precision
,
tb_type
):
for
unit
in
self
.
time_unit
:
for
unit
in
self
.
time_unit
:
if
(
unit
.
lower
()
==
'1u'
and
precision
.
lower
()
==
'ms'
)
or
(
unit
.
lower
()
==
'1b'
and
precision
.
lower
()
==
'us'
)
or
(
unit
.
lower
()
==
'1b'
and
precision
.
lower
()
==
'ms'
):
if
(
unit
.
lower
()
==
'1u'
and
precision
.
lower
()
==
'ms'
)
or
(
unit
.
lower
()
==
'1b'
and
precision
.
lower
()
==
'us'
)
or
(
unit
.
lower
()
==
'1b'
and
precision
.
lower
()
==
'ms'
):
if
tb_type
.
lower
()
==
'ntb'
:
if
tb_type
.
lower
()
==
'ntb'
:
tdSql
.
error
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
elif
tb_type
.
lower
()
==
'ctb'
:
elif
tb_type
.
lower
()
==
'ctb'
:
tdSql
.
error
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ctbname
}
'
)
tdSql
.
error
(
f
'select timediff(ts,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ctbname
}
'
)
...
@@ -66,7 +68,7 @@ class TDTestCase:
...
@@ -66,7 +68,7 @@ class TDTestCase:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
))
elif
unit
.
lower
()
==
'1d'
:
elif
unit
.
lower
()
==
'1d'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
/
24
))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
/
24
))
elif
unit
.
lower
()
==
'1w'
:
elif
unit
.
lower
()
==
'1w'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
/
24
/
7
))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
)
/
60
/
60
/
24
/
7
))
...
@@ -97,7 +99,7 @@ class TDTestCase:
...
@@ -97,7 +99,7 @@ class TDTestCase:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
*
1000
)))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
]
/
1000
)
-
self
.
subtractor
*
1000
)))
elif
unit
.
lower
()
==
'1u'
:
elif
unit
.
lower
()
==
'1u'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
for
i
in
range
(
len
(
self
.
ts_str
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000
)))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000
)))
self
.
check_tbtype
(
tb_type
)
self
.
check_tbtype
(
tb_type
)
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
tdSql
.
checkRows
(
len
(
self
.
ts_str
))
for
i
in
range
(
len
(
self
.
ts_str
)):
for
i
in
range
(
len
(
self
.
ts_str
)):
...
@@ -185,8 +187,16 @@ class TDTestCase:
...
@@ -185,8 +187,16 @@ class TDTestCase:
elif
precision
.
lower
()
==
'ns'
:
elif
precision
.
lower
()
==
'ns'
:
for
i
in
range
(
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
)))
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
int
(((
date_time
[
i
])
-
self
.
subtractor
*
1000000000
)))
def
function_multi_res_param
(
self
):
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,c0 int)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("2023-01-01 00:00:00",1)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("2023-01-01 00:01:00",2)'
)
tdSql
.
query
(
f
'select timediff(last(ts), first(ts)) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
60000
)
...
@@ -194,7 +204,8 @@ class TDTestCase:
...
@@ -194,7 +204,8 @@ class TDTestCase:
self
.
function_check_ntb
()
self
.
function_check_ntb
()
self
.
function_check_stb
()
self
.
function_check_stb
()
self
.
function_without_param
()
self
.
function_without_param
()
self
.
function_multi_res_param
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录