Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c45f6c4b
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,发现更多精彩内容 >>
提交
c45f6c4b
编写于
7月 15, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test:test case for update_iotdata
上级
a83d41f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
194 addition
and
1 deletion
+194
-1
tests/system-test/1-insert/update_data.py
tests/system-test/1-insert/update_data.py
+193
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
tests/system-test/1-insert/update_data.py
0 → 100644
浏览文件 @
c45f6c4b
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
random
import
string
from
util
import
constant
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
dbname
=
'db_test'
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
ts
=
1537146000000
self
.
binary_length
=
20
self
.
nchar_length
=
20
self
.
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
f
'binary(
{
self
.
binary_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
nchar_length
}
)'
,
'col_ts'
:
'timestamp'
}
self
.
tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
self
.
smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
self
.
int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
self
.
bigint
=
random
.
randint
(
constant
.
BIGINT_MIN
,
constant
.
BIGINT_MAX
)
self
.
untinyint
=
random
.
randint
(
constant
.
TINYINT_UN_MIN
,
constant
.
TINYINT_UN_MAX
)
self
.
unsmallint
=
random
.
randint
(
constant
.
SMALLINT_UN_MIN
,
constant
.
SMALLINT_UN_MAX
)
self
.
unint
=
random
.
randint
(
constant
.
INT_UN_MIN
,
constant
.
INT_MAX
)
self
.
unbigint
=
random
.
randint
(
constant
.
BIGINT_UN_MIN
,
constant
.
BIGINT_UN_MAX
)
self
.
bool
=
random
.
randint
(
0
,
100
)
%
2
self
.
float
=
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
)
self
.
double
=
random
.
uniform
(
constant
.
DOUBLE_MIN
*
(
1E-300
),
constant
.
DOUBLE_MAX
*
(
1E-300
))
self
.
binary
=
tdCom
.
getLongName
(
self
.
binary_length
)
self
.
tnchar
=
tdCom
.
getLongName
(
self
.
nchar_length
)
def
insert_base_data
(
self
,
col_type
,
tbname
,
value
=
None
):
if
value
==
None
:
if
col_type
.
lower
()
==
'tinyint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
tinyint
}
)'
)
elif
col_type
.
lower
()
==
'smallint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
smallint
}
)'
)
elif
col_type
.
lower
()
==
'int'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
int
}
)'
)
elif
col_type
.
lower
()
==
'bigint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
bigint
}
)'
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
untinyint
}
)'
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
unsmallint
}
)'
)
elif
col_type
.
lower
()
==
'int unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
unint
}
)'
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
unbigint
}
)'
)
elif
col_type
.
lower
()
==
'bool'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
bool
}
)'
)
elif
col_type
.
lower
()
==
'float'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
float
}
)'
)
elif
col_type
.
lower
()
==
'double'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
self
.
double
}
)'
)
elif
'binary'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
self
.
binary
}
")'
)
elif
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
self
.
nchar
}
")'
)
def
update_and_check_data
(
self
,
tbname
,
col_name
,
col_type
,
value
):
if
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
value
}
")'
)
else
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
value
}
)'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
if
col_type
.
lower
()
==
'float'
or
col_type
.
lower
()
==
'double'
:
if
abs
(
tdSql
.
queryResult
[
0
][
0
]
-
value
)
/
value
<=
0.0001
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tdSql
.
queryResult
[
0
][
0
])
else
:
tdLog
.
exit
(
f
'
{
col_name
}
data check failure'
)
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
def
update_check_ntb
(
self
):
up_tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
up_smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
up_int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
up_bigint
=
random
.
randint
(
constant
.
BIGINT_MIN
,
constant
.
BIGINT_MAX
)
up_untinyint
=
random
.
randint
(
constant
.
TINYINT_UN_MIN
,
constant
.
TINYINT_UN_MAX
)
up_unsmallint
=
random
.
randint
(
constant
.
SMALLINT_UN_MIN
,
constant
.
SMALLINT_UN_MAX
)
up_unint
=
random
.
randint
(
constant
.
INT_UN_MIN
,
constant
.
INT_MAX
)
up_unbigint
=
random
.
randint
(
constant
.
BIGINT_UN_MIN
,
constant
.
BIGINT_UN_MAX
)
up_bool
=
random
.
randint
(
0
,
100
)
%
2
up_float
=
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
)
up_double
=
random
.
uniform
(
constant
.
DOUBLE_MIN
*
(
1E-300
),
constant
.
DOUBLE_MAX
*
(
1E-300
))
binary_length
=
random
.
randint
(
0
,
self
.
binary_length
)
nchar_length
=
random
.
randint
(
0
,
self
.
binary_length
)
up_binary
=
tdCom
.
getLongName
(
binary_length
)
up_nchar
=
tdCom
.
getLongName
(
nchar_length
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
if
col_type
.
lower
()
==
'tinyint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_tinyint
)
elif
col_type
.
lower
()
==
'smallint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_smallint
)
elif
col_type
.
lower
()
==
'int'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_int
)
elif
col_type
.
lower
()
==
'bigint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_bigint
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_untinyint
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unsmallint
)
elif
col_type
.
lower
()
==
'int unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unint
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unbigint
)
elif
col_type
.
lower
()
==
'bool'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_bool
)
elif
col_type
.
lower
()
==
'float'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_float
)
elif
col_type
.
lower
()
==
'double'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_double
)
elif
'binary'
in
col_type
.
lower
():
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_binary
)
elif
'nchar'
in
col_type
.
lower
():
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_nchar
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,null)'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
self
.
ntbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
def
update_check_error_ntb
(
self
):
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
binary_length
=
self
.
binary_length
+
1
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
if
col_type
.
lower
()
in
[
'tinyint'
,
'smallint'
,
'int'
,
'bigint'
,
'tinyint unsigned'
,
'smallint unsigned'
,
'int unsigned'
,
'bigint unsigned'
]:
for
error_value
in
[
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
binary_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
in
[
'float'
,
'double'
]:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
binary_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
for
error_value
in
[
tdCom
.
getLongName
(
binary_length
)]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bool'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
binary_length
)]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
def
run
(
self
):
self
.
update_check_ntb
()
self
.
update_check_error_ntb
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/fulltest.sh
浏览文件 @
c45f6c4b
...
...
@@ -28,7 +28,7 @@ python3 ./test.py -f 1-insert/time_range_wise.py
python3 ./test.py
-f
1-insert/block_wise.py
python3 ./test.py
-f
1-insert/create_retentions.py
python3 ./test.py
-f
1-insert/table_param_ttl.py
python3 ./test.py
-f
1-insert/update_data.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/varchar.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录