Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
72ddf72b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
72ddf72b
编写于
6月 30, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
td-797: support SQL argument from command line
上级
c115bb3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
20 deletion
+36
-20
tests/stress/README.md
tests/stress/README.md
+2
-2
tests/stress/main.go
tests/stress/main.go
+34
-18
未找到文件。
tests/stress/README.md
浏览文件 @
72ddf72b
...
...
@@ -5,7 +5,7 @@ Stress test tool for TDengine. It run a set of test cases randomly and show stat
## COMMAND LINE
```
bash
$
./stress
[
-h
=
<localhost>]
[
-P
=
<0>]
[
-d
=
<
test
>]
[
-u
=
<root>]
[
-p
=
<taosdata>]
[
-c
=
<4>]
[
-f
=
<
true
>]
[
test
case
file
]
$
./stress
[
-h
=
<localhost>]
[
-P
=
<0>]
[
-d
=
<
test
>]
[
-u
=
<root>]
[
-p
=
<taosdata>]
[
-c
=
<4>]
[
-f
=
<
true
>]
[
path_or_sql
]
```
*
**-h**
: host name or IP address of TDengine server (default: localhost).
...
...
@@ -14,7 +14,7 @@ $ ./stress [-h=<localhost>] [-P=<0>] [-d=<test>] [-u=<root>] [-p=<taosdata>] [-c
*
**-p**
: password (default: taosdata).
*
**-c**
: concurrency, number of concurrent goroutines for query (default: 4).
*
**-f**
: fetch data or not (default: true).
*
**
test case file**
: the
path of a JSON file which contains the test cases (default: cases.json).
*
**
path_or_sql**
: a SQL statement or
path of a JSON file which contains the test cases (default: cases.json).
## TEST CASE FILE
...
...
tests/stress/main.go
浏览文件 @
72ddf72b
...
...
@@ -28,7 +28,7 @@ type testCase struct {
isQuery
bool
`json:"-"`
numArgs
int
`json:"-"`
Weight
int
`json:"weight"`
S
ql
string
`json:"sql"`
S
QL
string
`json:"sql"`
Args
[]
argument
`json:"args"`
}
...
...
@@ -103,7 +103,7 @@ func (tc *testCase) buildSql() string {
for
i
:=
0
;
i
<
len
(
tc
.
Args
);
i
++
{
args
=
tc
.
Args
[
i
]
.
generate
(
args
)
}
return
fmt
.
Sprintf
(
tc
.
S
ql
,
args
...
)
return
fmt
.
Sprintf
(
tc
.
S
QL
,
args
...
)
}
type
statitics
struct
{
...
...
@@ -129,22 +129,19 @@ var (
cases
[]
testCase
)
func
loadTestCase
(
path
string
)
error
{
f
,
e
:=
os
.
Open
(
path
)
if
e
!=
nil
{
func
loadTestCaseFromFile
(
file
*
os
.
File
)
error
{
if
e
:=
json
.
NewDecoder
(
file
)
.
Decode
(
&
cases
);
e
!=
nil
{
return
e
}
defer
f
.
Close
()
e
=
json
.
NewDecoder
(
f
)
.
Decode
(
&
cases
)
if
e
!=
nil
{
return
e
if
len
(
cases
)
==
0
{
return
fmt
.
Errorf
(
"no test case loaded."
)
}
for
i
:=
0
;
i
<
len
(
cases
);
i
++
{
c
:=
&
cases
[
i
]
c
.
S
ql
=
strings
.
TrimSpace
(
c
.
Sql
)
c
.
isQuery
=
strings
.
ToLower
(
c
.
S
ql
[
:
6
])
==
"select"
c
.
S
QL
=
strings
.
TrimSpace
(
c
.
SQL
)
c
.
isQuery
=
strings
.
ToLower
(
c
.
S
QL
[
:
6
])
==
"select"
if
c
.
Weight
<
0
{
return
fmt
.
Errorf
(
"test %d: negative weight"
,
i
)
}
...
...
@@ -171,6 +168,28 @@ func loadTestCase(path string) error {
return
nil
}
func
loadTestCase
(
pathOrSQL
string
)
error
{
if
f
,
e
:=
os
.
Open
(
pathOrSQL
);
e
==
nil
{
defer
f
.
Close
()
return
loadTestCaseFromFile
(
f
)
}
pathOrSQL
=
strings
.
TrimSpace
(
pathOrSQL
)
if
strings
.
ToLower
(
pathOrSQL
[
:
6
])
!=
"select"
{
return
fmt
.
Errorf
(
"'%s' is not a valid file or SQL statement"
,
pathOrSQL
)
}
cases
=
append
(
cases
,
testCase
{
isQuery
:
true
,
Weight
:
1
,
numArgs
:
0
,
SQL
:
pathOrSQL
,
})
totalWeight
=
1
return
nil
}
func
selectTestCase
()
*
testCase
{
sum
,
target
:=
0
,
rand
.
Intn
(
totalWeight
)
var
c
*
testCase
...
...
@@ -297,16 +316,13 @@ func main() {
flag
.
UintVar
(
&
concurrency
,
"c"
,
4
,
"concurrency, number of goroutines for query"
)
flag
.
Parse
()
caseFile
:=
flag
.
Arg
(
0
)
if
caseFile
==
""
{
caseFile
=
"cases.json"
pathOrSQL
:=
flag
.
Arg
(
0
)
if
len
(
pathOrSQL
)
==
0
{
pathOrSQL
=
"cases.json"
}
if
e
:=
loadTestCase
(
caseFile
);
e
!=
nil
{
if
e
:=
loadTestCase
(
pathOrSQL
);
e
!=
nil
{
fmt
.
Println
(
"failed to load test cases:"
,
e
.
Error
())
return
}
else
if
len
(
cases
)
==
0
{
fmt
.
Println
(
"there's no test case"
)
return
}
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录