Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
72192fe0
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,发现更多精彩内容 >>
未验证
提交
72192fe0
编写于
12月 25, 2021
作者:
H
Hui Li
提交者:
GitHub
12月 25, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9302 from taosdata/TD-11040
[TD-11040]<test>:add restful test case
上级
2e9cddf5
896b7eca
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
172 addition
and
0 deletion
+172
-0
tests/system-test/3-connectors/restful/restful_binddbname.py
tests/system-test/3-connectors/restful/restful_binddbname.py
+168
-0
tests/system-test/fulltest-connector.sh
tests/system-test/fulltest-connector.sh
+4
-0
未找到文件。
tests/system-test/3-connectors/restful/restful_binddbname.py
0 → 100644
浏览文件 @
72192fe0
# #################################################################
# 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 -*-
# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations
from
distutils.log
import
error
import
sys
from
requests.api
import
head
from
requests.models
import
Response
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
time
,
datetime
import
requests
,
json
import
threading
import
string
import
random
import
re
null
=
''
true
=
'true'
false
=
'false'
def
caseDescription
(
self
):
'''
case1<jiacy-jcy>:dbname binding
case2<jiacy-jcy>:dbname without binding
'''
def
check_unbind_db
(
url
,
data
,
header
):
resp
=
requests
.
post
(
url
,
data
,
headers
=
header
)
resp
.
encoding
=
'utf-8'
resp
=
eval
(
resp
.
text
)
status
=
resp
[
'status'
]
#cod = resp['code']
sqls
=
data
if
status
==
"error"
:
#and cod == 401:
print
(
" %s : check pass"
%
sqls
)
else
:
printf
(
"%s error occured , "
%
sqls
)
sys
.
exit
(
1
)
def
check_bind_db
(
url
,
data
,
header
):
resp
=
requests
.
post
(
url
,
data
,
headers
=
header
)
resp
.
encoding
=
'utf-8'
resp_dict
=
eval
(
resp
.
text
)
status
=
resp_dict
[
'status'
]
if
status
==
"succ"
:
print
(
"%s run success!"
%
data
)
# print(resp.text)
else
:
print
(
"%s run failed !"
%
data
)
print
(
resp
.
text
)
sys
.
exit
(
1
)
class
TDTestCase
():
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
execute
(
'drop database if exists test'
)
tdSql
.
execute
(
'drop database if exists db'
)
tdSql
.
execute
(
'drop database if exists test01'
)
tdSql
.
execute
(
'create database test'
)
tdSql
.
execute
(
'create database test01'
)
header
=
{
'Authorization'
:
'Basic cm9vdDp0YW9zZGF0YQ=='
}
url
=
"http://127.0.0.1:6041/rest/sql"
# case 1: test with no bind dbname
sqls1
=
[
"show databases;"
,
"use test;"
,
"show dnodes;"
,
"create database db;"
,
"drop database db;"
,
"select client_version();"
,
"ALTER DATABASE test COMP 2;"
,
"show test.tables"
,
"create table test.tb (ts timestamp, id int , data double)"
,
"insert into test.tb values (now , 2, 2.0) "
,
"select * from test.tb"
]
sqls2
=
[
"show tables;"
,
"show vgroups;"
,
"create table tb (ts timestamp, id int , data double)"
,
"insert into tb values (now , 1, 1.0) "
,
"select * from tb"
,
"insert into tb values (now , 2, 2.0) "
,
"select * from tb"
]
print
(
"==================="
*
5
)
print
(
" check unbind db about restful "
)
print
(
"==================="
*
5
)
for
sql
in
sqls1
:
print
(
"==================="
)
check_bind_db
(
url
,
sql
,
header
)
for
sql
in
sqls2
:
print
(
"==================="
)
check_unbind_db
(
url
,
sql
,
header
)
tdSql
.
execute
(
'drop database if exists test01'
)
tdSql
.
execute
(
'drop database if exists test'
)
tdSql
.
execute
(
'create database test'
)
tdSql
.
execute
(
'create database test01'
)
#case 2: test with bind dbname
sqls3
=
[
"show databases;"
,
"use test;"
,
"show tables;"
,
"show dnodes;"
,
"show vgroups;"
,
"create database db;"
,
"drop database db;"
,
"select client_version();"
,
"use test"
,
"ALTER DATABASE test COMP 2;"
,
"create table tb (ts timestamp, id int , data double)"
,
"insert into tb values (now , 1, 1.0) "
,
"select * from tb"
,
"show test.tables"
,
"show tables"
,
"insert into tb values (now , 2, 2.0) "
,
"create table test.tb1 (ts timestamp, id int , data double)"
,
"insert into test.tb1 values (now , 2, 2.0) "
,
"select * from tb"
,
"select * from test.tb1"
]
print
(
"==================="
*
5
)
print
(
" check bind db about restful "
)
print
(
"==================="
*
5
)
url
=
"http://127.0.0.1:6041/rest/sql/test"
for
sql
in
sqls3
:
print
(
"==================="
)
check_bind_db
(
url
,
sql
,
header
)
# check data
tdSql
.
query
(
"select * from test.tb"
)
tdSql
.
checkRows
(
2
)
os
.
system
(
'sudo timedatectl set-ntp on'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/fulltest-connector.sh
浏览文件 @
72192fe0
python3 ./test.py
-f
3-connectors/restful/restful_binddbname.py
bash 3-connectors/c#/test.sh
bash 3-connectors/go/test.sh
bash 3-connectors/java/test.sh
...
...
@@ -5,3 +8,4 @@ bash 3-connectors/nodejs/test.sh
bash 3-connectors/python/test.sh
bash 3-connectors/restful/test.sh
bash 3-connectors/rust/test.sh
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录