Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
74edf683
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
74edf683
编写于
7月 21, 2022
作者:
H
Hui Li
提交者:
GitHub
7月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15126 from taosdata/cpwu/3.0
Test: fix case support rest API
上级
5e9aeaea
7c0cbeb9
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
2521 addition
and
1917 deletion
+2521
-1917
tests/pytest/util/common.py
tests/pytest/util/common.py
+104
-5
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+3
-7
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+34
-7
tests/pytest/util/taosadapter.py
tests/pytest/util/taosadapter.py
+260
-0
tests/system-test/1-insert/create_retentions.py
tests/system-test/1-insert/create_retentions.py
+49
-37
tests/system-test/1-insert/time_range_wise.py
tests/system-test/1-insert/time_range_wise.py
+26
-16
tests/system-test/2-query/abs.py
tests/system-test/2-query/abs.py
+195
-182
tests/system-test/2-query/and_or_for_byte.py
tests/system-test/2-query/and_or_for_byte.py
+133
-130
tests/system-test/2-query/apercentile.py
tests/system-test/2-query/apercentile.py
+4
-3
tests/system-test/2-query/arccos.py
tests/system-test/2-query/arccos.py
+201
-202
tests/system-test/2-query/arcsin.py
tests/system-test/2-query/arcsin.py
+200
-201
tests/system-test/2-query/arctan.py
tests/system-test/2-query/arctan.py
+203
-204
tests/system-test/2-query/avg.py
tests/system-test/2-query/avg.py
+171
-174
tests/system-test/2-query/between.py
tests/system-test/2-query/between.py
+100
-95
tests/system-test/2-query/bottom.py
tests/system-test/2-query/bottom.py
+3
-3
tests/system-test/2-query/cast.py
tests/system-test/2-query/cast.py
+154
-150
tests/system-test/2-query/ceil.py
tests/system-test/2-query/ceil.py
+169
-181
tests/system-test/2-query/char_length.py
tests/system-test/2-query/char_length.py
+26
-21
tests/system-test/2-query/check_tsdb.py
tests/system-test/2-query/check_tsdb.py
+50
-49
tests/system-test/2-query/histogram.py
tests/system-test/2-query/histogram.py
+0
-1
tests/system-test/2-query/join.py
tests/system-test/2-query/join.py
+213
-152
tests/system-test/2-query/sum.py
tests/system-test/2-query/sum.py
+29
-25
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+32
-16
tests/system-test/test.py
tests/system-test/test.py
+162
-56
未找到文件。
tests/pytest/util/common.py
浏览文件 @
74edf683
...
...
@@ -11,13 +11,13 @@
# -*- coding: utf-8 -*-
from
collections
import
defaultdict
import
random
import
string
import
requests
import
time
import
socket
import
json
import
toml
from
.boundary
import
DataBoundary
import
taos
from
util.log
import
*
...
...
@@ -25,6 +25,79 @@ from util.sql import *
from
util.cases
import
*
from
util.dnodes
import
*
from
util.common
import
*
from
util.constant
import
*
from
dataclasses
import
dataclass
,
field
from
typing
import
List
@
dataclass
class
DataSet
:
ts_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
int_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
bint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
sint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
tint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
uint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
ubint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
usint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
utint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
float_data
:
List
[
float
]
=
field
(
default_factory
=
list
)
double_data
:
List
[
float
]
=
field
(
default_factory
=
list
)
bool_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
vchar_data
:
List
[
str
]
=
field
(
default_factory
=
list
)
nchar_data
:
List
[
str
]
=
field
(
default_factory
=
list
)
def
get_order_set
(
self
,
rows
,
int_step
:
int
=
1
,
bint_step
:
int
=
1
,
sint_step
:
int
=
1
,
tint_step
:
int
=
1
,
uint_step
:
int
=
1
,
ubint_step
:
int
=
1
,
usint_step
:
int
=
1
,
utint_step
:
int
=
1
,
float_step
:
float
=
1
,
double_step
:
float
=
1
,
bool_start
:
int
=
1
,
vchar_prefix
:
str
=
"vachar_"
,
vchar_step
:
int
=
1
,
nchar_prefix
:
str
=
"nchar_测试_"
,
nchar_step
:
int
=
1
,
ts_step
:
int
=
1
):
for
i
in
range
(
rows
):
self
.
int_data
.
append
(
int
(
i
*
int_step
%
INT_MAX
))
self
.
bint_data
.
append
(
int
(
i
*
bint_step
%
BIGINT_MAX
))
self
.
sint_data
.
append
(
int
(
i
*
sint_step
%
SMALLINT_MAX
))
self
.
tint_data
.
append
(
int
(
i
*
tint_step
%
TINYINT_MAX
))
self
.
uint_data
.
append
(
int
(
i
*
uint_step
%
INT_UN_MAX
))
self
.
ubint_data
.
append
(
int
(
i
*
ubint_step
%
BIGINT_UN_MAX
))
self
.
usint_data
.
append
(
int
(
i
*
usint_step
%
SMALLINT_UN_MAX
))
self
.
utint_data
.
append
(
int
(
i
*
utint_step
%
TINYINT_UN_MAX
))
self
.
float_data
.
append
(
float
(
i
*
float_step
%
FLOAT_MAX
))
self
.
double_data
.
append
(
float
(
i
*
double_step
%
DOUBLE_MAX
))
self
.
bool_data
.
append
(
bool
((
i
+
bool_start
)
%
2
))
self
.
vchar_data
.
append
(
f
"
{
vchar_prefix
}
_
{
i
*
vchar_step
}
"
)
self
.
nchar_data
.
append
(
f
"
{
nchar_prefix
}
_
{
i
*
nchar_step
}
"
)
self
.
ts_data
.
append
(
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
-
i
*
ts_step
))
def
get_disorder_set
(
self
,
rows
,
int_low
:
int
=
INT_MIN
,
int_up
:
int
=
INT_MAX
,
bint_low
:
int
=
BIGINT_MIN
,
bint_up
:
int
=
BIGINT_MAX
,
sint_low
:
int
=
SMALLINT_MIN
,
sint_up
:
int
=
SMALLINT_MAX
,
tint_low
:
int
=
TINYINT_MIN
,
tint_up
:
int
=
TINYINT_MAX
,
ubint_low
:
int
=
BIGINT_UN_MIN
,
ubint_up
:
int
=
BIGINT_UN_MAX
,
):
pass
class
TDCom
:
def
__init__
(
self
):
...
...
@@ -372,6 +445,7 @@ class TDCom:
def
getClientCfgPath
(
self
):
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosd not found!"
)
else
:
...
...
@@ -650,7 +724,7 @@ class TDCom:
else
:
column_value_str
+=
f
'
{
column_value
}
, '
idx
+=
1
column_value_str
=
column_value_str
.
rstrip
()[:
-
1
]
column_value_str
=
column_value_str
.
rstrip
()[:
-
1
]
insert_sql
=
f
'insert into
{
dbname
}
.
{
tbname
}
values (
{
column_value_str
}
);'
tsql
.
execute
(
insert_sql
)
def
getOneRow
(
self
,
location
,
containElm
):
...
...
@@ -662,12 +736,12 @@ class TDCom:
return
res_list
else
:
tdLog
.
exit
(
f
"getOneRow out of range: row_index=
{
location
}
row_count=
{
self
.
query_row
}
"
)
def
killProcessor
(
self
,
processorName
):
def
killProcessor
(
self
,
processorName
):
if
(
platform
.
system
().
lower
()
==
'windows'
):
os
.
system
(
"TASKKILL /F /IM %s.exe"
%
processorName
)
else
:
os
.
system
(
'pkill %s'
%
processorName
)
os
.
system
(
'pkill %s'
%
processorName
)
def
is_json
(
msg
):
...
...
@@ -680,4 +754,29 @@ def is_json(msg):
else
:
return
False
def
get_path
(
tool
=
"taosd"
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
paths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
((
tool
)
in
files
or
(
"%s.exe"
%
tool
)
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
paths
.
append
(
os
.
path
.
join
(
root
,
tool
))
break
if
(
len
(
paths
)
==
0
):
return
""
return
paths
[
0
]
def
dict2toml
(
in_dict
:
dict
,
file
:
str
):
if
not
isinstance
(
in_dict
,
dict
):
return
""
with
open
(
file
,
'w'
)
as
f
:
toml
.
dump
(
in_dict
,
f
)
tdCom
=
TDCom
()
tests/pytest/util/dnodes.py
浏览文件 @
74edf683
...
...
@@ -96,9 +96,9 @@ class TDSimClient:
for
key
,
value
in
self
.
cfgDict
.
items
():
self
.
cfg
(
key
,
value
)
try
:
if
bool
(
updatecfgDict
)
and
updatecfgDict
[
0
]
and
updatecfgDict
[
0
][
0
]:
if
bool
(
updatecfgDict
)
and
updatecfgDict
[
0
]
and
updatecfgDict
[
0
][
0
]:
clientCfg
=
dict
(
updatecfgDict
[
0
][
0
].
get
(
'clientCfg'
))
for
key
,
value
in
clientCfg
.
items
():
self
.
cfg
(
key
,
value
)
...
...
@@ -244,7 +244,6 @@ class TDDnode:
# print(updatecfgDict)
isFirstDir
=
1
if
bool
(
updatecfgDict
)
and
updatecfgDict
[
0
]
and
updatecfgDict
[
0
][
0
]:
print
(
updatecfgDict
[
0
][
0
])
for
key
,
value
in
updatecfgDict
[
0
][
0
].
items
():
if
key
==
"clientCfg"
and
self
.
remoteIP
==
""
and
not
platform
.
system
().
lower
()
==
'windows'
:
continue
...
...
@@ -324,7 +323,6 @@ class TDDnode:
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
running
=
1
print
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
tdLog
.
debug
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
if
self
.
valgrind
==
0
:
time
.
sleep
(
0.1
)
...
...
@@ -358,7 +356,7 @@ class TDDnode:
# break
# elif bkey2 in line:
# popen.kill()
# break
# break
# if time.time() > timeout:
# print(time.time(),timeout)
# tdLog.exit('wait too long for taosd start')
...
...
@@ -407,7 +405,6 @@ class TDDnode:
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
running
=
1
print
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
tdLog
.
debug
(
"dnode:%d is running with %s "
%
(
self
.
index
,
cmd
))
if
self
.
valgrind
==
0
:
time
.
sleep
(
0.1
)
...
...
@@ -664,7 +661,6 @@ class TDDnodes:
def
stoptaosd
(
self
,
index
):
self
.
check
(
index
)
self
.
dnodes
[
index
-
1
].
stoptaosd
()
def
start
(
self
,
index
):
self
.
check
(
index
)
...
...
tests/pytest/util/sql.py
浏览文件 @
74edf683
...
...
@@ -235,9 +235,17 @@ class TDSql:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
elif
isinstance
(
data
,
float
)
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
float
):
if
abs
(
data
)
>=
1
and
abs
((
self
.
queryResult
[
row
][
col
]
-
data
)
/
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
abs
(
data
)
<
1
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
return
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
...
...
@@ -323,13 +331,32 @@ class TDSql:
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
col_name_list
,
expect_col_name_list
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s"
%
args
)
def
__check_equal
(
self
,
elm
,
expect_elm
):
if
not
type
(
elm
)
in
(
list
,
tuple
)
and
elm
==
expect_elm
:
return
True
if
type
(
elm
)
in
(
list
,
tuple
)
and
type
(
expect_elm
)
in
(
list
,
tuple
):
if
len
(
elm
)
!=
len
(
expect_elm
):
return
False
if
len
(
elm
)
==
0
:
return
True
for
i
in
range
(
len
(
elm
)):
flag
=
self
.
__check_equal
(
elm
[
i
],
expect_elm
[
i
])
if
not
flag
:
return
False
return
True
return
False
def
checkEqual
(
self
,
elm
,
expect_elm
):
if
elm
==
expect_elm
:
tdLog
.
info
(
"sql:%s, elm:%s == expect_elm:%s"
%
(
self
.
sql
,
elm
,
expect_elm
))
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
elm
,
expect_elm
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, elm:%s != expect_elm:%s"
%
args
)
return
if
self
.
__check_equal
(
elm
,
expect_elm
):
tdLog
.
info
(
"sql:%s, elm:%s == expect_elm:%s"
%
(
self
.
sql
,
elm
,
expect_elm
))
return
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
elm
,
expect_elm
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, elm:%s != expect_elm:%s"
%
args
)
def
checkNotEqual
(
self
,
elm
,
expect_elm
):
if
elm
!=
expect_elm
:
...
...
tests/pytest/util/taosadapter.py
0 → 100644
浏览文件 @
74edf683
import
socket
from
fabric2
import
Connection
from
util.log
import
*
from
util.common
import
*
class
TAdapter
:
def
__init__
(
self
):
self
.
running
=
0
self
.
deployed
=
0
self
.
remoteIP
=
""
self
.
taosadapter_cfg_dict
=
{
"debug"
:
True
,
"taosConfigDir"
:
""
,
"port"
:
6041
,
"logLevel"
:
"debug"
,
"cors"
:
{
"allowAllOrigins"
:
True
,
},
"pool"
:
{
"maxConnect"
:
4000
,
"maxIdle"
:
4000
,
"idleTimeout"
:
"1h"
},
"ssl"
:
{
"enable"
:
False
,
"certFile"
:
""
,
"keyFile"
:
""
,
},
"log"
:
{
"path"
:
""
,
"rotationCount"
:
30
,
"rotationTime"
:
"24h"
,
"rotationSize"
:
"1GB"
,
"enableRecordHttpSql"
:
True
,
"sqlRotationCount"
:
2
,
"sqlRotationTime"
:
"24h"
,
"sqlRotationSize"
:
"1GB"
,
},
"monitor"
:
{
"collectDuration"
:
"3s"
,
"incgroup"
:
False
,
"pauseQueryMemoryThreshold"
:
70
,
"pauseAllMemoryThreshold"
:
80
,
"identity"
:
""
,
"writeToTD"
:
True
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"writeInterval"
:
"30s"
},
"opentsdb"
:
{
"enable"
:
False
},
"influxdb"
:
{
"enable"
:
False
},
"statsd"
:
{
"enable"
:
False
},
"collectd"
:
{
"enable"
:
False
},
"opentsdb_telnet"
:
{
"enable"
:
False
},
"node_exporter"
:
{
"enable"
:
False
},
"prometheus"
:
{
"enable"
:
False
},
}
# TODO: add taosadapter env:
# 1. init cfg.toml.dict :OK
# 2. dump dict to toml : OK
# 3. update cfg.toml.dict :OK
# 4. check adapter exists : OK
# 5. deploy adapter cfg : OK
# 6. adapter start : OK
# 7. adapter stop
def
init
(
self
,
path
,
remoteIP
=
""
):
self
.
path
=
path
self
.
remoteIP
=
remoteIP
binPath
=
get_path
()
+
"/../../../"
binPath
=
os
.
path
.
realpath
(
binPath
)
if
path
==
""
:
self
.
path
=
os
.
path
.
abspath
(
binPath
+
"../../"
)
else
:
self
.
path
=
os
.
path
.
realpath
(
path
)
if
self
.
remoteIP
:
try
:
self
.
config
=
eval
(
remoteIP
)
self
.
remote_conn
=
Connection
(
host
=
self
.
config
[
"host"
],
port
=
self
.
config
[
"port"
],
user
=
self
.
config
[
"user"
],
connect_kwargs
=
{
'password'
:
self
.
config
[
"password"
]})
except
Exception
as
e
:
tdLog
.
notice
(
e
)
def
update_cfg
(
self
,
update_dict
:
dict
):
if
not
isinstance
(
update_dict
,
dict
):
return
if
"log"
in
update_dict
and
"path"
in
update_dict
[
"log"
]:
del
update_dict
[
"log"
][
"path"
]
for
key
,
value
in
update_dict
.
items
():
if
key
in
[
"cors"
,
"pool"
,
"ssl"
,
"log"
,
"monitor"
,
"opentsdb"
,
"influxdb"
,
"statsd"
,
"collectd"
,
"opentsdb_telnet"
,
"node_exporter"
,
"prometheus"
]:
if
isinstance
(
value
,
dict
):
for
k
,
v
in
value
.
items
():
self
.
taosadapter_cfg_dict
[
key
][
k
]
=
v
else
:
self
.
taosadapter_cfg_dict
[
key
]
=
value
def
check_adapter
(
self
):
if
getPath
(
tool
=
"taosadapter"
):
return
False
else
:
return
True
def
remote_exec
(
self
,
updateCfgDict
,
execCmd
):
remoteCfgDict
=
copy
.
deepcopy
(
updateCfgDict
)
if
"log"
in
remoteCfgDict
and
"path"
in
remoteCfgDict
[
"log"
]:
del
remoteCfgDict
[
"log"
][
"path"
]
remoteCfgDictStr
=
base64
.
b64encode
(
toml
.
dumps
(
remoteCfgDict
).
encode
()).
decode
()
execCmdStr
=
base64
.
b64encode
(
execCmd
.
encode
()).
decode
()
with
self
.
remote_conn
.
cd
((
self
.
config
[
"path"
]
+
sys
.
path
[
0
].
replace
(
self
.
path
,
''
)).
replace
(
'
\\
'
,
'/'
)):
self
.
remote_conn
.
run
(
f
"python3 ./test.py -D
{
remoteCfgDictStr
}
-e
{
execCmdStr
}
"
)
def
cfg
(
self
,
option
,
value
):
cmd
=
f
"echo
{
option
}
=
{
value
}
>>
{
self
.
cfg_path
}
"
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
def
deploy
(
self
,
*
update_cfg_dict
):
self
.
log_dir
=
f
"
{
self
.
path
}
/sim/dnode1/log"
self
.
cfg_dir
=
f
"
{
self
.
path
}
/sim/dnode1/cfg"
self
.
cfg_path
=
f
"
{
self
.
cfg_dir
}
/taosadapter.toml"
cmd
=
f
"touch
{
self
.
cfg_path
}
"
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
taosadapter_cfg_dict
[
"log"
][
"path"
]
=
self
.
log_dir
if
bool
(
update_cfg_dict
):
self
.
update_cfg
(
update_dict
=
update_cfg_dict
)
if
(
self
.
remoteIP
==
""
):
dict2toml
(
self
.
taosadapter_cfg_dict
,
self
.
cfg_path
)
else
:
self
.
remote_exec
(
self
.
taosadapter_cfg_dict
,
"tAdapter.deploy(update_cfg_dict)"
)
self
.
deployed
=
1
tdLog
.
debug
(
f
"taosadapter is deployed and configured by
{
self
.
cfg_path
}
"
)
def
start
(
self
):
bin_path
=
get_path
(
tool
=
"taosadapter"
)
if
(
bin_path
==
""
):
tdLog
.
exit
(
"taosadapter not found!"
)
else
:
tdLog
.
info
(
f
"taosadapter found:
{
bin_path
}
"
)
if
platform
.
system
().
lower
()
==
'windows'
:
cmd
=
f
"mintty -h never
{
bin_path
}
-c
{
self
.
cfg_dir
}
"
else
:
cmd
=
f
"nohup
{
bin_path
}
-c
{
self
.
cfg_path
}
> /dev/null 2>&1 & "
if
self
.
remoteIP
:
self
.
remote_exec
(
self
.
taosadapter_cfg_dict
,
f
"tAdapter.deployed=1
\n
tAdapter.log_dir=
{
self
.
log_dir
}
\n
tAdapter.cfg_dir=
{
self
.
cfg_dir
}
\n
tAdapter.start()"
)
self
.
running
=
1
else
:
os
.
system
(
f
"rm -rf
{
self
.
log_dir
}
/taosadapter*"
)
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
running
=
1
tdLog
.
debug
(
f
"taosadapter is running with
{
cmd
}
"
)
time
.
sleep
(
0.1
)
taosadapter_port
=
self
.
taosadapter_cfg_dict
[
"port"
]
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
settimeout
(
3
)
try
:
res
=
s
.
connect_ex
((
self
.
remoteIP
,
taosadapter_port
))
s
.
shutdown
(
2
)
if
res
==
0
:
tdLog
.
info
(
f
"the taosadapter has been started, using port:
{
taosadapter_port
}
"
)
else
:
tdLog
.
info
(
f
"the taosadapter do not started!!!"
)
except
socket
.
error
as
e
:
tdLog
.
notice
(
"socket connect error!"
)
finally
:
if
s
:
s
.
close
()
# tdLog.debug("the taosadapter has been started.")
time
.
sleep
(
1
)
def
start_taosadapter
(
self
):
"""
use this method, must deploy taosadapter
"""
bin_path
=
get_path
(
tool
=
"taosadapter"
)
if
(
bin_path
==
""
):
tdLog
.
exit
(
"taosadapter not found!"
)
else
:
tdLog
.
info
(
f
"taosadapter found:
{
bin_path
}
"
)
if
self
.
deployed
==
0
:
tdLog
.
exit
(
"taosadapter is not deployed"
)
if
platform
.
system
().
lower
()
==
'windows'
:
cmd
=
f
"mintty -h never
{
bin_path
}
-c
{
self
.
cfg_dir
}
"
else
:
cmd
=
f
"nohup
{
bin_path
}
-c
{
self
.
cfg_path
}
> /dev/null 2>&1 & "
if
self
.
remoteIP
:
self
.
remote_exec
(
self
.
taosadapter_cfg_dict
,
f
"tAdapter.deployed=1
\n
tAdapter.log_dir=
{
self
.
log_dir
}
\n
tAdapter.cfg_dir=
{
self
.
cfg_dir
}
\n
tAdapter.start()"
)
self
.
running
=
1
else
:
if
os
.
system
(
cmd
)
!=
0
:
tdLog
.
exit
(
cmd
)
self
.
running
=
1
tdLog
.
debug
(
f
"taosadapter is running with
{
cmd
}
"
)
time
.
sleep
(
0.1
)
def
stop
(
self
,
force_kill
=
False
):
signal
=
"-SIGKILL"
if
force_kill
else
"-SIGTERM"
if
self
.
remoteIP
:
self
.
remote_exec
(
self
.
taosadapter_cfg_dict
,
"tAdapter.running=1
\n
tAdapter.stop()"
)
tdLog
.
info
(
"stop taosadapter"
)
return
toBeKilled
=
"taosadapter"
if
self
.
running
!=
0
:
psCmd
=
f
"ps -ef|grep -w
{
toBeKilled
}
| grep -v grep | awk '{{print $2}}'"
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
).
decode
(
"utf-8"
)
while
(
processID
):
killCmd
=
f
"kill
{
signal
}
{
processID
}
> /dev/null 2>&1"
os
.
system
(
killCmd
)
time
.
sleep
(
1
)
processID
=
subprocess
.
check_output
(
psCmd
,
shell
=
True
).
decode
(
"utf-8"
)
if
not
platform
.
system
().
lower
()
==
'windows'
:
for
port
in
range
(
6030
,
6041
):
fuserCmd
=
f
"fuser -k -n tcp
{
port
}
> /dev/null"
os
.
system
(
fuserCmd
)
self
.
running
=
0
tdLog
.
debug
(
f
"taosadapter is stopped by kill
{
signal
}
"
)
tAdapter
=
TAdapter
()
\ No newline at end of file
tests/system-test/1-insert/create_retentions.py
浏览文件 @
74edf683
...
...
@@ -9,31 +9,41 @@ from util.dnodes import *
PRIMARY_COL
=
"ts"
INT_COL
=
"c_int"
BINT_COL
=
"c_bint"
SINT_COL
=
"c_sint"
TINT_COL
=
"c_tint"
FLOAT_COL
=
"c_float"
DOUBLE_COL
=
"c_double"
BOOL_COL
=
"c_bool"
TINT_UN_COL
=
"c_tint_un"
SINT_UN_COL
=
"c_sint_un"
BINT_UN_COL
=
"c_bint_un"
INT_UN_COL
=
"c_int_un"
BINARY_COL
=
"c_binary"
NCHAR_COL
=
"c_nchar"
TS_COL
=
"c_ts"
NUM_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
]
CHAR_COL
=
[
BINARY_COL
,
NCHAR_COL
,
]
BOOLEAN_COL
=
[
BOOL_COL
,
]
TS_TYPE_COL
=
[
TS_COL
,
]
INT_COL
=
"c_int"
BINT_COL
=
"c_bint"
SINT_COL
=
"c_sint"
TINT_COL
=
"c_tint"
FLOAT_COL
=
"c_float"
DOUBLE_COL
=
"c_double"
BOOL_COL
=
"c_bool"
TINT_UN_COL
=
"c_utint"
SINT_UN_COL
=
"c_usint"
BINT_UN_COL
=
"c_ubint"
INT_UN_COL
=
"c_uint"
BINARY_COL
=
"c_binary"
NCHAR_COL
=
"c_nchar"
TS_COL
=
"c_ts"
NUM_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
TINT_UN_COL
,
SINT_UN_COL
,
BINT_UN_COL
,
INT_UN_COL
]
CHAR_COL
=
[
BINARY_COL
,
NCHAR_COL
,
]
BOOLEAN_COL
=
[
BOOL_COL
,
]
TS_TYPE_COL
=
[
TS_COL
,
]
INT_TAG
=
"t_int"
ALL_COL
=
[
PRIMARY_COL
,
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
BINARY_COL
,
NCHAR_COL
,
BOOL_COL
,
TS_COL
]
TAG_COL
=
[
INT_TAG
]
## insert data args:
TIME_STEP
=
10000
NOW
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
# init db/table
DBNAME
=
"db"
STBNAME
=
"stb1"
CTBNAME
=
"ct1"
NTBNAME
=
"nt1"
@
dataclass
class
DataSet
:
ts_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
...
...
@@ -152,29 +162,31 @@ class TDTestCase:
self
.
test_create_databases
()
self
.
test_create_stb
()
def
__create_tb
(
self
):
def
__create_tb
(
self
,
stb
=
STBNAME
,
ctb_num
=
20
,
ntbnum
=
1
,
rsma
=
False
):
tdLog
.
printNoPrefix
(
"==========step: create table"
)
create_stb_sql
=
f
'''create table stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
TINT_UN_COL
}
tinyint unsigned,
{
SINT_UN_COL
}
smallint unsigned,
{
INT_UN_COL
}
int unsigned,
{
BINT_UN_COL
}
bigint unsigned
) tags (t1 int)
'''
create_ntb_sql
=
f
'''create table t1(
create_stb_sql
=
f
'''create table
{
stb
}
(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
TINT_UN_COL
}
tinyint unsigned,
{
SINT_UN_COL
}
smallint unsigned,
{
INT_UN_COL
}
int unsigned,
{
BINT_UN_COL
}
bigint unsigned
)
)
tags (
{
INT_TAG
}
int)
'''
for
i
in
range
(
ntbnum
):
create_ntb_sql
=
f
'''create table nt
{
i
+
1
}
(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
TINT_UN_COL
}
tinyint unsigned,
{
SINT_UN_COL
}
smallint unsigned,
{
INT_UN_COL
}
int unsigned,
{
BINT_UN_COL
}
bigint unsigned
)
'''
tdSql
.
execute
(
create_stb_sql
)
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using
stb1
tags (
{
i
+
1
}
)'
)
for
i
in
range
(
ctb_num
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using
{
stb
}
tags (
{
i
+
1
}
)'
)
def
__data_set
(
self
,
rows
):
data_set
=
DataSet
()
...
...
@@ -220,7 +232,7 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into ct1 values (
{
NOW
-
i
*
TIME_STEP
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.6
)
}
,
{
neg_row_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.8
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
t1
values (
{
NOW
-
i
*
int
(
TIME_STEP
*
1.2
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
-
i
*
int
(
TIME_STEP
*
1.2
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
NOW
+
int
(
TIME_STEP
*
0.6
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
0.6
)
}
,
{
null_data
}
)"
)
...
...
@@ -230,9 +242,9 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into ct4 values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
0.8
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.39
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
t1
values (
{
NOW
+
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
t1
values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
t1
values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.59
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
+
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.59
)
}
,
{
null_data
}
)"
)
def
run
(
self
):
...
...
tests/system-test/1-insert/time_range_wise.py
浏览文件 @
74edf683
...
...
@@ -325,10 +325,17 @@ class TDTestCase:
def
__sma_create_check
(
self
,
sma
:
SMAschema
):
if
self
.
updatecfgDict
[
"querySmaOptimize"
]
==
0
:
return
False
# TODO: if database is a rollup-db, can not create sma index
# tdSql.query("select database()")
# if sma.rollup_db :
# return False
tdSql
.
query
(
"select database()"
)
dbname
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"show databases"
)
for
row
in
tdSql
.
queryResult
:
if
row
[
0
]
==
dbname
:
if
row
[
-
1
]
is
None
:
continue
if
":"
in
row
[
-
1
]:
sma
.
rollup_db
=
True
if
sma
.
rollup_db
:
return
False
tdSql
.
query
(
"show stables"
)
if
not
sma
.
tbname
:
return
False
...
...
@@ -379,12 +386,15 @@ class TDTestCase:
tdSql
.
query
(
self
.
__create_sma_index
(
sma
))
self
.
sma_count
+=
1
self
.
sma_created_index
.
append
(
sma
.
index_name
)
tdSql
.
query
(
"show streams"
)
tdSql
.
query
(
self
.
__show_sma_index
(
sma
)
)
tdSql
.
checkRows
(
self
.
sma_count
)
tdSql
.
checkData
(
0
,
2
,
sma
.
tbname
)
else
:
tdSql
.
error
(
self
.
__create_sma_index
(
sma
))
def
__drop_sma_index
(
self
,
sma
:
SMAschema
):
sql
=
f
"
{
sma
.
drop
}
{
sma
.
drop_flag
}
{
sma
.
index_name
}
"
return
sql
...
...
@@ -402,12 +412,12 @@ class TDTestCase:
def
sma_drop_check
(
self
,
sma
:
SMAschema
):
if
self
.
__sma_drop_check
(
sma
):
tdSql
.
query
(
self
.
__drop_sma_index
(
sma
))
print
(
self
.
__drop_sma_index
(
sma
))
self
.
sma_count
-=
1
self
.
sma_created_index
=
list
(
filter
(
lambda
x
:
x
!=
sma
.
index_name
,
self
.
sma_created_index
))
tdSql
.
query
(
"show streams"
)
tdSql
.
checkRows
(
self
.
sma_count
)
else
:
tdSql
.
error
(
self
.
__drop_sma_index
(
sma
))
...
...
@@ -614,20 +624,20 @@ class TDTestCase:
self
.
__insert_data
()
self
.
all_test
()
#tdLog.printNoPrefix("==========step2:create table in rollup database")
#tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
#tdSql.execute("use db3")
# self.__create_tb()
#tdSql.execute(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL}) ")
#self.all_test()
# self.__insert_data()
tdLog
.
printNoPrefix
(
"==========step2:create table in rollup database"
)
tdSql
.
execute
(
"create database db3 retentions 1s:4m,2s:8m,3s:12m"
)
tdSql
.
execute
(
"use db3"
)
tdSql
.
execute
(
f
"create stable stb1 (
{
PRIMARY_COL
}
timestamp,
{
INT_COL
}
int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma(
{
INT_COL
}
) "
)
self
.
all_test
()
tdSql
.
execute
(
"drop database if exists db1 "
)
tdSql
.
execute
(
"drop database if exists db2 "
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"flush database db "
)
tdLog
.
printNoPrefix
(
"==========step4:after wal, all check again "
)
self
.
all_test
()
...
...
tests/system-test/2-query/abs.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/and_or_for_byte.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/apercentile.py
浏览文件 @
74edf683
...
...
@@ -20,12 +20,13 @@ from util.sqlset import TDSetSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
self
.
rowNum
=
10
self
.
ts
=
1537146000000
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
dbname
=
"db"
self
.
ntbname
=
f
"
{
self
.
dbname
}
.ntb"
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
column_dict
=
{
...
...
tests/system-test/2-query/arccos.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/arcsin.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/arctan.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/avg.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/between.py
浏览文件 @
74edf683
...
...
@@ -13,190 +13,195 @@ class TDTestCase:
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
run
(
self
):
# sourcery skip: extract-duplicate-method
def
run
(
self
):
dbname
=
"db"
stb
=
f
"
{
dbname
}
.stb1"
rows
=
10
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
tdSql
.
execute
(
'''create table if not exists supt
f
'''create table if not exists
{
stb
}
(ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint)
tags(location binary(64), type int, isused bool , family nchar(64))'''
)
tdSql
.
execute
(
"create table t1 using supt
tags('beijing', 1, 1, 'nchar1')"
)
tdSql
.
execute
(
"create table t2 using supt
tags('shanghai', 2, 0, 'nchar2')"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.t1 using
{
stb
}
tags('beijing', 1, 1, 'nchar1')"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.t2 using
{
stb
}
tags('shanghai', 2, 0, 'nchar2')"
)
tdLog
.
printNoPrefix
(
"==========step2:insert data"
)
for
i
in
range
(
10
):
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into t1 values (now()+
{
i
}
m,
{
32767
+
i
}
,
{
20.0
+
i
/
10
}
,
{
2
**
31
+
i
}
,
{
3.4
*
10
**
38
+
i
/
10
}
,
{
127
+
i
}
,
{
i
}
)"
f
"insert into
{
dbname
}
.
t1 values (now()+
{
i
}
m,
{
32767
+
i
}
,
{
20.0
+
i
/
10
}
,
{
2
**
31
+
i
}
,
{
3.4
*
10
**
38
+
i
/
10
}
,
{
127
+
i
}
,
{
i
}
)"
)
tdSql
.
execute
(
f
"insert into t2 values (now()-
{
i
}
m,
{
-
32767
-
i
}
,
{
20.0
-
i
/
10
}
,
{
-
i
-
2
**
31
}
,
{
-
i
/
10
-
3.4
*
10
**
38
}
,
{
-
127
-
i
}
,
{
-
i
}
)"
f
"insert into
{
dbname
}
.
t2 values (now()-
{
i
}
m,
{
-
32767
-
i
}
,
{
20.0
-
i
/
10
}
,
{
-
i
-
2
**
31
}
,
{
-
i
/
10
-
3.4
*
10
**
38
}
,
{
-
127
-
i
}
,
{
-
i
}
)"
)
tdSql
.
execute
(
f
"insert into t1 values (now()+11m,
{
2
**
31
-
1
}
,
{
pow
(
10
,
37
)
*
34
}
,
{
pow
(
2
,
63
)
-
1
}
,
{
1.7
*
10
**
308
}
, 32767, 127)"
f
"insert into
{
dbname
}
.
t1 values (now()+11m,
{
2
**
31
-
1
}
,
{
pow
(
10
,
37
)
*
34
}
,
{
pow
(
2
,
63
)
-
1
}
,
{
1.7
*
10
**
308
}
, 32767, 127)"
)
tdSql
.
execute
(
f
"insert into t2 values (now()-11m,
{
1
-
2
**
31
}
,
{
-
3.4
*
10
**
38
}
,
{
1
-
2
**
63
}
,
{
-
1.7
*
10
**
308
}
, -32767, -127)"
f
"insert into
{
dbname
}
.
t2 values (now()-11m,
{
1
-
2
**
31
}
,
{
-
3.4
*
10
**
38
}
,
{
1
-
2
**
63
}
,
{
-
1.7
*
10
**
308
}
, -32767, -127)"
)
tdSql
.
execute
(
f
"insert into t2 values (now()-12m, null ,
{
-
3.4
*
10
**
38
}
, null ,
{
-
1.7
*
10
**
308
}
, null , null)"
f
"insert into
{
dbname
}
.
t2 values (now()-12m, null ,
{
-
3.4
*
10
**
38
}
, null ,
{
-
1.7
*
10
**
308
}
, null , null)"
)
tdLog
.
printNoPrefix
(
"==========step3:query timestamp type"
)
tdSql
.
query
(
"select * from
t1 where ts between now()-1m and now()+10m"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from
t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where ts between now()-1m and now()+10m"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'"
)
# tdSql.checkRows(11)
tdSql
.
query
(
"select * from
t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'"
)
# tdSql.checkRows(0)
tdSql
.
query
(
"select * from
t1 where ts between -2793600 and 31507199"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where ts between -2793600 and 31507199"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where ts between 1609430400000 and 4765104000000"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where ts between 1609430400000 and 4765104000000"
)
tdSql
.
checkRows
(
rows
+
1
)
tdLog
.
printNoPrefix
(
"==========step4:query int type"
)
tdSql
.
query
(
"select * from
t1 where c1 between 32767 and 32776"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from
t1 where c1 between 32766.9 and 32776.1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from
t1 where c1 between 32776 and 32767"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 between 32767 and 32776"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 between 32766.9 and 32776.1"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 between 32776 and 32767"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c1 between 'a' and 'e'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 between 'a' and 'e'"
)
tdSql
.
checkRows
(
0
)
# tdSql.query("select * from t1 where c1 between 0x64 and 0x69")
# tdSql.query("select * from
{dbname}.
t1 where c1 between 0x64 and 0x69")
# tdSql.checkRows(6)
tdSql
.
query
(
"select * from
t1 where c1 not between 100 and 106"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
f
"select * from t1 where c1 between
{
2
**
31
-
2
}
and
{
2
**
31
+
1
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 not between 100 and 106"
)
tdSql
.
checkRows
(
rows
+
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c1 between
{
2
**
31
-
2
}
and
{
2
**
31
+
1
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
"select * from t2 where c1 between null and
{
1
-
2
**
31
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c1 between null and
{
1
-
2
**
31
}
"
)
# tdSql.checkRows(3)
tdSql
.
query
(
f
"select * from t2 where c1 between
{
-
2
**
31
}
and
{
1
-
2
**
31
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c1 between
{
-
2
**
31
}
and
{
1
-
2
**
31
}
"
)
tdSql
.
checkRows
(
1
)
tdLog
.
printNoPrefix
(
"==========step5:query float type"
)
tdSql
.
query
(
"select * from
t1 where c2 between 20.0 and 21.0"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 between 20.0 and 21.0"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
f
"select * from t1 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
3.4
*
10
**
38
+
1
}
"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
"select * from
t1 where c2 between 21.0 and 20.0"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
3.4
*
10
**
38
+
1
}
"
)
tdSql
.
checkRows
(
rows
+
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 between 21.0 and 20.0"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c2 between 'DC3' and 'SYN'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 between 'DC3' and 'SYN'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c2 not between 0.1 and 0.2"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
f
"select * from t1 where c2 between
{
pow
(
10
,
38
)
*
3.4
}
and
{
pow
(
10
,
38
)
*
3.4
+
1
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 not between 0.1 and 0.2"
)
tdSql
.
checkRows
(
rows
+
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c2 between
{
pow
(
10
,
38
)
*
3.4
}
and
{
pow
(
10
,
38
)
*
3.4
+
1
}
"
)
# tdSql.checkRows(1)
tdSql
.
query
(
f
"select * from t2 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
-
3.4
*
10
**
38
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
-
3.4
*
10
**
38
}
"
)
# tdSql.checkRows(2)
tdSql
.
query
(
f
"select * from t2 where c2 between null and
{
-
3.4
*
10
**
38
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c2 between null and
{
-
3.4
*
10
**
38
}
"
)
# tdSql.checkRows(3)
tdLog
.
printNoPrefix
(
"==========step6:query bigint type"
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
}
and
{
2
**
31
+
10
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
-
2
**
63
}
and
{
2
**
63
}
"
)
tdSql
.
checkRows
(
1
1
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
+
10
}
and
{
2
**
31
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 between
{
2
**
31
}
and
{
2
**
31
+
10
}
"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 between
{
-
2
**
63
}
and
{
2
**
63
}
"
)
tdSql
.
checkRows
(
rows
+
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 between
{
2
**
31
+
10
}
and
{
2
**
31
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c3 between 'a' and 'z'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 between 'a' and 'z'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c3 not between 1 and 2"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
63
-
2
}
and
{
2
**
63
-
1
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c3 between
{
2
**
63
-
2
}
and
{
2
**
63
-
1
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
"select * from t2 where c3 between
{
-
2
**
63
}
and
{
1
-
2
**
63
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c3 between
{
-
2
**
63
}
and
{
1
-
2
**
63
}
"
)
# tdSql.checkRows(3)
tdSql
.
query
(
f
"select * from t2 where c3 between null and
{
1
-
2
**
63
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c3 between null and
{
1
-
2
**
63
}
"
)
# tdSql.checkRows(2)
tdLog
.
printNoPrefix
(
"==========step7:query double type"
)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
3.4
*
10
**
38
}
and
{
3.4
*
10
**
38
+
10
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
1.7
*
10
**
308
+
1
}
and
{
1.7
*
10
**
308
+
2
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 between
{
3.4
*
10
**
38
}
and
{
3.4
*
10
**
38
+
10
}
"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 between
{
1.7
*
10
**
308
+
1
}
and
{
1.7
*
10
**
308
+
2
}
"
)
# 因为精度原因,在超出bigint边界后,数值不能进行准确的判断
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
3.4
*
10
**
38
+
10
}
and
{
3.4
*
10
**
38
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 between
{
3.4
*
10
**
38
+
10
}
and
{
3.4
*
10
**
38
}
"
)
# tdSql.checkRows(0)
tdSql
.
query
(
"select * from
t1 where c4 between 'a' and 'z'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 between 'a' and 'z'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c4 not between 1 and 2"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
1.7
*
10
**
308
}
and
{
1.7
*
10
**
308
+
1
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c4 between
{
1.7
*
10
**
308
}
and
{
1.7
*
10
**
308
+
1
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
"select * from t2 where c4 between
{
-
1.7
*
10
**
308
-
1
}
and
{
-
1.7
*
10
**
308
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c4 between
{
-
1.7
*
10
**
308
-
1
}
and
{
-
1.7
*
10
**
308
}
"
)
# tdSql.checkRows(3)
tdSql
.
query
(
f
"select * from t2 where c4 between null and
{
-
1.7
*
10
**
308
}
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c4 between null and
{
-
1.7
*
10
**
308
}
"
)
# tdSql.checkRows(3)
tdLog
.
printNoPrefix
(
"==========step8:query smallint type"
)
tdSql
.
query
(
"select * from
t1 where c5 between 127 and 136"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from
t1 where c5 between 126.9 and 135.9"
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select * from
t1 where c5 between 136 and 127"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 between 127 and 136"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 between 126.9 and 135.9"
)
tdSql
.
checkRows
(
rows
-
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 between 136 and 127"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c5 between '~' and '^'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 between '~' and '^'"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c5 not between 1 and 2"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
"select * from
t1 where c5 between 32767 and 32768"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c5 between 32767 and 32768"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from
t2 where c5 between -32768 and -32767"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c5 between -32768 and -32767"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from
t2 where c5 between null and -32767"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c5 between null and -32767"
)
# tdSql.checkRows(1)
tdLog
.
printNoPrefix
(
"==========step9:query tinyint type"
)
tdSql
.
query
(
"select * from
t1 where c6 between 0 and 9"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from
t1 where c6 between -1.1 and 8.9"
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select * from
t1 where c6 between 9 and 0"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between 0 and 9"
)
tdSql
.
checkRows
(
rows
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between -1.1 and 8.9"
)
tdSql
.
checkRows
(
rows
-
1
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between 9 and 0"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from
t1 where c6 between 'NUL' and 'HT'"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between 'NUL' and 'HT'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from
t1 where c6 not between 1 and 2"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 not between 1 and 2"
)
# tdSql.checkRows(1)
tdSql
.
query
(
"select * from
t1 where c6 between 127 and 128"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between 127 and 128"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from
t2 where c6 between -128 and -127"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c6 between -128 and -127"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from
t2 where c6 between null and -127"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t2 where c6 between null and -127"
)
# tdSql.checkRows(3)
tdLog
.
printNoPrefix
(
"==========step10:invalid query type"
)
# TODO tag is not finished
# tdSql.query("select * from supt where location between 'beijing' and 'shanghai'")
# tdSql.checkRows(23)
# # 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
# tdSql.query("select * from supt where isused between 0 and 1")
# tdSql.checkRows(23)
# tdSql.query("select * from supt where isused between -1 and 0")
# tdSql.checkRows(0)
# tdSql.error("select * from supt where isused between false and true")
# tdSql.query("select * from supt where family between '拖拉机' and '自行车'")
# tdSql.checkRows(23)
tdSql
.
query
(
f
"select * from
{
stb
}
where location between 'beijing' and 'shanghai'"
)
tdSql
.
checkRows
(
rows
*
2
+
3
)
# 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
tdSql
.
query
(
f
"select * from
{
stb
}
where isused between 0 and 1"
)
tdSql
.
checkRows
(
rows
*
2
+
3
)
tdSql
.
query
(
f
"select * from
{
stb
}
where isused between -1 and 0"
)
tdSql
.
checkRows
(
rows
+
2
)
tdSql
.
query
(
f
"select * from
{
stb
}
where isused between false and true"
)
tdSql
.
checkRows
(
rows
*
2
+
3
)
tdSql
.
query
(
f
"select * from
{
stb
}
where family between '拖拉机' and '自行车'"
)
tdSql
.
checkRows
(
0
)
tdLog
.
printNoPrefix
(
"==========step11:query HEX/OCT/BIN type"
)
tdSql
.
error
(
"select * from
t1 where c6 between 0x7f and 0x80"
)
# check filter HEX
tdSql
.
error
(
"select * from
t1 where c6 between 0b1 and 0b11111"
)
# check filter BIN
tdSql
.
error
(
"select * from
t1 where c6 between 0b1 and 0x80"
)
tdSql
.
error
(
"select * from
t1 where c6=0b1"
)
tdSql
.
error
(
"select * from
t1 where c6=0x1"
)
tdSql
.
error
(
f
"select * from
{
dbname
}
.
t1 where c6 between 0x7f and 0x80"
)
# check filter HEX
tdSql
.
error
(
f
"select * from
{
dbname
}
.
t1 where c6 between 0b1 and 0b11111"
)
# check filter BIN
tdSql
.
error
(
f
"select * from
{
dbname
}
.
t1 where c6 between 0b1 and 0x80"
)
tdSql
.
error
(
f
"select * from
{
dbname
}
.
t1 where c6=0b1"
)
tdSql
.
error
(
f
"select * from
{
dbname
}
.
t1 where c6=0x1"
)
# 八进制数据会按照十进制数据进行判定
tdSql
.
query
(
"select * from
t1 where c6 between 01 and 0200"
)
# check filter OCT
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.
t1 where c6 between 01 and 0200"
)
# check filter OCT
tdSql
.
checkRows
(
rows
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/2-query/bottom.py
浏览文件 @
74edf683
...
...
@@ -26,7 +26,7 @@ class TDTestCase:
tdSql
.
init
(
conn
.
cursor
())
self
.
dbname
=
'db_test'
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'
ntb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.
ntb'
self
.
rowNum
=
10
self
.
tbnum
=
20
self
.
ts
=
1537146000000
...
...
@@ -96,7 +96,7 @@ class TDTestCase:
self
.
bottom_check_data
(
self
.
ntbname
,
'normal_table'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
bottom_check_stb
(
self
):
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
stbname
=
f
'
{
self
.
dbname
}
.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
tag_dict
=
{
't0'
:
'int'
}
...
...
@@ -109,7 +109,7 @@ class TDTestCase:
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags(
{
tag_values
[
0
]
}
)"
)
self
.
insert_data
(
self
.
column_dict
,
f
'
{
stbname
}
_
{
i
}
'
,
self
.
rowNum
)
tdSql
.
query
(
'show
tables'
)
tdSql
.
query
(
f
'show
{
self
.
dbname
}
.
tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
...
...
tests/system-test/2-query/cast.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/ceil.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/char_length.py
浏览文件 @
74edf683
import
imp
import
datetime
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
...
...
@@ -101,16 +105,16 @@ class TDTestCase:
return
sqls
def
__test_current
(
self
):
def
__test_current
(
self
,
dbname
=
"db"
):
tdLog
.
printNoPrefix
(
"==========current sql condition check , must return query ok=========="
)
tbname
=
[
"ct1"
,
"ct2"
,
"ct4"
,
"t1"
,
"
stb1"
]
tbname
=
[
f
"
{
dbname
}
.ct1"
,
f
"
{
dbname
}
.ct2"
,
f
"
{
dbname
}
.ct4"
,
f
"
{
dbname
}
.t1"
,
f
"
{
dbname
}
.
stb1"
]
for
tb
in
tbname
:
self
.
__char_length_current_check
(
tb
)
tdLog
.
printNoPrefix
(
f
"==========current sql condition check in
{
tb
}
over=========="
)
def
__test_error
(
self
):
def
__test_error
(
self
,
dbname
=
"db"
):
tdLog
.
printNoPrefix
(
"==========err sql condition check , must return error=========="
)
tbname
=
[
"ct1"
,
"ct2"
,
"ct4"
,
"t1"
,
"
stb1"
]
tbname
=
[
f
"
{
dbname
}
.ct1"
,
f
"
{
dbname
}
.ct2"
,
f
"
{
dbname
}
.ct4"
,
f
"
{
dbname
}
.t1"
,
f
"
{
dbname
}
.
stb1"
]
for
tb
in
tbname
:
for
errsql
in
self
.
__char_length_err_check
(
tb
):
...
...
@@ -123,17 +127,16 @@ class TDTestCase:
self
.
__test_error
()
def
__create_tb
(
self
):
tdSql
.
prepare
()
def
__create_tb
(
self
,
dbname
=
"db"
):
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
create_stb_sql
=
f
'''create table stb1(
create_stb_sql
=
f
'''create table
{
dbname
}
.
stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
) tags (t
1
int)
) tags (t
_int
int)
'''
create_ntb_sql
=
f
'''create table t1(
create_ntb_sql
=
f
'''create table
{
dbname
}
.
t1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
...
...
@@ -143,29 +146,29 @@ class TDTestCase:
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags (
{
i
+
1
}
)'
)
tdSql
.
execute
(
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags (
{
i
+
1
}
)'
)
def
__insert_data
(
self
,
rows
):
def
__insert_data
(
self
,
rows
,
dbname
=
"db"
):
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
'''insert into ct1 values
f
'''insert into
{
dbname
}
.
ct1 values
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0',
{
now_time
+
8
}
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9',
{
now_time
+
9
}
)
'''
)
tdSql
.
execute
(
f
'''insert into ct4 values
f
'''insert into
{
dbname
}
.
ct4 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -181,7 +184,7 @@ class TDTestCase:
)
tdSql
.
execute
(
f
'''insert into ct2 values
f
'''insert into
{
dbname
}
.
ct2 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -197,13 +200,13 @@ class TDTestCase:
)
for
i
in
range
(
rows
):
insert_data
=
f
'''insert into t1 values
insert_data
=
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
-
i
*
3600000
}
,
{
i
}
,
{
i
*
11111
}
,
{
i
%
32767
}
,
{
i
%
127
}
,
{
i
*
1.11111
}
,
{
i
*
1000.1111
}
,
{
i
%
2
}
,
"binary_
{
i
}
", "nchar_
{
i
}
",
{
now_time
-
1000
*
i
}
)
'''
tdSql
.
execute
(
insert_data
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -232,8 +235,10 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step3:all check"
)
self
.
all_test
()
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"flush database db"
)
tdSql
.
execute
(
"use db"
)
...
...
tests/system-test/2-query/check_tsdb.py
浏览文件 @
74edf683
...
...
@@ -9,73 +9,73 @@ from util.cases import *
from
util.dnodes
import
*
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"udfDebugFlag"
:
143
}
# updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
#
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
#
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
Tru
e
)
def
prepare_datas
(
self
):
tdSql
.
init
(
conn
.
cursor
(),
Fals
e
)
def
prepare_datas
(
self
,
dbname
=
"db"
):
tdSql
.
execute
(
'''create table
stb1
f
'''create table
{
dbname
}
.
stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
#
tdSql.execute(
# f
'''
#
create table t1
#
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
#
'''
#
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags (
{
i
+
1
}
)'
)
tdSql
.
execute
(
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags (
{
i
+
1
}
)'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
# tdSql.execute(
# f'''insert into t1 values
# ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
# ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
# ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
# ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
# ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
# ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
# ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
# ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
# ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
# ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
# ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
# ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
# '''
# )
def
restart_taosd_query_sum
(
self
):
def
restart_taosd_query_sum
(
self
,
dbname
=
"db"
):
for
i
in
range
(
5
):
tdLog
.
info
(
" this is %d_th restart taosd "
%
i
)
os
.
system
(
"taos -s ' use db ;select c6 from
stb1 ; '"
)
tdSql
.
execute
(
"use db
"
)
tdSql
.
query
(
"select count(*) from
stb1"
)
os
.
system
(
f
"taos -s ' use db ;select c6 from
{
dbname
}
.
stb1 ; '"
)
tdSql
.
execute
(
f
"use
{
dbname
}
"
)
tdSql
.
query
(
f
"select count(*) from
{
dbname
}
.
stb1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select sum(c1),sum(c2),sum(c3),sum(c4),sum(c5),sum(c6) from
stb1;"
)
tdSql
.
query
(
f
"select sum(c1),sum(c2),sum(c3),sum(c4),sum(c5),sum(c6) from
{
dbname
}
.
stb1;"
)
tdSql
.
checkData
(
0
,
0
,
99
)
tdSql
.
checkData
(
0
,
1
,
499995
)
tdSql
.
checkData
(
0
,
2
,
4995
)
...
...
@@ -85,17 +85,18 @@ class TDTestCase:
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
time
.
sleep
(
2
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql
.
prepare
()
dbname
=
"db"
tdLog
.
printNoPrefix
(
"==========step1:create table =============="
)
self
.
prepare_datas
()
os
.
system
(
"taos -s ' select c6 from
stb1 ; '"
)
os
.
system
(
f
"taos -s ' select c6 from
{
dbname
}
.
stb1 ; '"
)
self
.
restart_taosd_query_sum
()
def
stop
(
self
):
...
...
tests/system-test/2-query/histogram.py
浏览文件 @
74edf683
...
...
@@ -5,7 +5,6 @@ import json
from
dataclasses
import
dataclass
,
field
from
typing
import
List
,
Any
,
Tuple
from
certifi
import
where
from
util.log
import
tdLog
from
util.sql
import
tdSql
from
util.cases
import
tdCases
...
...
tests/system-test/2-query/join.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/2-query/sum.py
浏览文件 @
74edf683
...
...
@@ -20,6 +20,8 @@ NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
UN_NUM_COL
=
[
BOOL_COL
,
BINARY_COL
,
NCHAR_COL
,
]
TS_TYPE_COL
=
[
TS_COL
]
DBNAME
=
"db"
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
...
...
@@ -54,14 +56,14 @@ class TDTestCase:
where_condition
=
self
.
__where_condition
(
condition
)
group_condition
=
self
.
__group_condition
(
condition
,
having
=
f
"
{
condition
}
is not null "
)
tdSql
.
query
(
f
"select
{
condition
}
from
{
tbname
}
{
where_condition
}
"
)
tdSql
.
query
(
f
"select
{
condition
}
from
{
DBNAME
}
.
{
tbname
}
{
where_condition
}
"
)
datas
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
sum_data
=
sum
(
filter
(
None
,
datas
))
tdSql
.
query
(
f
"select sum(
{
condition
}
) from
{
tbname
}
{
where_condition
}
"
)
tdSql
.
query
(
f
"select sum(
{
condition
}
) from
{
DBNAME
}
.
{
tbname
}
{
where_condition
}
"
)
tdSql
.
checkData
(
0
,
0
,
sum_data
)
tdSql
.
query
(
f
"select
{
condition
}
from
{
tbname
}
{
where_condition
}
{
group_condition
}
"
)
tdSql
.
query
(
f
"select sum(
{
condition
}
) from
{
tbname
}
{
where_condition
}
{
group_condition
}
"
)
tdSql
.
query
(
f
"select
{
condition
}
from
{
DBNAME
}
.
{
tbname
}
{
where_condition
}
{
group_condition
}
"
)
tdSql
.
query
(
f
"select sum(
{
condition
}
) from
{
DBNAME
}
.
{
tbname
}
{
where_condition
}
{
group_condition
}
"
)
def
__sum_err_check
(
self
,
tbanme
):
sqls
=
[]
...
...
@@ -69,19 +71,19 @@ class TDTestCase:
for
un_num_col
in
UN_NUM_COL
:
sqls
.
extend
(
(
f
"select sum(
{
un_num_col
}
) from
{
tbanme
}
"
,
f
"select sum(ceil(
{
un_num_col
}
)) from
{
tbanme
}
"
,
f
"select sum(
{
un_num_col
}
) from
{
DBNAME
}
.
{
tbanme
}
"
,
f
"select sum(ceil(
{
un_num_col
}
))
{
DBNAME
}
.
from
{
tbanme
}
"
,
)
)
# sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
sqls
.
extend
(
f
"select sum(
{
num_col
}
+
{
ts_col
}
) from
{
tbanme
}
"
for
num_col
in
NUM_COL
for
ts_col
in
TS_TYPE_COL
)
sqls
.
extend
(
f
"select sum(
{
num_col
}
+
{
ts_col
}
) from
{
DBNAME
}
.
{
tbanme
}
"
for
num_col
in
NUM_COL
for
ts_col
in
TS_TYPE_COL
)
sqls
.
extend
(
(
f
"select sum() from
{
tbanme
}
"
,
f
"select sum(*) from
{
tbanme
}
"
,
f
"select sum(ccccccc) from
{
tbanme
}
"
,
f
"select sum('test') from
{
tbanme
}
"
,
f
"select sum() from
{
DBNAME
}
.
{
tbanme
}
"
,
f
"select sum(*) from
{
DBNAME
}
.
{
tbanme
}
"
,
f
"select sum(ccccccc)
{
DBNAME
}
.
from
{
tbanme
}
"
,
f
"select sum('test') from
{
DBNAME
}
.
{
tbanme
}
"
,
)
)
...
...
@@ -110,16 +112,15 @@ class TDTestCase:
def
__create_tb
(
self
):
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
create_stb_sql
=
f
'''create table stb1(
create_stb_sql
=
f
'''create table
{
DBNAME
}
.
stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
) tags (t1 int)
'''
create_ntb_sql
=
f
'''create table t1(
create_ntb_sql
=
f
'''create table
{
DBNAME
}
.
t1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
...
...
@@ -129,29 +130,29 @@ class TDTestCase:
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags (
{
i
+
1
}
)'
)
tdSql
.
execute
(
f
'create table
{
DBNAME
}
.ct
{
i
+
1
}
using
{
DBNAME
}
.
stb1 tags (
{
i
+
1
}
)'
)
def
__insert_data
(
self
,
rows
):
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
DBNAME
}
.
ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
DBNAME
}
.
ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
DBNAME
}
.
ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
'''insert into ct1 values
f
'''insert into
{
DBNAME
}
.
ct1 values
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0',
{
now_time
+
8
}
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9',
{
now_time
+
9
}
)
'''
)
tdSql
.
execute
(
f
'''insert into ct4 values
f
'''insert into
{
DBNAME
}
.
ct4 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -167,7 +168,7 @@ class TDTestCase:
)
tdSql
.
execute
(
f
'''insert into ct2 values
f
'''insert into
{
DBNAME
}
.
ct2 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -183,13 +184,13 @@ class TDTestCase:
)
for
i
in
range
(
rows
):
insert_data
=
f
'''insert into t1 values
insert_data
=
f
'''insert into
{
DBNAME
}
.
t1 values
(
{
now_time
-
i
*
3600000
}
,
{
i
}
,
{
i
*
11111
}
,
{
i
%
32767
}
,
{
i
%
127
}
,
{
i
*
1.11111
}
,
{
i
*
1000.1111
}
,
{
i
%
2
}
,
"binary_
{
i
}
", "nchar_
{
i
}
",
{
now_time
-
1000
*
i
}
)
'''
tdSql
.
execute
(
insert_data
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
DBNAME
}
.
t1 values
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -218,8 +219,11 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step3:all check"
)
self
.
all_test
()
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"flush database db"
)
tdSql
.
execute
(
"use db"
)
...
...
tests/system-test/fulltest.sh
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
tests/system-test/test.py
浏览文件 @
74edf683
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录