Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0d778738
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,发现更多精彩内容 >>
提交
0d778738
编写于
11月 17, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test:add test case for boundary check
上级
a186cc44
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
197 addition
and
2 deletion
+197
-2
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+10
-1
tests/system-test/1-insert/boundary.py
tests/system-test/1-insert/boundary.py
+186
-0
tests/system-test/1-insert/update_data.py
tests/system-test/1-insert/update_data.py
+1
-1
未找到文件。
tests/pytest/util/sql.py
浏览文件 @
0d778738
...
...
@@ -73,8 +73,15 @@ class TDSql:
expectErrNotOccured
=
True
try
:
self
.
cursor
.
execute
(
sql
)
except
BaseException
:
except
BaseException
as
e
:
expectErrNotOccured
=
False
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
self
.
error_info
=
repr
(
e
)
# print(error_info)
# self.error_info = error_info[error_info.index('(')+1:-1].split(",")[0].replace("'","")
# self.error_info = (','.join(error_info.split(",")[:-1]).split("(",1)[1:][0]).replace("'","")
# print("!!!!!!!!!!!!!!",self.error_info)
if
expectErrNotOccured
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
"%s(%d) failed: sql:%s, expect error not occured"
%
(
caller
.
filename
,
caller
.
lineno
,
sql
))
...
...
@@ -83,6 +90,8 @@ class TDSql:
self
.
queryCols
=
0
self
.
queryResult
=
None
tdLog
.
info
(
"sql:%s, expect error occured"
%
(
sql
))
return
self
.
error_info
def
query
(
self
,
sql
,
row_tag
=
None
,
queryTimes
=
10
):
self
.
sql
=
sql
...
...
tests/system-test/1-insert/boundary.py
0 → 100644
浏览文件 @
0d778738
###################################################################
# 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
math
from
random
import
randint
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.sqlset
import
*
from
util.boundary
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
boundary
=
DataBoundary
()
self
.
dbname_length_boundary
=
self
.
boundary
.
DBNAME_MAX_LENGTH
self
.
tbname_length_boundary
=
self
.
boundary
.
TBNAME_MAX_LENGTH
self
.
stbname_length_boundary
=
self
.
boundary
.
STBNAME_MAX_LENGTH
self
.
colname_length_boundary
=
self
.
boundary
.
COL_KEY_MAX_LENGTH
self
.
tagname_length_boundary
=
self
.
boundary
.
TAG_KEY_MAX_LENGTH
self
.
username_length_boundary
=
23
self
.
password_length_boundary
=
15
def
dbname_length_check
(
self
):
dbname_length
=
randint
(
1
,
self
.
dbname_length_boundary
-
1
)
for
dbname
in
[
tdCom
.
get_long_name
(
self
.
dbname_length_boundary
),
tdCom
.
get_long_name
(
dbname_length
)]:
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
query
(
f
'select name from information_schema.ins_databases where name = "
{
dbname
}
"'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
dbname
)
tdSql
.
execute
(
f
'drop database if exists
{
dbname
}
'
)
dbname
=
tdCom
.
get_long_name
(
self
.
dbname_length_boundary
+
1
)
tdSql
.
error
(
f
'create database if not exists
{
dbname
}
'
)
if
"Invalid identifier name"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
def
tbname_length_check
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'use db'
)
tbname_length
=
randint
(
1
,
self
.
tbname_length_boundary
-
1
)
tdSql
.
execute
(
f
'create table stb (ts timestamp,c0 int) tags(t0 int)'
)
for
tbname
in
[
tdCom
.
get_long_name
(
self
.
tbname_length_boundary
),
tdCom
.
get_long_name
(
tbname_length
)]:
tdSql
.
execute
(
f
'create table
{
tbname
}
using stb tags(1)'
)
tdSql
.
query
(
f
'select table_name from information_schema.ins_tables where table_name = "
{
tbname
}
"'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbname
)
tdSql
.
execute
(
f
'drop table
{
tbname
}
'
)
tbname
=
tdCom
.
get_long_name
(
self
.
tbname_length_boundary
+
1
)
tdSql
.
error
(
f
'create table
{
tbname
}
using stb tags(1)'
)
if
"Invalid identifier name"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
stbname_length
=
randint
(
1
,
self
.
stbname_length_boundary
-
1
)
for
stbname
in
[
tdCom
.
get_long_name
(
self
.
stbname_length_boundary
),
tdCom
.
get_long_name
(
stbname_length
)]:
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
query
(
f
'select stable_name from information_schema.ins_stables where stable_name = "
{
stbname
}
"'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
stbname
)
tdSql
.
execute
(
f
'drop table
{
stbname
}
'
)
stbname
=
tdCom
.
get_long_name
(
self
.
stbname_length_boundary
+
1
)
tdSql
.
error
(
f
'create table
{
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
print
(
tdSql
.
error_info
)
if
"Invalid identifier name"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
tdSql
.
execute
(
'drop database db'
)
def
colname_length_check
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'use db'
)
column_name_length
=
randint
(
1
,
self
.
colname_length_boundary
-
1
)
for
colname
in
[
tdCom
.
get_long_name
(
column_name_length
),
tdCom
.
get_long_name
(
self
.
colname_length_boundary
)]:
stbname
=
tdCom
.
get_long_name
(
3
)
ntbname
=
tdCom
.
get_long_name
(
4
)
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,
{
colname
}
int) tags(t0 int)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
1
][
0
],
colname
)
tdSql
.
execute
(
f
'create table
{
ntbname
}
(ts timestamp,
{
colname
}
int)'
)
tdSql
.
query
(
f
'describe
{
ntbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
1
][
0
],
colname
)
colname
=
tdCom
.
get_long_name
(
self
.
colname_length_boundary
+
1
)
tdSql
.
error
(
f
'create table stb (ts timestamp,
{
colname
}
int) tags(t0 int)'
)
if
"Invalid identifier name"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
tdSql
.
execute
(
'drop database db'
)
def
tagname_length_check
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'use db'
)
tag_name_length
=
randint
(
1
,
self
.
tagname_length_boundary
-
1
)
for
tagname
in
(
tdCom
.
get_long_name
(
tag_name_length
),
tdCom
.
get_long_name
(
self
.
tagname_length_boundary
)):
stbname
=
tdCom
.
get_long_name
(
3
)
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,c0 int) tags(
{
tagname
}
int)'
)
tdSql
.
query
(
f
'describe
{
stbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
-
1
][
0
],
tagname
)
tagname
=
tdCom
.
get_long_name
(
self
.
tagname_length_boundary
+
1
)
tdSql
.
error
(
f
'create table
{
stbname
}
(ts timestamp,c0 int) tags(
{
tagname
}
int)'
)
if
"Invalid identifier name"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
tdSql
.
execute
(
'drop database db'
)
def
username_length_check
(
self
):
username_length
=
randint
(
1
,
self
.
username_length_boundary
-
1
)
for
username
in
[
tdCom
.
get_long_name
(
username_length
),
tdCom
.
get_long_name
(
self
.
username_length_boundary
)]:
tdSql
.
execute
(
f
'create user
{
username
}
pass "123"'
)
tdSql
.
query
(
'show users'
)
for
user
in
tdSql
.
queryResult
:
if
user
[
0
].
lower
()
!=
'root'
:
tdSql
.
checkEqual
(
user
[
0
],
username
)
tdSql
.
execute
(
f
'drop user
{
username
}
'
)
username
=
tdCom
.
get_long_name
(
self
.
username_length_boundary
+
1
)
tdSql
.
error
(
f
'create user
{
username
}
pass "123"'
)
if
"Name or password too long"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
def
password_length_check
(
self
):
password_length
=
randint
(
1
,
self
.
password_length_boundary
-
1
)
for
password
in
[
tdCom
.
get_long_name
(
password_length
),
tdCom
.
get_long_name
(
self
.
password_length_boundary
)]:
username
=
tdCom
.
get_long_name
(
3
)
tdSql
.
execute
(
f
'create user
{
username
}
pass "
{
password
}
"'
)
password
=
tdCom
.
get_long_name
(
self
.
password_length_boundary
+
1
)
tdSql
.
error
(
f
'create user
{
username
}
pass "
{
password
}
"'
)
if
"Name or password too long"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
def
sql_length_check
(
self
):
insert_rows
=
1021
tdSql
.
prepare
()
tdSql
.
execute
(
'use db'
)
tdSql
.
execute
(
'create table ntb (ts timestamp,c0 binary(1013))'
)
values_sql
=
''
value
=
tdCom
.
get_long_name
(
1013
)
for
num
in
range
(
insert_rows
):
values_sql
+=
f
' (now+
{
num
}
s,"
{
value
}
")'
value
=
tdCom
.
get_long_name
(
65
)
values_sql
+=
f
"(now-1s,'
{
value
}
')"
tdSql
.
execute
(
f
'insert into ntb values
{
values_sql
}
'
)
tdSql
.
query
(
'select * from ntb'
)
tdSql
.
checkRows
(
insert_rows
+
1
)
tdSql
.
execute
(
'create table ntb1 (ts timestamp,c0 binary(1013))'
)
tdSql
.
error
(
f
'insert into ntb1 values
{
values_sql
}
;'
)
print
(
tdSql
.
error_info
)
if
"SQL statement too long"
in
tdSql
.
error_info
:
tdLog
.
info
(
"error info is true!"
)
else
:
tdLog
.
exit
(
"error info is not true"
)
tdSql
.
execute
(
'drop database db'
)
def
run
(
self
):
self
.
dbname_length_check
()
self
.
tbname_length_check
()
self
.
colname_length_check
()
self
.
tagname_length_check
()
self
.
username_length_check
()
# self.password_length_check()
self
.
sql_length_check
()
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/1-insert/update_data.py
浏览文件 @
0d778738
...
...
@@ -23,7 +23,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
()
,
logSql
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
dbname
=
'db_test'
self
.
ntbname
=
'ntb'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录