mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* enh: rename libtaos.so to libtaosinternal.so * enh: let python system-test work * enh: shell for libinternal.so * enh: refact script * enh: wrapper for libtaosinternal * enh: rename some files * enh: let shell support internal driver * enh: minor changes * enh: minor changes * add intenal.h * enh: remove unused codes * enh: minor changs * feat: mac os issues * enh: let python test use internal connection * enh: let nettest work * enh: let taosc -C work * enh: test shell in mac os * enh: minor changes * enh: let libtaosinternal.so work in linux * enh: update install script * enh: for ci * enh: for windows compile * enh: minor changes * enh: compile in windows * enh: minor changes * enh: taosinternal work in windows * enh: add taos_internal_static * enh: rollback os_for_wrapper * fix: conflicts * fix: conflicts * fix: compile errors * fix: conflicts * enh: rename taosinternal to taosnative * enh: rename taosinternal to taosnative * fix: compile error * enh: remove taosnative.h * fix: compile errors * enh: set default shell options * fix: compile errors * fix: compile errors * debug: switch taosws branch to feat/new-libtaos-with-ws * enh: taosBenchmark remove WEBSOCKET finished * fix: CMakeLists.txt remove WEBSOCKET * fix: compile errors * fix: taosBenchmark delete restful code * .gitignore remove taos-tools folder * fix: remove taosdump WEBSOCKET MACRO * fix: build error for taosdump * fix: build project passed * fix: support -Z for connect mode * fix: build error * fix: build error fixed * fix: add -Z options * fix: native and websocket with string * fix: -Z option core * fix: build unit test * fix: build error * fix: add colon for array * fix: unit test can not include fun * fix: CTest pointer null is nullptr * fix: include pub.h * fix: taosdump add -Z --driver options * fix: taosdump support -Z with pub.h pub.c * fix: toolsGetTimeDay move to pub.c * fix: restore pub.c only simple fun * fix: add error tips * fix: tmfree remove from taosdump * fix: remove double declare taos variant * fix: taos support -Z option * enh: configDir set with main fun * fix: add g_arguments.configDir * fix: show tips add cfgdir * fix: g_argument is pointer * fix: configDir is global var * fix: declare g_configDir in benchMain.c * fix: taos version not show on websocket * stmt2 websocket prepare with supertable * stmt2 websocket prepare build * fix: stmt and stmt2 prepare add db name * fix: remove -R --restful test case * fix: taosBenchmark adjust priority cmd > json > evn * fix: add connect mode test case connMode.py * fix: clear evn and add host port check * fix: army/test.py modify start taosAdapter is default * change: system-test/test.py default start taosAdapter * fix: add taosAdapter variant to system-test/test.py * fix: -y must put behind other options * fix: remove rest sml and add -N normal case * fix: add -c work cfg test case * del: queryMain.py remove rest query * fix: remove groups have a blank append bug * fix: caseBase.py add db in sql query * fix: query_json.py remove rest test * fix: taosBenchmark uniform dsn describe * fix: add pub.h pub.c to tools public * fix: case remove restful interface * fix: build error * fix: taosDriverCleanup no arg call * fix: taosdump add test conn mode case taosdumpCommandline.py * fix: modify insertFullType.json db name * fix: taosdump connMode test case taosDumpCommandline.py passed * enh: priority cmd > env > json * fix: taosCli remove is_native variant * fix: password is not pointer * fix: comment -o test case * fix: solve fun return code check * fix: windows unresolved strcasecmp * fix: remove coverHostToServAddr * fix: forbid check ODR violation * ci: trigger pr run * fix: build error not del >>>>>3.0 * fix: support json dbinfo->vgroups have blank space * fix: solve conflict with merge * fix: with TrimCaseCmp fun to compare vgroups * fix: del vgroups support blank code * feat: wrapper add taos_fetch_fields_e * fix: move jni from libtaosnative.so to libtaos.so * fix: move clientTmqConnector.c for jni * fix: fix assert check with del comment code * fix: taosBenchmark add prepare stmt debug log * fix: stmt2 already have debug log on preapare * fix: (double)LLONG_MAX force covert * fix: stmt insert normal table with websocket * fix: normal table with stmt too many ? * fix: taosdump stmt_prepare with child tbname * fix: build error add int code * feat: stmtPrepare with child table to do * taos -a options move to native test case * fix:unit test benchmarkTest passed * fix: query_json-with-sqlfile.py case no check results * fix: queryMain.py case lost, put in tasks again --------- Co-authored-by: Shengliang Guan <slguan@taosdata.com>
152 lines
4.5 KiB
C
152 lines
4.5 KiB
C
/*
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
*
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
#include "shellInt.h"
|
|
|
|
static void shellWorkAsClient() {
|
|
SShellArgs *pArgs = &shell.args;
|
|
SRpcInit rpcInit = {0};
|
|
SEpSet epSet = {.inUse = 0, .numOfEps = 1};
|
|
SRpcMsg rpcRsp = {0};
|
|
void *clientRpc = NULL;
|
|
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
|
|
|
taosEncryptPass_c((uint8_t *)("_pwd"), strlen("_pwd"), pass);
|
|
rpcInit.label = "CHK";
|
|
rpcInit.numOfThreads = 1;
|
|
rpcInit.sessions = 16;
|
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
|
rpcInit.idleTime = 3000;
|
|
rpcInit.user = "_dnd";
|
|
rpcInit.timeToGetConn = 500000;
|
|
|
|
taosVersionStrToInt(td_version, &rpcInit.compatibilityVer);
|
|
clientRpc = rpcOpen(&rpcInit);
|
|
if (clientRpc == NULL) {
|
|
printf("failed to init net test client since %s\r\n", terrstr());
|
|
goto _OVER;
|
|
}
|
|
|
|
if (pArgs->port == 0) {
|
|
pArgs->port = 6030;
|
|
}
|
|
if (pArgs->host == NULL) {
|
|
pArgs->host = "localhost";
|
|
}
|
|
char fqdn[TSDB_FQDN_LEN] = {0};
|
|
tstrncpy(fqdn, pArgs->host, TSDB_FQDN_LEN);
|
|
strtok(fqdn, ":");
|
|
|
|
printf("network test client is initialized, the server is %s:%u\r\n", fqdn, pArgs->port);
|
|
|
|
tstrncpy(epSet.eps[0].fqdn, fqdn, TSDB_FQDN_LEN);
|
|
epSet.eps[0].port = (uint16_t)pArgs->port;
|
|
|
|
int32_t totalSucc = 0;
|
|
uint64_t startTime = taosGetTimestampUs();
|
|
|
|
for (int32_t i = 0; i < pArgs->pktNum; ++i) {
|
|
SRpcMsg rpcMsg = {.info.ahandle = (void *)0x9525, .info.notFreeAhandle = 1, .msgType = TDMT_DND_NET_TEST};
|
|
rpcMsg.pCont = rpcMallocCont(pArgs->pktLen);
|
|
rpcMsg.contLen = pArgs->pktLen;
|
|
|
|
printf("request is sent, size:%d\r\n", rpcMsg.contLen);
|
|
rpcSendRecv(clientRpc, &epSet, &rpcMsg, &rpcRsp);
|
|
if (rpcRsp.code == 0 && rpcRsp.contLen == rpcMsg.contLen) {
|
|
printf("response is received, size:%d\r\n", rpcMsg.contLen);
|
|
if (rpcRsp.code == 0) totalSucc++;
|
|
} else {
|
|
printf("response not received since %s\r\n", tstrerror(rpcRsp.code));
|
|
}
|
|
|
|
rpcFreeCont(rpcRsp.pCont);
|
|
rpcRsp.pCont = NULL;
|
|
}
|
|
|
|
uint64_t endTime = taosGetTimestampUs();
|
|
uint64_t elT = endTime - startTime;
|
|
|
|
printf("\r\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\r\n", totalSucc, pArgs->pktNum, elT / 1000.0,
|
|
pArgs->pktLen / (elT / 1000000.0) / 1024.0 / 1024.0 * totalSucc);
|
|
|
|
_OVER:
|
|
if (clientRpc != NULL) {
|
|
rpcClose(clientRpc);
|
|
}
|
|
if (rpcRsp.pCont != NULL) {
|
|
rpcFreeCont(rpcRsp.pCont);
|
|
}
|
|
}
|
|
|
|
static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|
printf("request is received, size:%d\r\n", pRpc->contLen);
|
|
fflush(stdout);
|
|
SRpcMsg rsp = {.info = pRpc->info, .code = 0};
|
|
rsp.pCont = rpcMallocCont(pRpc->contLen);
|
|
if (rsp.pCont == NULL) {
|
|
rsp.code = TSDB_CODE_OUT_OF_MEMORY;
|
|
} else {
|
|
rsp.contLen = pRpc->contLen;
|
|
}
|
|
rpcSendResponse(&rsp);
|
|
}
|
|
|
|
void shellNettestHandler(int32_t signum, void *sigInfo, void *context) { shellExit(); }
|
|
|
|
static void shellWorkAsServer() {
|
|
SShellArgs *pArgs = &shell.args;
|
|
|
|
if (pArgs->port == 0) {
|
|
pArgs->port = 6030;
|
|
}
|
|
if (pArgs->host == NULL) {
|
|
pArgs->host = "127.0.0.1";
|
|
}
|
|
|
|
SRpcInit rpcInit = {0};
|
|
memcpy(rpcInit.localFqdn, pArgs->host, strlen(pArgs->host));
|
|
rpcInit.localPort = pArgs->port;
|
|
rpcInit.label = "CHK";
|
|
rpcInit.numOfThreads = 2;
|
|
rpcInit.cfp = (RpcCfp)shellProcessMsg;
|
|
rpcInit.sessions = 10;
|
|
rpcInit.connType = TAOS_CONN_SERVER;
|
|
rpcInit.idleTime = 3000;
|
|
|
|
taosVersionStrToInt(td_version, &rpcInit.compatibilityVer);
|
|
|
|
void *serverRpc = rpcOpen(&rpcInit);
|
|
if (serverRpc == NULL) {
|
|
printf("failed to init net test server since %s\r\n", terrstr());
|
|
} else {
|
|
printf("network test server is initialized, %s:%u\r\n", pArgs->host, pArgs->port);
|
|
taosSetSignal(SIGTERM, shellNettestHandler);
|
|
while (1) taosMsleep(10);
|
|
}
|
|
}
|
|
|
|
void shellTestNetWork() {
|
|
(void)osDefaultInit();
|
|
(void)rpcInit();
|
|
|
|
if (strcmp(shell.args.netrole, "client") == 0) {
|
|
shellWorkAsClient();
|
|
}
|
|
|
|
if (strcmp(shell.args.netrole, "server") == 0) {
|
|
shellWorkAsServer();
|
|
}
|
|
}
|