[TD-13558]<feature>: taos shell refactor (#10967)
* [TD-13558]<feature>: taos shell refactor add taosTools as submodule * add tools/taos-tools * add more client interface for taosTools compile * update taos-tools * update taos-tools * refactor shell * [TD-13558]<feature>: taos shell test speed * [TD-13558]<feature>: taos -n startup works * taos -n rpc works * taos -n server works * cleanup code since no endPort in 3.0
This commit is contained in:
parent
7a6c8e08bb
commit
5f9e660f9b
|
@ -78,8 +78,6 @@ typedef enum {
|
|||
|
||||
extern char *qtypeStr[];
|
||||
|
||||
#define TSDB_PORT_DNODEDNODE 5
|
||||
#define TSDB_PORT_SYNC 10
|
||||
#define TSDB_PORT_HTTP 11
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -58,7 +58,7 @@ static struct argp_option options[] = {
|
|||
{"check", 'k', "CHECK", 0, "Check tables."},
|
||||
{"database", 'd', "DATABASE", 0, "Database to use when connecting to the server."},
|
||||
{"timezone", 'z', "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|speen|fqdn."},
|
||||
{"netrole", 'n', "NETROLE", 0, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|speed|fqdn."},
|
||||
{"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."},
|
||||
// Shuduo: 3.0 does not support UDP any more
|
||||
|
|
|
@ -406,7 +406,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
|
|||
reqMsg.code = 0;
|
||||
reqMsg.handle = NULL; // rpc handle returned to app
|
||||
reqMsg.ahandle = NULL; // app handle set by client
|
||||
strcpy(reqMsg.pCont, "nettest");
|
||||
strcpy(reqMsg.pCont, "dnode-nettest");
|
||||
|
||||
rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg);
|
||||
|
||||
|
@ -442,7 +442,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
|
|||
|
||||
SStartupReq *pStep = malloc(sizeof(SStartupReq));
|
||||
while (1) {
|
||||
int32_t code = taosNetCheckRpc(host, port + TSDB_PORT_DNODEDNODE, 20, 0, pStep);
|
||||
int32_t code = taosNetCheckRpc(host, port, 20, 0, pStep);
|
||||
if (code > 0) {
|
||||
code = taosNetParseStartup(pStep);
|
||||
}
|
||||
|
@ -499,48 +499,46 @@ static void taosNetCheckSync(char *host, int32_t port) {
|
|||
}
|
||||
|
||||
static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
|
||||
int32_t endPort = startPort + TSDB_PORT_SYNC;
|
||||
char spi = 0;
|
||||
|
||||
uInfo("check rpc, host:%s startPort:%d endPort:%d pkgLen:%d\n", host, startPort, endPort, pkgLen);
|
||||
uInfo("check rpc, host:%s Port:%d pkgLen:%d\n", host, startPort, pkgLen);
|
||||
|
||||
for (uint16_t port = startPort; port < endPort; port++) {
|
||||
int32_t sendpkgLen;
|
||||
if (pkgLen <= tsRpcMaxUdpSize) {
|
||||
uint16_t port = startPort;
|
||||
int32_t sendpkgLen;
|
||||
if (pkgLen <= tsRpcMaxUdpSize) {
|
||||
sendpkgLen = tsRpcMaxUdpSize + 1000;
|
||||
} else {
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
printf("successed to test TCP port:%d\n", port);
|
||||
}
|
||||
|
||||
if (pkgLen >= tsRpcMaxUdpSize) {
|
||||
sendpkgLen = tsRpcMaxUdpSize - 1000;
|
||||
} else {
|
||||
sendpkgLen = pkgLen;
|
||||
}
|
||||
|
||||
tsRpcForceTcp = 0;
|
||||
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
|
||||
if (ret < 0) {
|
||||
printf("failed to test UDP port:%d\n", port);
|
||||
} else {
|
||||
printf("successed to test UDP port:%d\n", port);
|
||||
}
|
||||
}
|
||||
|
||||
taosNetCheckSync(host, startPort + TSDB_PORT_SYNC);
|
||||
tsRpcForceTcp = 1;
|
||||
int32_t ret = taosNetCheckRpc(host, port, sendpkgLen, spi, NULL);
|
||||
if (ret < 0) {
|
||||
printf("failed to test TCP port:%d\n", port);
|
||||
} else {
|
||||
printf("successed to test TCP port:%d\n", port);
|
||||
}
|
||||
|
||||
if (pkgLen >= tsRpcMaxUdpSize) {
|
||||
sendpkgLen = tsRpcMaxUdpSize - 1000;
|
||||
} else {
|
||||
sendpkgLen = pkgLen;
|
||||
}
|
||||
/*
|
||||
tsRpcForceTcp = 0;
|
||||
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
|
||||
if (ret < 0) {
|
||||
printf("failed to test UDP port:%d\n", port);
|
||||
} else {
|
||||
printf("successed to test UDP port:%d\n", port);
|
||||
}
|
||||
*/
|
||||
|
||||
taosNetCheckSync(host, startPort);
|
||||
}
|
||||
|
||||
static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
|
||||
int32_t endPort = startPort + 11;
|
||||
uInfo("work as client, host:%s startPort:%d endPort:%d pkgLen:%d\n", host, startPort, endPort, pkgLen);
|
||||
uInfo("work as client, host:%s Port:%d pkgLen:%d\n", host, startPort, pkgLen);
|
||||
|
||||
uint32_t serverIp = taosGetIpv4FromFqdn(host);
|
||||
if (serverIp == 0xFFFFFFFF) {
|
||||
|
@ -549,15 +547,14 @@ static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
|
|||
}
|
||||
|
||||
uInfo("server ip:%s is resolved from host:%s", taosIpStr(serverIp), host);
|
||||
taosNetCheckPort(serverIp, startPort, endPort, pkgLen);
|
||||
taosNetCheckPort(serverIp, startPort, startPort, pkgLen);
|
||||
}
|
||||
|
||||
static void taosNetTestServer(char *host, int32_t startPort, int32_t pkgLen) {
|
||||
int32_t endPort = startPort + 11;
|
||||
uInfo("work as server, host:%s startPort:%d endPort:%d pkgLen:%d\n", host, startPort, endPort, pkgLen);
|
||||
uInfo("work as server, host:%s Port:%d pkgLen:%d\n", host, startPort, pkgLen);
|
||||
|
||||
int32_t port = startPort;
|
||||
int32_t num = endPort - startPort + 1;
|
||||
int32_t num = 1;
|
||||
if (num < 0) num = 1;
|
||||
|
||||
TdThread *pids = malloc(2 * num * sizeof(TdThread));
|
||||
|
|
Loading…
Reference in New Issue