Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e87ae5b1
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
未验证
提交
e87ae5b1
编写于
6月 20, 2022
作者:
H
Hui Li
提交者:
GitHub
6月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14002 from taosdata/3.0test/jcy
test : add test case for table comment
上级
565a1133
580fb571
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
135 addition
and
114 deletion
+135
-114
tests/system-test/1-insert/create_table_comment.py
tests/system-test/1-insert/create_table_comment.py
+0
-113
tests/system-test/1-insert/table_comment.py
tests/system-test/1-insert/table_comment.py
+134
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
tests/system-test/1-insert/create_table_comment.py
已删除
100644 → 0
浏览文件 @
565a1133
###################################################################
# 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.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
def
get_long_name
(
self
,
length
,
mode
=
"mixed"
):
"""
generate long name
mode could be numbers/letters/letters_mixed/mixed
"""
if
mode
==
"numbers"
:
population
=
string
.
digits
elif
mode
==
"letters"
:
population
=
string
.
ascii_letters
.
lower
()
elif
mode
==
"letters_mixed"
:
population
=
string
.
ascii_letters
.
upper
()
+
string
.
ascii_letters
.
lower
()
else
:
population
=
string
.
ascii_letters
.
lower
()
+
string
.
digits
return
""
.
join
(
random
.
choices
(
population
,
k
=
length
))
def
__create_tb
(
self
,
dbname
,
stbname
,
tbname
,
comment
):
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,c0 int) tags(t0 int) '
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1) comment "
{
comment
}
"'
)
def
__create_normaltb
(
self
,
dbname
,
tbname
,
comment
):
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp,c0 int) comment "
{
comment
}
"'
)
def
check_comment
(
self
):
dbname
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
ntbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
# create normal table with comment
comment
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
self
.
__create_normaltb
(
dbname
,
ntbname
,
comment
)
ntb_kv_list
=
tdSql
.
getResult
(
"show tables"
)
print
(
ntb_kv_list
)
tdSql
.
checkEqual
(
ntb_kv_list
[
0
][
8
],
comment
)
tdSql
.
error
(
'alter table {ntbname} comment "test1"'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
# max length(1024)
comment
=
self
.
get_long_name
(
length
=
1024
,
mode
=
"letters"
)
self
.
__create_normaltb
(
dbname
,
ntbname
,
comment
)
ntb_kv_list
=
tdSql
.
getResult
(
"show tables"
)
tdSql
.
checkEqual
(
ntb_kv_list
[
0
][
8
],
comment
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
# error overlength
comment
=
self
.
get_long_name
(
length
=
1025
,
mode
=
"letters"
)
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
error
(
f
"create table ntb (ts timestamp,c0 int) comment '
{
comment
}
'"
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
# create child table with comment
comment
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
stbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
tbname
=
self
.
get_long_name
(
length
=
3
,
mode
=
"letters"
)
self
.
__create_tb
(
dbname
,
stbname
,
tbname
,
comment
)
ntb_kv_list
=
tdSql
.
getResult
(
"show tables"
)
tdSql
.
checkEqual
(
ntb_kv_list
[
0
][
8
],
comment
)
tdSql
.
error
(
f
'alter table
{
tbname
}
comment "test1"'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
# max length 1024
comment
=
self
.
get_long_name
(
length
=
1024
,
mode
=
"letters"
)
self
.
__create_tb
(
dbname
,
ntbname
,
comment
)
ntb_kv_list
=
tdSql
.
getResult
(
"show tables"
)
tdSql
.
checkEqual
(
ntb_kv_list
[
0
][
8
],
comment
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
# error overlength
comment
=
self
.
get_long_name
(
length
=
1025
,
mode
=
"letters"
)
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
tdSql
.
execute
(
f
"create table stb (ts timestamp,c0 int) tags(t0 int)"
)
tdSql
.
error
(
f
'create table stb_1 us stb tags(1) comment "
{
comment
}
"'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
run
(
self
):
self
.
check_comment
()
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/table_comment.py
0 → 100644
浏览文件 @
e87ae5b1
###################################################################
# 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.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
())
# prepare data
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'c1'
:
'int'
,
'c2'
:
'float'
,
'c3'
:
'double'
,
'c4'
:
'timestamp'
}
self
.
tag_dict
=
{
't0'
:
'int'
}
self
.
comment_length
=
[
0
,
1024
]
self
.
error_comment_length
=
[
1025
]
self
.
table_type_list
=
[
'normal_table'
,
'stable'
,
'child_table'
]
self
.
comment_flag_list
=
[
True
,
False
]
def
__set_and_alter_comment
(
self
,
tb_type
=
''
,
comment_flag
=
False
):
column_sql
=
''
tag_sql
=
''
for
k
,
v
in
self
.
column_dict
.
items
():
column_sql
+=
f
"
{
k
}
{
v
}
,"
for
k
,
v
in
self
.
tag_dict
.
items
():
tag_sql
+=
f
"
{
k
}
{
v
}
,"
if
tb_type
==
'normal_table'
or
tb_type
==
''
:
if
comment_flag
==
False
:
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(
{
column_sql
[:
-
1
]
}
)'
)
self
.
check_comment_info
()
self
.
alter_comment
(
self
.
ntbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
elif
comment_flag
==
True
:
for
i
in
self
.
comment_length
:
comment_info
=
tdCom
.
getLongName
(
i
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(
{
column_sql
[:
-
1
]
}
) comment "
{
comment_info
}
"'
)
self
.
check_comment_info
(
comment_info
)
self
.
alter_comment
(
self
.
ntbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
for
i
in
self
.
error_comment_length
:
comment_info
=
tdCom
.
getLongName
(
i
)
tdSql
.
error
(
f
'create table
{
self
.
ntbname
}
(
{
column_sql
[:
-
1
]
}
) comment "
{
comment_info
}
"'
)
elif
tb_type
==
'stable'
:
for
operation
in
[
'table'
,
'stable'
]:
if
comment_flag
==
False
:
tdSql
.
execute
(
f
'create
{
operation
}
{
self
.
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
)
self
.
check_comment_info
(
None
,
'stable'
)
self
.
alter_comment
(
self
.
stbname
,
'stable'
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
'
)
elif
comment_flag
==
True
:
for
i
in
self
.
comment_length
:
comment_info
=
tdCom
.
getLongName
(
i
)
tdSql
.
execute
(
f
'create
{
operation
}
{
self
.
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
) comment "
{
comment_info
}
"'
)
self
.
check_comment_info
(
comment_info
,
'stable'
)
self
.
alter_comment
(
self
.
stbname
,
'stable'
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
'
)
elif
tb_type
==
'child_table'
:
tdSql
.
execute
(
f
'create table if not exists
{
self
.
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
)
if
comment_flag
==
False
:
tdSql
.
execute
(
f
'create table if not exists
{
self
.
stbname
}
_ctb using
{
self
.
stbname
}
tags(1)'
)
self
.
check_comment_info
()
self
.
alter_comment
(
f
'
{
self
.
stbname
}
_ctb'
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
_ctb'
)
elif
comment_flag
==
True
:
for
j
in
self
.
comment_length
:
comment_info
=
tdCom
.
getLongName
(
j
)
tdSql
.
execute
(
f
'create table if not exists
{
self
.
stbname
}
_ctb using
{
self
.
stbname
}
tags(1) comment "
{
comment_info
}
"'
)
self
.
check_comment_info
(
comment_info
)
self
.
alter_comment
(
f
'
{
self
.
stbname
}
_ctb'
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
_ctb'
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
'
)
def
alter_comment
(
self
,
tbname
,
tb_type
=
''
):
for
i
in
self
.
comment_length
:
comment_info
=
tdCom
.
getLongName
(
i
)
print
(
comment_info
)
tdSql
.
execute
(
f
'alter table
{
tbname
}
comment "
{
comment_info
}
"'
)
self
.
check_comment_info
(
comment_info
,
tb_type
)
for
i
in
self
.
error_comment_length
:
comment_info
=
tdCom
.
getLongName
(
i
)
tdSql
.
error
(
f
'alter table
{
tbname
}
comment "
{
comment_info
}
"'
)
def
check_comment_info
(
self
,
comment_info
=
None
,
tb_type
=
''
):
if
tb_type
==
''
or
tb_type
==
'normal_table'
or
tb_type
==
'child_table'
:
tdSql
.
query
(
'show tables'
)
if
comment_info
==
None
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
8
],
None
)
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
8
],
comment_info
)
elif
tb_type
==
'stable'
:
tdSql
.
query
(
'show stables'
)
if
comment_info
==
None
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
6
],
None
)
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
6
],
comment_info
)
def
comment_check_case
(
self
,
table_type
,
comment_flag
):
tdSql
.
prepare
()
for
tb
in
table_type
:
for
flag
in
comment_flag
:
self
.
__set_and_alter_comment
(
tb
,
flag
)
tdSql
.
execute
(
'drop database db'
)
def
run
(
self
):
self
.
comment_check_case
(
self
.
table_type_list
,
self
.
comment_flag_list
)
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
浏览文件 @
e87ae5b1
...
...
@@ -22,7 +22,7 @@ python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
python3 ./test.py
-f
1-insert/alter_stable.py
python3 ./test.py
-f
1-insert/alter_table.py
python3 ./test.py
-f
1-insert/insertWithMoreVgroup.py
# python3 ./test.py -f 1-inerst/create_
table_comment.py
python3 ./test.py
-f
1-insert/
table_comment.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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录