From 570ecb9e079311519dd1cfc45a2a51b0696d1aed Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 10 Aug 2021 19:47:24 +0800 Subject: [PATCH 01/14] [TD-5838] fix tcp test error --- src/util/src/tnettest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 0bab7b7e66..4c180f9bbb 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -466,6 +466,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) { sendpkgLen = pkgLen; } + tsRpcForceTcp = 1; int32_t ret = taosNetCheckRpc(host, port, sendpkgLen, spi, NULL); if (ret < 0) { printf("failed to test TCP port:%d\n", port); @@ -479,6 +480,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) { sendpkgLen = pkgLen; } + tsRpcForceTcp = 0; ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL); if (ret < 0) { printf("failed to test UDP port:%d\n", port); From 6b0fd5b2a35e5ba1299c771123874bb69dd405e9 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 13:54:19 +0800 Subject: [PATCH 02/14] [TD-5838] add function of speed test --- src/kit/shell/inc/shell.h | 2 + src/kit/shell/src/shellLinux.c | 13 +++++ src/kit/shell/src/shellMain.c | 4 +- src/kit/shell/src/shellWindows.c | 20 +++++++ src/util/inc/tnettest.h | 2 +- src/util/src/tnettest.c | 96 ++++++++++++++++++++++++++++++-- 6 files changed, 131 insertions(+), 6 deletions(-) diff --git a/src/kit/shell/inc/shell.h b/src/kit/shell/inc/shell.h index 2374150c52..e19a18c9b7 100644 --- a/src/kit/shell/inc/shell.h +++ b/src/kit/shell/inc/shell.h @@ -56,6 +56,8 @@ typedef struct SShellArguments { int abort; int port; int pktLen; + int pktNum; + char* pktType, char* netTestRole; } SShellArguments; diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index dc74f6fcaa..fcba3a4426 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -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; diff --git a/src/kit/shell/src/shellMain.c b/src/kit/shell/src/shellMain.c index 0c70386061..eb6e2effc2 100644 --- a/src/kit/shell/src/shellMain.c +++ b/src/kit/shell/src/shellMain.c @@ -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); } diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 87d11a3516..ce161d89b7 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -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); diff --git a/src/util/inc/tnettest.h b/src/util/inc/tnettest.h index b7585bd715..8a03b67628 100644 --- a/src/util/inc/tnettest.h +++ b/src/util/inc/tnettest.h @@ -20,7 +20,7 @@ extern "C" { #endif -void taosNetTest(char *role, char *host, int port, int pkgLen); +void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, int32_t pkgNum, char *pkgType); #ifdef __cplusplus } diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 4c180f9bbb..fccdf1b24e 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -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); } From 2f91838e8eabc1d28e4373a670f2b5596aab5717 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 13:58:32 +0800 Subject: [PATCH 03/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index fccdf1b24e..6519f56121 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -626,7 +626,7 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, tscEmbedded = 1; if (host == NULL) host = tsLocalFqdn; if (port == 0) port = tsServerPort; - if (0 == strcmp("speed", role){ + 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; From d7311c0eaa8efcb135ede7f8b852fee06e1ba028 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 13:59:58 +0800 Subject: [PATCH 04/14] [TD-5838] add function of speed test --- src/kit/shell/inc/shell.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kit/shell/inc/shell.h b/src/kit/shell/inc/shell.h index e19a18c9b7..4d72d36e2e 100644 --- a/src/kit/shell/inc/shell.h +++ b/src/kit/shell/inc/shell.h @@ -56,8 +56,8 @@ typedef struct SShellArguments { int abort; int port; int pktLen; - int pktNum; - char* pktType, + int pktNum; + char* pktType; char* netTestRole; } SShellArguments; From c388d7b818881a48dbc418863b389f16d44ac6c3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:16:26 +0800 Subject: [PATCH 05/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 6519f56121..c946d87ff6 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -567,20 +567,6 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, 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; @@ -596,6 +582,21 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, int64_t startT = taosGetTimestampMs(); for (int32_t i = 0; i < pkgNum; i++) { int64_t startTime = taosGetTimestampMs(); + + 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"); + rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); int code = 0; @@ -606,6 +607,8 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, totalSucc ++; } + rpcFreeCont(rspMsg.pCont); + 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); @@ -613,7 +616,7 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, 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 From 684d9d911cbee77fcdf1e6d33596341cd5bb68c4 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:23:26 +0800 Subject: [PATCH 06/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index c946d87ff6..68a432ab79 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -27,10 +27,10 @@ #include "syncMsg.h" #define MAX_PKG_LEN (64 * 1000) -#define MAX_SPEED_PKG_LEN (1024 * 1024) +#define MAX_SPEED_PKG_LEN (1024 * 1024 * 1024) #define MIN_SPEED_PKG_LEN 1024 #define MAX_SPEED_PKG_NUM 10000 -#define MIN_SPEED_PKG_NUM 10 +#define MIN_SPEED_PKG_NUM 1 #define BUFFER_SIZE (MAX_PKG_LEN + 1024) extern int32_t tsRpcMaxUdpSize; @@ -579,9 +579,9 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, } int32_t totalSucc = 0; - int64_t startT = taosGetTimestampMs(); - for (int32_t i = 0; i < pkgNum; i++) { - int64_t startTime = taosGetTimestampMs(); + int64_t startT = taosGetTimestampUs(); + for (int32_t i = 1; i <= pkgNum; i++) { + int64_t startTime = taosGetTimestampUs(); memset(&epSet, 0, sizeof(SRpcEpSet)); epSet.inUse = 0; @@ -609,11 +609,11 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, rpcFreeCont(rspMsg.pCont); - int64_t endTime = taosGetTimestampMs(); + int64_t endTime = taosGetTimestampUs(); 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(); + int64_t endT = taosGetTimestampUs(); 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); @@ -632,8 +632,8 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, 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; + if (pkgNum <= MIN_SPEED_PKG_NUM) pkgNum = MIN_SPEED_PKG_NUM; + if (pkgNum > MAX_SPEED_PKG_NUM) pkgNum = MAX_SPEED_PKG_NUM; }else{ if (pkgLen <= 10) pkgLen = 1000; if (pkgLen > MAX_PKG_LEN) pkgLen = MAX_PKG_LEN; From 4ff07fe4152629c5a6eedf2d9f1b6908a66255a9 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:32:01 +0800 Subject: [PATCH 07/14] [TD-5838] add function of speed test --- src/kit/shell/src/shellMain.c | 2 +- src/util/src/tnettest.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kit/shell/src/shellMain.c b/src/kit/shell/src/shellMain.c index eb6e2effc2..496dac8524 100644 --- a/src/kit/shell/src/shellMain.c +++ b/src/kit/shell/src/shellMain.c @@ -118,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, args.pktLen, args.pktType); + taosNetTest(args.netTestRole, args.host, args.port, args.pktLen, args.pktNum, args.pktType); exit(0); } diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 68a432ab79..b88ab7e6e6 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -552,7 +552,7 @@ 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); + uInfo("check spend, host:%s port:%d pkgLen:%d pkgNum:%d pkgType:%s", host, port, pkgLen, pkgNum, pkgType); SRpcEpSet epSet; SRpcMsg reqMsg; @@ -579,9 +579,9 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, } int32_t totalSucc = 0; - int64_t startT = taosGetTimestampUs(); + uint64_t startT = taosGetTimestampUs(); for (int32_t i = 1; i <= pkgNum; i++) { - int64_t startTime = taosGetTimestampUs(); + uint64_t startTime = taosGetTimestampUs(); memset(&epSet, 0, sizeof(SRpcEpSet)); epSet.inUse = 0; @@ -609,13 +609,13 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, rpcFreeCont(rspMsg.pCont); - int64_t endTime = taosGetTimestampUs(); - 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); + uint64_t endTime = taosGetTimestampUs(); + uint64_t el = endTime - startTime; + printf("progress: %5d/%d, status: %d, cost: %8" PRId64 " ms, speed: %8.2lf KB/s\n", i, pkgNum, code, el, pkgLen/(el/1000000.0)/1024); } int64_t endT = taosGetTimestampUs(); - 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); + uint64_t elT = endT - startT; + printf("total: %5d/%d, cost: %8" PRId64 " ms, speed: %8.2lf KB/s\n", totalSucc, pkgNum, elT, pkgLen * totalSucc/(elT/1000000.0)/1024); rpcClose(pRpcConn); From a40d817ac063eda80b83dcf7e8a6a93aeacfaf1b Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:41:00 +0800 Subject: [PATCH 08/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index b88ab7e6e6..914750f5f8 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -611,11 +611,11 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, uint64_t endTime = taosGetTimestampUs(); uint64_t el = endTime - startTime; - printf("progress: %5d/%d, status: %d, cost: %8" PRId64 " ms, speed: %8.2lf KB/s\n", i, pkgNum, code, el, pkgLen/(el/1000000.0)/1024); + printf("progress: %5d/%d, status: %d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", i, pkgNum, code, el/1000.0, pkgLen/(el/1000000.0)/1024.0/1024.0); } int64_t endT = taosGetTimestampUs(); uint64_t elT = endT - startT; - printf("total: %5d/%d, cost: %8" PRId64 " ms, speed: %8.2lf KB/s\n", totalSucc, pkgNum, elT, pkgLen * totalSucc/(elT/1000000.0)/1024); + printf("total succ: %5d/%d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen * totalSucc/(elT/1000000.0)/1024.0/1024.0); rpcClose(pRpcConn); From 8cb3fb045bbce8776883a6eee7760e8c623bee34 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:57:20 +0800 Subject: [PATCH 09/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 914750f5f8..cf83ae61f0 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -615,7 +615,7 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, } int64_t endT = taosGetTimestampUs(); uint64_t elT = endT - startT; - printf("total succ: %5d/%d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen * totalSucc/(elT/1000000.0)/1024.0/1024.0); + printf("total succ: %5d/%d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen/(elT/1000000.0)/1024.0/1024.0*totalSucc); rpcClose(pRpcConn); From 198f93ed4ea389449e40680b48d1599d8b929f9e Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 18:02:36 +0800 Subject: [PATCH 10/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index cf83ae61f0..a44bbb3df4 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -611,11 +611,11 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, uint64_t endTime = taosGetTimestampUs(); uint64_t el = endTime - startTime; - printf("progress: %5d/%d, status: %d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", i, pkgNum, code, el/1000.0, pkgLen/(el/1000000.0)/1024.0/1024.0); + printf("progress:%5d/%d\t\tstatus:%d\t\tcost:%8.2lf ms\t\tspeed:%8.2lf MB/s\n", i, pkgNum, code, el/1000.0, pkgLen/(el/1000000.0)/1024.0/1024.0); } int64_t endT = taosGetTimestampUs(); uint64_t elT = endT - startT; - printf("total succ: %5d/%d, cost: %10.2lf ms, speed: %10.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen/(elT/1000000.0)/1024.0/1024.0*totalSucc); + printf("\ntotal succ:%5d/%d\t\tcost:%8.2lf ms\t\tspeed:%8.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen/(elT/1000000.0)/1024.0/1024.0*totalSucc); rpcClose(pRpcConn); From 8017ce03b2c6333c008cda7f4896bed567017f53 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 18:04:09 +0800 Subject: [PATCH 11/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index a44bbb3df4..bfbbfd3415 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -611,11 +611,11 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, uint64_t endTime = taosGetTimestampUs(); uint64_t el = endTime - startTime; - printf("progress:%5d/%d\t\tstatus:%d\t\tcost:%8.2lf ms\t\tspeed:%8.2lf MB/s\n", i, pkgNum, code, el/1000.0, pkgLen/(el/1000000.0)/1024.0/1024.0); + printf("progress:%5d/%d\tstatus:%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\n", i, pkgNum, code, el/1000.0, pkgLen/(el/1000000.0)/1024.0/1024.0); } int64_t endT = taosGetTimestampUs(); uint64_t elT = endT - startT; - printf("\ntotal succ:%5d/%d\t\tcost:%8.2lf ms\t\tspeed:%8.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen/(elT/1000000.0)/1024.0/1024.0*totalSucc); + printf("\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\n", totalSucc, pkgNum, elT/1000.0, pkgLen/(elT/1000000.0)/1024.0/1024.0*totalSucc); rpcClose(pRpcConn); From 6cf5becd39d1a384a835b379d2b6143f8f3a30f3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 18:18:56 +0800 Subject: [PATCH 12/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index bfbbfd3415..8e6dd7e20e 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -570,11 +570,14 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, // record config int32_t compressTmp = tsCompressMsgSize; int32_t maxUdpSize = tsRpcMaxUdpSize; + int32_t forceTcp = tsRpcForceTcp; tsCompressMsgSize = -1; if (0 == strcmp("TCP", pkgType)){ + tsRpcForceTcp = 1; tsRpcMaxUdpSize = 0; // force tcp } else { + tsRpcForceTcp = 0; tsRpcMaxUdpSize = INT_MAX; } @@ -622,6 +625,7 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, // return config tsCompressMsgSize = compressTmp; tsRpcMaxUdpSize = maxUdpSize; + tsRpcForceTcp = forceTcp; } void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, From 6c8f6e153a98435cdfb5ce50bffc74ce8da6af5a Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 23:46:16 +0800 Subject: [PATCH 13/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 63 ++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 8e6dd7e20e..435c1e936f 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -548,39 +548,49 @@ static void taosNetTestServer(char *host, int32_t startPort, 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", 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; +static void taosNetTestFqdn(char *host) { + int code = 0; + uint64_t startTime = taosGetTimestampUs(); + uint32_t ip = taosGetIpv4FromFqdn(host); + if (ip == 0xffffffff) { + uError("failed to get IP address from %s since %s", host, strerror(errno)); + code = -1; } + uint64_t endTime = taosGetTimestampUs(); + uint64_t el = endTime - startTime; + printf("check convert fqdn spend, statuw: %d\tcost: %" PRIu64 " us\n", code, el); + return; +} +static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, + int32_t pkgNum, char *pkgType) { // record config int32_t compressTmp = tsCompressMsgSize; int32_t maxUdpSize = tsRpcMaxUdpSize; int32_t forceTcp = tsRpcForceTcp; - tsCompressMsgSize = -1; - if (0 == strcmp("TCP", pkgType)){ + if (0 == strcmp("tcp", pkgType)){ tsRpcForceTcp = 1; tsRpcMaxUdpSize = 0; // force tcp } else { tsRpcForceTcp = 0; tsRpcMaxUdpSize = INT_MAX; } + tsCompressMsgSize = -1; + SRpcEpSet epSet; + SRpcMsg reqMsg; + SRpcMsg rspMsg; + void * pRpcConn; + char secretEncrypt[32] = {0}; + char spi = 0; + pRpcConn = taosNetInitRpc(secretEncrypt, spi); + if (NULL == pRpcConn) { + uError("failed to init client rpc"); + return; + } + + printf("check net spend, host:%s port:%d pkgLen:%d pkgNum:%d pkgType:%s\n", host, port, pkgLen, pkgNum, pkgType); int32_t totalSucc = 0; uint64_t startT = taosGetTimestampUs(); for (int32_t i = 1; i <= pkgNum; i++) { @@ -626,6 +636,18 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, tsCompressMsgSize = compressTmp; tsRpcMaxUdpSize = maxUdpSize; tsRpcForceTcp = forceTcp; + return; +} + +static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, + int32_t pkgNum, char *pkgType) { + if (0 == strcmp("fqdn", pkgType)){ + taosNetTestFqdn(host); + return; + } + + taosNetCheckSpeed(host, port, pkgLen, pkgNum, pkgType); + return; } void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, @@ -656,7 +678,8 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen, taosNetTestStartup(host, port); } else if (0 == strcmp("speed", role)) { tscEmbedded = 0; - taosNetTestSpeed(host, port, pkgLen, pkgNum, pkgType); + char type[10] = {0}; + taosNetTestSpeed(host, port, pkgLen, pkgNum, strtolower(type, pkgType)); }else { taosNetTestStartup(host, port); } From 6b0dfd475e86096f9567e6c1163f41cbcd933a86 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 12 Aug 2021 09:42:57 +0800 Subject: [PATCH 14/14] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 435c1e936f..153ad346db 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -558,7 +558,7 @@ static void taosNetTestFqdn(char *host) { } uint64_t endTime = taosGetTimestampUs(); uint64_t el = endTime - startTime; - printf("check convert fqdn spend, statuw: %d\tcost: %" PRIu64 " us\n", code, el); + printf("check convert fqdn spend, status: %d\tcost: %" PRIu64 " us\n", code, el); return; } @@ -590,7 +590,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, return; } - printf("check net spend, host:%s port:%d pkgLen:%d pkgNum:%d pkgType:%s\n", host, port, pkgLen, pkgNum, pkgType); + printf("check net spend, host:%s port:%d pkgLen:%d pkgNum:%d pkgType:%s\n\n", host, port, pkgLen, pkgNum, pkgType); int32_t totalSucc = 0; uint64_t startT = taosGetTimestampUs(); for (int32_t i = 1; i <= pkgNum; i++) {