Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f138388b
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f138388b
编写于
6月 30, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update now.py and today.py
上级
3f9f8592
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
32 deletion
+56
-32
tests/system-test/2-query/Now.py
tests/system-test/2-query/Now.py
+0
-1
tests/system-test/2-query/Today.py
tests/system-test/2-query/Today.py
+56
-31
未找到文件。
tests/system-test/2-query/Now.py
浏览文件 @
f138388b
...
...
@@ -58,7 +58,6 @@ class TDTestCase:
if
v
.
lower
()
!=
'timestamp'
:
continue
else
:
sleep
(
1
)
tdSql
.
query
(
f
'select * from
{
tbname
}
where
{
k
}
>=now()'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select * from
{
tbname
}
where
{
k
}
<now()'
)
...
...
tests/system-test/2-query/Today.py
浏览文件 @
f138388b
...
...
@@ -5,6 +5,7 @@ from util.log import *
from
util.sql
import
*
from
util.cases
import
*
import
datetime
import
pandas
as
pd
class
TDTestCase
:
...
...
@@ -12,8 +13,8 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
self
.
today_date
=
datetime
.
datetime
.
strptime
(
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d"
),
"%Y-%m-%d"
)
self
.
today_date
=
datetime
.
datetime
.
strptime
(
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d"
),
"%Y-%m-%d"
)
self
.
today_ts
=
datetime
.
datetime
.
strptime
(
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d"
),
"%Y-%m-%d"
).
timestamp
(
)
self
.
time_unit
=
[
'b'
,
'u'
,
'a'
,
's'
,
'm'
,
'h'
,
'd'
,
'w'
]
self
.
error_param
=
[
'1.5'
,
'abc'
,
'!@#'
,
'"abc"'
,
'today()'
]
self
.
arithmetic_operators
=
[
'+'
,
'-'
,
'*'
,
'/'
]
...
...
@@ -41,7 +42,7 @@ class TDTestCase:
f
'today(),3,3.333,333.333333,now()'
,
f
'today()-1d,10,11.11,99.999999,now()'
,
f
'today()+1d,1,1.55,100.555555,today()'
]
self
.
db_percision
=
[
'ms'
,
'us'
,
'ns'
]
def
set_create_normaltable_sql
(
self
,
ntbname
,
column_dict
):
column_sql
=
''
for
k
,
v
in
column_dict
.
items
():
...
...
@@ -57,7 +58,12 @@ class TDTestCase:
tag_sql
+=
f
"
{
k
}
{
v
}
,"
create_stb_sql
=
f
'create table
{
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
return
create_stb_sql
def
data_check
(
self
,
column_dict
=
{},
tbname
=
''
,
values_list
=
[],
tb_num
=
1
,
tb
=
'tb'
):
def
datetime_transition
(
self
,
date
,
precision
):
if
precision
==
'ns'
:
today_date
=
date
*
1000000000
return
today_date
def
data_check
(
self
,
column_dict
=
{},
tbname
=
''
,
values_list
=
[],
tb_num
=
1
,
tb
=
'tb'
,
precision
=
'ms'
):
for
k
,
v
in
column_dict
.
items
():
num_up
=
0
num_down
=
0
...
...
@@ -65,12 +71,27 @@ class TDTestCase:
if
v
.
lower
()
==
'timestamp'
:
tdSql
.
query
(
f
'select
{
k
}
from
{
tbname
}
'
)
for
i
in
tdSql
.
queryResult
:
if
i
[
0
]
>
self
.
today_date
:
num_up
+=
1
elif
i
[
0
]
==
self
.
today_date
:
num_same
+=
1
elif
i
[
0
]
<
self
.
today_date
:
num_down
+=
1
if
precision
==
'ms'
:
if
int
(
i
[
0
].
timestamp
())
*
1000
>
int
(
self
.
today_ts
)
*
1000
:
num_up
+=
1
elif
int
(
i
[
0
].
timestamp
())
*
1000
==
int
(
self
.
today_ts
)
*
1000
:
num_same
+=
1
elif
int
(
i
[
0
].
timestamp
())
*
1000
<
int
(
self
.
today_ts
)
*
1000
:
num_down
+=
1
elif
precision
==
'us'
:
if
int
(
i
[
0
].
timestamp
())
*
1000000
>
int
(
self
.
today_ts
)
*
1000000
:
num_up
+=
1
elif
int
(
i
[
0
].
timestamp
())
*
1000000
==
int
(
self
.
today_ts
)
*
1000000
:
num_same
+=
1
elif
int
(
i
[
0
].
timestamp
())
*
1000000
<
int
(
self
.
today_ts
)
*
1000000
:
num_down
+=
1
elif
precision
==
'ns'
:
if
i
[
0
]
>
int
(
self
.
today_ts
)
*
1000000000
:
num_up
+=
1
elif
i
[
0
]
==
int
(
self
.
today_ts
)
*
1000000000
:
num_same
+=
1
elif
i
[
0
]
<
int
(
self
.
today_ts
)
*
1000000000
:
num_down
+=
1
tdSql
.
query
(
f
"select today() from
{
tbname
}
"
)
tdSql
.
checkRows
(
len
(
values_list
)
*
tb_num
)
tdSql
.
checkData
(
0
,
0
,
str
(
self
.
today_date
))
...
...
@@ -130,32 +151,36 @@ class TDTestCase:
for
i
in
range
(
num_same
):
tdSql
.
checkData
(
i
,
0
,
str
(
self
.
today_date
))
def
today_check_ntb
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
self
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
i
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
i
}
)'
)
self
.
data_check
(
self
.
column_dict
,
self
.
ntbname
,
self
.
values_list
)
tdSql
.
execute
(
'drop database db'
)
for
time_unit
in
self
.
db_percision
:
print
(
time_unit
)
tdSql
.
execute
(
f
'create database db precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db'
)
tdSql
.
execute
(
self
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
i
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
i
}
)'
)
self
.
data_check
(
self
.
column_dict
,
self
.
ntbname
,
self
.
values_list
,
1
,
'tb'
,
time_unit
)
tdSql
.
execute
(
'drop database db'
)
def
today_check_stb_tb
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
self
.
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
}
)'
)
# check child table
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
self
.
column_dict
,
f
'
{
self
.
stbname
}
_
{
i
}
'
,
self
.
values_list
)
# check stable
self
.
data_check
(
self
.
column_dict
,
self
.
stbname
,
self
.
values_list
,
self
.
tbnum
,
'stb'
)
tdSql
.
execute
(
'drop database db'
)
for
time_unit
in
self
.
db_percision
:
print
(
time_unit
)
tdSql
.
execute
(
f
'create database db precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db'
)
tdSql
.
execute
(
self
.
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
}
)'
)
# check child table
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
self
.
column_dict
,
f
'
{
self
.
stbname
}
_
{
i
}
'
,
self
.
values_list
,
1
,
'tb'
,
time_unit
)
# check stable
self
.
data_check
(
self
.
column_dict
,
self
.
stbname
,
self
.
values_list
,
self
.
tbnum
,
'stb'
,
time_unit
)
tdSql
.
execute
(
'drop database db'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
tdLog
.
printNoPrefix
(
"==========check today() for normal table =========="
)
self
.
today_check_ntb
()
tdLog
.
printNoPrefix
(
"==========check today() for stable and child table=========="
)
self
.
today_check_stb_tb
()
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录