Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
afa69d79
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,发现更多精彩内容 >>
未验证
提交
afa69d79
编写于
11月 26, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 26, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4360 from taosdata/xiaoping/add_test_case2
[TD-2240] <test> update restfulInsert
上级
b7119d3d
65167295
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
13 deletion
+24
-13
tests/pytest/insert/restfulInsert.py
tests/pytest/insert/restfulInsert.py
+24
-13
未找到文件。
tests/pytest/insert/restfulInsert.py
浏览文件 @
afa69d79
...
...
@@ -18,10 +18,10 @@ import time
import
argparse
class
RestfulInsert
:
def
__init__
(
self
,
host
,
dbname
,
threads
,
tables
,
records
,
batchSize
,
tbNamePerfix
,
outOfOrder
):
def
__init__
(
self
,
host
,
startTimestamp
,
dbname
,
threads
,
tables
,
records
,
batchSize
,
tbNamePerfix
,
outOfOrder
):
self
.
header
=
{
'Authorization'
:
'Basic cm9vdDp0YW9zZGF0YQ=='
}
self
.
url
=
"http://%s:6041/rest/sql"
%
host
self
.
ts
=
1500000000000
self
.
ts
=
startTimestamp
self
.
dbname
=
dbname
self
.
numOfThreads
=
threads
self
.
numOfTables
=
tables
...
...
@@ -36,8 +36,10 @@ class RestfulInsert:
for
i
in
range
(
tablesPerThread
):
tableID
=
threadID
*
tablesPerThread
name
=
'beijing'
if
tableID
%
2
==
0
else
'shanghai'
data
=
"create table %s.%s%d using %s.meters tags(%d, '%s')"
%
(
self
.
dbname
,
self
.
tableNamePerfix
,
tableID
+
i
,
self
.
dbname
,
tableID
+
i
,
name
)
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
data
=
"create table if not exists %s.%s%d using %s.meters tags(%d, '%s')"
%
(
self
.
dbname
,
self
.
tableNamePerfix
,
tableID
+
i
,
self
.
dbname
,
tableID
+
i
,
name
)
response
=
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
if
response
.
status_code
!=
200
:
print
(
response
.
content
)
def
insertData
(
self
,
threadID
):
print
(
"thread %d started"
%
threadID
)
...
...
@@ -50,7 +52,9 @@ class RestfulInsert:
values
=
[]
for
k
in
range
(
self
.
batchSize
):
data
+=
"(%d, %d, %d, %d)"
%
(
start
+
j
*
self
.
batchSize
+
k
,
random
.
randint
(
1
,
100
),
random
.
randint
(
1
,
100
),
random
.
randint
(
1
,
100
))
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
response
=
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
if
response
.
status_code
!=
200
:
print
(
response
.
content
)
def
insertUnlimitedData
(
self
,
threadID
):
print
(
"thread %d started"
%
threadID
)
...
...
@@ -76,15 +80,15 @@ class RestfulInsert:
else
:
random
.
shuffle
(
values
)
for
k
in
range
(
len
(
values
)):
data
+=
values
[
k
]
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
data
+=
values
[
k
]
response
=
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
if
response
.
status_code
!=
200
:
print
(
response
.
content
)
def
run
(
self
):
data
=
"drop database if exists %s"
%
self
.
dbname
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
data
=
"create database %s"
%
self
.
dbname
def
run
(
self
):
data
=
"create database if not exists %s"
%
self
.
dbname
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
data
=
"create table %s.meters(ts timestamp, f1 int, f2 int, f3 int) tags(id int, loc nchar(20))"
%
self
.
dbname
data
=
"create table
if not exists
%s.meters(ts timestamp, f1 int, f2 int, f3 int) tags(id int, loc nchar(20))"
%
self
.
dbname
requests
.
post
(
self
.
url
,
data
,
headers
=
self
.
header
)
threads
=
[]
...
...
@@ -120,6 +124,13 @@ parser.add_argument(
default
=
'127.0.0.1'
,
type
=
str
,
help
=
'host name to be connected (default: 127.0.0.1)'
)
parser
.
add_argument
(
'-S'
,
'--start-timestamp'
,
action
=
'store'
,
default
=
1500000000000
,
type
=
int
,
help
=
'insert data from timestamp (default: 1500000000000)'
)
parser
.
add_argument
(
'-d'
,
'--db-name'
,
...
...
@@ -169,5 +180,5 @@ parser.add_argument(
help
=
'The order of test data (default: False)'
)
args
=
parser
.
parse_args
()
ri
=
RestfulInsert
(
args
.
host_name
,
args
.
db_name
,
args
.
number_of_threads
,
args
.
number_of_tables
,
args
.
number_of_records
,
args
.
batch_size
,
args
.
table_name_prefix
,
args
.
out_of_order
)
ri
=
RestfulInsert
(
args
.
host_name
,
args
.
start_timestamp
,
args
.
db_name
,
args
.
number_of_threads
,
args
.
number_of_tables
,
args
.
number_of_records
,
args
.
batch_size
,
args
.
table_name_prefix
,
args
.
out_of_order
)
ri
.
run
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录