Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6b0fd5b2
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b0fd5b2
编写于
8月 11, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5838]<feature> add function of speed test
上级
570ecb9e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
131 addition
and
6 deletion
+131
-6
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+2
-0
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+13
-0
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+3
-1
src/kit/shell/src/shellWindows.c
src/kit/shell/src/shellWindows.c
+20
-0
src/util/inc/tnettest.h
src/util/inc/tnettest.h
+1
-1
src/util/src/tnettest.c
src/util/src/tnettest.c
+92
-4
未找到文件。
src/kit/shell/inc/shell.h
浏览文件 @
6b0fd5b2
...
...
@@ -56,6 +56,8 @@ typedef struct SShellArguments {
int
abort
;
int
port
;
int
pktLen
;
int
pktNum
;
char
*
pktType
,
char
*
netTestRole
;
}
SShellArguments
;
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
6b0fd5b2
...
...
@@ -50,6 +50,8 @@ static struct argp_option options[] = {
{
"timezone"
,
't'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
{
"pkttype"
,
'S'
,
"PKTTYPE"
,
0
,
"Packet type used for net test, default is TCP."
},
{
0
}};
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
...
...
@@ -148,6 +150,17 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
return
-
1
;
}
break
;
case
'N'
:
if
(
arg
)
{
arguments
->
pktNum
=
atoi
(
arg
);
}
else
{
fprintf
(
stderr
,
"Invalid packet number
\n
"
);
return
-
1
;
}
break
;
case
'S'
:
arguments
->
pktType
=
arg
;
break
;
case
OPT_ABORT
:
arguments
->
abort
=
1
;
break
;
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
6b0fd5b2
...
...
@@ -83,6 +83,8 @@ SShellArguments args = {
.
threadNum
=
5
,
.
commands
=
NULL
,
.
pktLen
=
1000
,
.
pktNum
=
100
,
.
pktType
=
"TCP"
,
.
netTestRole
=
NULL
};
...
...
@@ -116,7 +118,7 @@ int main(int argc, char* argv[]) {
printf
(
"Failed to init taos"
);
exit
(
EXIT_FAILURE
);
}
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
);
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktLen
,
args
.
pktType
);
exit
(
0
);
}
...
...
src/kit/shell/src/shellWindows.c
浏览文件 @
6b0fd5b2
...
...
@@ -55,6 +55,10 @@ void printHelp() {
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync."
);
printf
(
"%s%s
\n
"
,
indent
,
"-l"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Packet length used for net test, default is 1000 bytes."
);
printf
(
"%s%s
\n
"
,
indent
,
"-N"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Packet numbers used for net test, default is 100."
);
printf
(
"%s%s
\n
"
,
indent
,
"-S"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Packet type used for net test, default is TCP."
);
printf
(
"%s%s
\n
"
,
indent
,
"-V"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Print program version."
);
...
...
@@ -170,6 +174,22 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-N"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
pktNum
=
atoi
(
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"option -N requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-S"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
pktType
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -S requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-V"
)
==
0
)
{
printVersion
();
exit
(
EXIT_SUCCESS
);
...
...
src/util/inc/tnettest.h
浏览文件 @
6b0fd5b2
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
void
taosNetTest
(
char
*
role
,
char
*
host
,
int
port
,
int
pkgLen
);
void
taosNetTest
(
char
*
role
,
char
*
host
,
int
32_t
port
,
int32_t
pkgLen
,
int32_t
pkgNum
,
char
*
pkgType
);
#ifdef __cplusplus
}
...
...
src/util/src/tnettest.c
浏览文件 @
6b0fd5b2
...
...
@@ -27,6 +27,10 @@
#include "syncMsg.h"
#define MAX_PKG_LEN (64 * 1000)
#define MAX_SPEED_PKG_LEN (1024 * 1024)
#define MIN_SPEED_PKG_LEN 1024
#define MAX_SPEED_PKG_NUM 10000
#define MIN_SPEED_PKG_NUM 10
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
extern
int32_t
tsRpcMaxUdpSize
;
...
...
@@ -544,12 +548,93 @@ static void taosNetTestServer(char *host, int32_t startPort, int32_t pkgLen) {
}
}
void
taosNetTest
(
char
*
role
,
char
*
host
,
int32_t
port
,
int32_t
pkgLen
)
{
static
void
taosNetTestSpeed
(
char
*
host
,
int32_t
port
,
int32_t
pkgLen
,
int32_t
pkgNum
,
char
*
pkgType
)
{
char
spi
=
0
;
uInfo
(
"check spend, host:%s port:%d pkgLen:%d pkgNum:%d pkgType:%s
\\
n"
,
host
,
port
,
pkgLen
,
pkgNum
,
pkgType
);
SRpcEpSet
epSet
;
SRpcMsg
reqMsg
;
SRpcMsg
rspMsg
;
void
*
pRpcConn
;
char
secretEncrypt
[
32
]
=
{
0
};
pRpcConn
=
taosNetInitRpc
(
secretEncrypt
,
spi
);
if
(
NULL
==
pRpcConn
)
{
uError
(
"failed to init client rpc"
);
return
;
}
memset
(
&
epSet
,
0
,
sizeof
(
SRpcEpSet
));
epSet
.
inUse
=
0
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
strcpy
(
epSet
.
fqdn
[
0
],
host
);
reqMsg
.
msgType
=
TSDB_MSG_TYPE_NETWORK_TEST
;
reqMsg
.
pCont
=
rpcMallocCont
(
pkgLen
);
reqMsg
.
contLen
=
pkgLen
;
reqMsg
.
code
=
0
;
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
strcpy
(
reqMsg
.
pCont
,
"nettest speed"
);
// record config
int32_t
compressTmp
=
tsCompressMsgSize
;
int32_t
maxUdpSize
=
tsRpcMaxUdpSize
;
tsCompressMsgSize
=
-
1
;
if
(
0
==
strcmp
(
"TCP"
,
pkgType
)){
tsRpcMaxUdpSize
=
0
;
// force tcp
}
else
{
tsRpcMaxUdpSize
=
INT_MAX
;
}
int32_t
totalSucc
=
0
;
int64_t
startT
=
taosGetTimestampMs
();
for
(
int32_t
i
=
0
;
i
<
pkgNum
;
i
++
)
{
int64_t
startTime
=
taosGetTimestampMs
();
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
int
code
=
0
;
if
((
rspMsg
.
code
!=
0
)
||
(
rspMsg
.
msgType
!=
TSDB_MSG_TYPE_NETWORK_TEST
+
1
))
{
uError
(
"ret code 0x%x %s"
,
rspMsg
.
code
,
tstrerror
(
rspMsg
.
code
));
code
=
-
1
;
}
else
{
totalSucc
++
;
}
int64_t
endTime
=
taosGetTimestampMs
();
int32_t
el
=
endTime
-
startTime
;
printf
(
"progress: %5d/%d, status: %d, cost: %10d ms, speed: %10.2lf KB/s
\n
"
,
i
,
pkgNum
,
code
,
el
,
pkgLen
/
(
el
/
1000
.
0
)
/
1024
);
}
int64_t
endT
=
taosGetTimestampMs
();
int32_t
elT
=
endT
-
startT
;
printf
(
"total: %5d/%d, cost: %10d ms, speed: %10.2lf KB/s
\n
"
,
totalSucc
,
pkgNum
,
elT
,
pkgLen
*
totalSucc
/
(
elT
/
1000
.
0
)
/
1024
);
rpcFreeCont
(
rspMsg
.
pCont
);
rpcClose
(
pRpcConn
);
// return config
tsCompressMsgSize
=
compressTmp
;
tsRpcMaxUdpSize
=
maxUdpSize
;
}
void
taosNetTest
(
char
*
role
,
char
*
host
,
int32_t
port
,
int32_t
pkgLen
,
int32_t
pkgNum
,
char
*
pkgType
)
{
tscEmbedded
=
1
;
if
(
host
==
NULL
)
host
=
tsLocalFqdn
;
if
(
port
==
0
)
port
=
tsServerPort
;
if
(
pkgLen
<=
10
)
pkgLen
=
1000
;
if
(
pkgLen
>
MAX_PKG_LEN
)
pkgLen
=
MAX_PKG_LEN
;
if
(
0
==
strcmp
(
"speed"
,
role
){
if
(
pkgLen
<=
MIN_SPEED_PKG_LEN
)
pkgLen
=
MIN_SPEED_PKG_LEN
;
if
(
pkgLen
>
MAX_SPEED_PKG_LEN
)
pkgLen
=
MAX_SPEED_PKG_LEN
;
if
(
pkgNum
<=
MIN_SPEED_PKG_NUM
)
pkgLen
=
MIN_SPEED_PKG_NUM
;
if
(
pkgNum
>
MAX_SPEED_PKG_NUM
)
pkgLen
=
MAX_SPEED_PKG_NUM
;
}
else
{
if
(
pkgLen
<=
10
)
pkgLen
=
1000
;
if
(
pkgLen
>
MAX_PKG_LEN
)
pkgLen
=
MAX_PKG_LEN
;
}
if
(
0
==
strcmp
(
"client"
,
role
))
{
taosNetTestClient
(
host
,
port
,
pkgLen
);
...
...
@@ -562,7 +647,10 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen) {
taosNetCheckSync
(
host
,
port
);
}
else
if
(
0
==
strcmp
(
"startup"
,
role
))
{
taosNetTestStartup
(
host
,
port
);
}
else
{
}
else
if
(
0
==
strcmp
(
"speed"
,
role
))
{
tscEmbedded
=
0
;
taosNetTestSpeed
(
host
,
port
,
pkgLen
,
pkgNum
,
pkgType
);
}
else
{
taosNetTestStartup
(
host
,
port
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录