Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f000a2df
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f000a2df
编写于
6月 23, 2022
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix case
上级
beea5581
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
15 deletion
+93
-15
tests/pytest/util/constant.py
tests/pytest/util/constant.py
+10
-1
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+36
-0
tests/system-test/1-insert/time_range_wise.py
tests/system-test/1-insert/time_range_wise.py
+47
-14
未找到文件。
tests/pytest/util/constant.py
浏览文件 @
f000a2df
...
...
@@ -25,6 +25,9 @@ TAOS_BIN_TYPE = [
"MEDIUMBLOB"
,
"BLOB"
,
# add in 3.x
]
TAOS_TIME_INIT
=
[
"b"
,
"u"
,
"a"
,
"s"
,
"m"
,
"h"
,
"d"
,
"w"
,
"n"
,
"y"
]
TAOS_PRECISION
=
[
"ms"
,
"us"
,
"ns"
]
# basic data type boundary
TINYINT_MAX
=
127
TINYINT_MIN
=
-
128
...
...
@@ -108,7 +111,13 @@ TIME_Y = 365 * TIME_D
# streams and related agg-function
SMA_INDEX_FUNCTIONS
=
[
"MIN"
,
"MAX"
]
ROLLUP_FUNCTIONS
=
[
"AVG"
,
"SUM"
,
"MIN"
,
"MAX"
,
"LAST"
,
"FIRST"
]
SMA_WATMARK_MAXDELAY_INIT
=
[
'a'
,
"s"
,
"m"
]
\ No newline at end of file
SMA_WATMARK_MAXDELAY_INIT
=
[
'a'
,
"s"
,
"m"
]
WATERMARK_MAX
=
900000
WATERMARK_MIN
=
0
MAX_DELAY_MAX
=
900000
MAX_DELAY_MIN
=
1
\ No newline at end of file
tests/pytest/util/sql.py
浏览文件 @
f000a2df
...
...
@@ -21,6 +21,7 @@ import psutil
import
shutil
import
pandas
as
pd
from
util.log
import
*
from
util.constant
import
*
def
_parse_datetime
(
timestr
):
try
:
...
...
@@ -301,6 +302,41 @@ class TDSql:
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
elm
,
expect_elm
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, elm:%s == expect_elm:%s"
%
args
)
def
get_times
(
self
,
time_str
,
precision
=
"ms"
):
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
if
time_str
[
-
1
]
not
in
TAOS_TIME_INIT
:
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed:
{
time_str
}
not a standard taos time init"
)
if
precision
not
in
TAOS_PRECISION
:
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed:
{
precision
}
not a standard taos time precision"
)
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
0
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_NS
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
1
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_US
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
2
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_MS
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
3
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_S
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
4
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_M
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
5
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_H
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
6
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_D
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
7
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_W
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
8
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_N
if
time_str
[
-
1
]
==
TAOS_TIME_INIT
[
9
]:
times
=
int
(
time_str
[:
-
1
])
*
TIME_Y
if
precision
==
"ms"
:
return
int
(
times
)
elif
precision
==
"us"
:
return
int
(
times
*
1000
)
elif
precision
==
"ns"
:
return
int
(
times
*
1000
*
1000
)
def
taosdStatus
(
self
,
state
):
tdLog
.
sleep
(
5
)
pstate
=
0
...
...
tests/system-test/1-insert/time_range_wise.py
浏览文件 @
f000a2df
...
...
@@ -7,8 +7,6 @@ from util.sql import *
from
util.cases
import
*
from
util.dnodes
import
*
from
util.constant
import
*
# from ...pytest.util.sql import *
# from ...pytest.util.constant import *
PRIMARY_COL
=
"ts"
...
...
@@ -144,12 +142,16 @@ class SMAschema:
del
self
.
other
[
k
]
from
...pytest.util.sql
import
*
from
...pytest.util.constant
import
*
class
TDTestCase
:
updatecfgDict
=
{
"querySmaOptimize"
:
1
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
self
.
precision
=
"ms"
"""
create sma index :
...
...
@@ -210,14 +212,43 @@ class TDTestCase:
return
False
return
True
def
__check_sma_watermark
_max_dealy
(
self
,
arg
):
def
__check_sma_watermark
(
self
,
arg
):
if
not
isinstance
(
arg
,
str
):
return
False
if
arg
[
-
1
]
not
in
SMA_WATMARK_MAXDELAY_INIT
:
return
False
if
len
(
arg
)
==
1
:
return
False
if
not
arg
[:
-
1
].
isdecimal
():
return
False
if
tdSql
.
get_times
(
arg
)
>
WATERMARK_MAX
:
return
False
if
tdSql
.
get_times
(
arg
)
<
WATERMARK_MIN
:
return
False
return
True
def
__check_sma_max_delay
(
self
,
arg
):
self
.
__check_sma_watermark
(
arg
)
if
tdSql
.
get_times
(
arg
)
<
MAX_DELAY_MIN
:
return
False
return
True
def
__check_sliding
(
self
,
arg
):
if
not
isinstance
(
arg
,
str
):
return
False
if
arg
[
-
1
]
not
in
TAOS_TIME_INIT
:
return
False
if
len
(
arg
)
==
1
:
return
False
if
not
arg
[:
-
1
].
isdecimal
():
return
False
def
__check_interval
(
self
,
arg
):
if
not
isinstance
(
arg
,
tuple
):
return
False
def
__sma_create_check
(
self
,
sma
:
SMAschema
):
if
self
.
updatecfgDict
[
"querySmaOptimize"
]
==
0
:
...
...
@@ -245,9 +276,9 @@ class TDTestCase:
return
False
if
not
sma
.
sliding
:
return
False
if
not
sma
.
watermark
:
if
not
sma
.
watermark
or
not
self
.
__check_sma_watermark
(
sma
.
watermark
)
:
return
False
if
not
sma
.
max_delay
:
if
not
sma
.
max_delay
or
not
self
.
__check_sma_max_delay
(
sma
.
max_delay
)
:
return
False
if
sma
.
other
:
return
False
...
...
@@ -263,22 +294,24 @@ class TDTestCase:
cur_sqls
=
[]
# err_set
# # case 1: required fields check
err_sqls
.
append
(
SMAschema
(
creation
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
index_name
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
index_flag
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
operator
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
tbname
=
""
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
func
=
""
,
tbname
=
STBNAME
)
)
err_sqls
.
append
(
SMAschema
(
interval
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
sliding
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
err_sqls
.
append
(
SMAschema
(
max_delay
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
#
err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(func="",tbname=STBNAME ) )
#
err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
#
err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) )
err_sqls
.
append
(
SMAschema
(
watermark
=
""
,
tbname
=
STBNAME
,
func
=
(
f
"min(
{
INT_COL
}
)"
,
f
"max(
{
INT_COL
}
)"
)
)
)
return
err_sqls
,
cur_sqls
def
test_create_sma
(
self
):
err_sqls
,
cur_sqls
=
self
.
__create_sma_sql
for
err_sql
in
err_sqls
:
print
(
type
(
err_sql
.
watermark
))
self
.
sma_create_check
(
err_sql
)
def
all_test
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录