Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5b06d8df
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5b06d8df
编写于
7月 26, 2022
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix case
上级
e6bf3ccb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
15 deletion
+87
-15
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+13
-8
tests/system-test/1-insert/mutil_stage.py
tests/system-test/1-insert/mutil_stage.py
+74
-7
未找到文件。
tests/pytest/util/sql.py
浏览文件 @
5b06d8df
...
...
@@ -49,18 +49,23 @@ class TDSql:
def
close
(
self
):
self
.
cursor
.
close
()
def
prepare
(
self
):
tdLog
.
info
(
"prepare database:db
"
)
def
prepare
(
self
,
dbname
=
"db"
,
drop
=
True
,
**
kwargs
):
tdLog
.
info
(
f
"prepare database:
{
dbname
}
"
)
s
=
'reset query cache'
try
:
self
.
cursor
.
execute
(
s
)
except
:
tdLog
.
notice
(
"'reset query cache' is not supported"
)
s
=
'drop database if exists db'
self
.
cursor
.
execute
(
s
)
s
=
'create database db duration 300'
if
drop
:
s
=
f
'drop database if exists
{
dbname
}
'
self
.
cursor
.
execute
(
s
)
s
=
f
'create database
{
dbname
}
'
for
k
,
v
in
kwargs
.
items
():
s
+=
f
"
{
k
}
{
v
}
"
if
"duration"
not
in
kwargs
:
s
+=
" duration 300"
self
.
cursor
.
execute
(
s
)
s
=
'use db
'
s
=
f
'use
{
dbname
}
'
self
.
cursor
.
execute
(
s
)
time
.
sleep
(
2
)
...
...
@@ -106,7 +111,7 @@ class TDSql:
if
row_tag
:
return
self
.
queryResult
return
self
.
queryRows
except
Exception
as
e
:
except
Exception
as
e
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
sql
,
repr
(
e
))
tdLog
.
notice
(
"%s(%d) failed: sql:%s, %s"
%
args
)
...
...
@@ -304,7 +309,7 @@ class TDSql:
tdLog
.
notice
(
"Try to execute sql again, query times: %d "
%
i
)
time
.
sleep
(
1
)
pass
else
:
else
:
try
:
tdLog
.
notice
(
"Try the last execute sql "
)
self
.
affectedRows
=
self
.
cursor
.
execute
(
sql
)
...
...
tests/system-test/1-insert/mutil_stage.py
浏览文件 @
5b06d8df
from
datetime
import
datetime
import
time
from
typing
import
List
,
Any
,
Tuple
from
util.log
import
*
...
...
@@ -31,7 +32,6 @@ 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
...
...
@@ -39,9 +39,9 @@ NOW = int(datetime.timestamp(datetime.now()) * 1000)
# init db/table
DBNAME
=
"db"
STBNAME
=
f
"
{
DBNAME
}
.
stb1"
CTB
NAME
=
f
"
{
DBNAME
}
.ct1
"
NTB
NAME
=
f
"
{
DBNAME
}
.nt1
"
STBNAME
=
"
stb1"
CTB
_PRE
=
"ct
"
NTB
_PRE
=
"nt
"
L0
=
0
L1
=
1
...
...
@@ -153,32 +153,99 @@ class TDTestCase:
for
i
in
range
(
9
):
current_case2
.
append
(
f
"dataDir
{
self
.
taos_data_dir
}
/
{
DATA_PRE0
}{
i
+
1
}
{
L0
}
{
NON_PRIMARY_DIR
}
"
)
# TD-17773bug
current_case3
=
[
f
"dataDir
{
self
.
taos_data_dir
}
/
{
DATA_PRE0
}
0 "
,
f
"dataDir
{
self
.
taos_data_dir
}
/
{
DATA_PRE0
}
1
{
L0
}
{
NON_PRIMARY_DIR
}
"
,
f
"dataDir
{
self
.
taos_data_dir
}
/
{
DATA_PRE1
}
0
{
L1
}
{
NON_PRIMARY_DIR
}
"
,
f
"dataDir
{
self
.
taos_data_dir
}
/
{
DATA_PRE2
}
0
{
L2
}
{
NON_PRIMARY_DIR
}
"
,
]
cfg_list
.
append
(
current_case1
)
cfg_list
.
append
(
current_case3
)
return
cfg_list
def
cfg_check
(
self
):
for
cfg_case
in
self
.
__err_cfg
:
tdLog
.
info
(
self
.
__err_cfg
.
index
(
cfg_case
))
self
.
del_old_datadir
(
filename
=
self
.
taos_cfg_path
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
deploy
(
1
)
self
.
cfg_str_list
(
filename
=
self
.
taos_cfg_path
,
update_list
=
cfg_case
)
tdDnodes
.
starttaosd
(
1
)
time
.
sleep
(
2
)
tdSql
.
error
(
f
"show databases"
)
for
cfg_case
in
self
.
__current_cfg
:
self
.
del_old_datadir
(
filename
=
self
.
taos_cfg_path
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
deploy
(
1
)
self
.
cfg_str_list
(
filename
=
self
.
taos_cfg_path
,
update_list
=
cfg_case
)
tdDnodes
.
start
(
1
)
tdSql
.
query
(
f
"show databases"
)
def
__create_tb
(
self
,
stb
=
STBNAME
,
ctb_pre
=
CTB_PRE
,
ctb_num
=
20
,
ntb_pre
=
NTB_PRE
,
ntbnum
=
1
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"==========step: create table"
)
create_stb_sql
=
f
'''create table
{
dbname
}
.
{
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
{
dbname
}
.
{
ntb_pre
}{
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
(
ctb_num
):
tdSql
.
execute
(
f
'create table
{
dbname
}
.
{
ctb_pre
}{
i
+
1
}
using
{
dbname
}
.
{
stb
}
tags (
{
i
+
1
}
)'
)
def
__insert_data
(
self
,
rows
,
dbname
=
DBNAME
):
data
=
DataSet
().
get_order_set
(
rows
)
tdLog
.
printNoPrefix
(
"==========step: start inser data into tables now....."
)
# now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for
i
in
range
(
self
.
rows
):
row_data
=
f
'''
{
data
.
int_data
[
i
]
}
,
{
data
.
bint_data
[
i
]
}
,
{
data
.
sint_data
[
i
]
}
,
{
data
.
tint_data
[
i
]
}
,
{
data
.
float_data
[
i
]
}
,
{
data
.
double_data
[
i
]
}
,
{
data
.
bool_data
[
i
]
}
, '
{
data
.
binary_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
data
.
tint_un_data
[
i
]
}
,
{
data
.
sint_un_data
[
i
]
}
,
{
data
.
int_un_data
[
i
]
}
,
{
data
.
bint_un_data
[
i
]
}
'''
neg_row_data
=
f
'''
{
-
1
*
data
.
int_data
[
i
]
}
,
{
-
1
*
data
.
bint_data
[
i
]
}
,
{
-
1
*
data
.
sint_data
[
i
]
}
,
{
-
1
*
data
.
tint_data
[
i
]
}
,
{
-
1
*
data
.
float_data
[
i
]
}
,
{
-
1
*
data
.
double_data
[
i
]
}
,
{
data
.
bool_data
[
i
]
}
, '
{
data
.
binary_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
1
*
data
.
tint_un_data
[
i
]
}
,
{
1
*
data
.
sint_un_data
[
i
]
}
,
{
1
*
data
.
int_un_data
[
i
]
}
,
{
1
*
data
.
bint_un_data
[
i
]
}
'''
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
CTB_PRE
}
1 values (
{
NOW
-
i
*
TIME_STEP
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
CTB_PRE
}
2 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.6
)
}
,
{
neg_row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
CTB_PRE
}
4 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.8
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
NTB_PRE
}
1 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
1.2
)
}
,
{
row_data
}
)"
)
def
run
(
self
):
self
.
rows
=
10
self
.
cfg_check
()
tdSql
.
prepare
(
dbname
=
DBNAME
,
**
{
"keep"
:
"5m, 10m, 15m"
,
"duration"
:
"5m"
})
self
.
__create_tb
(
dbname
=
DBNAME
)
self
.
__insert_data
(
rows
=
self
.
rows
,
dbname
=
DBNAME
)
tdSql
.
query
(
f
"select count(*) from
{
DBNAME
}
.
{
NTB_PRE
}
1"
)
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录