From 3e0bd397e9912e2c57dde03f1033ebcdbfd5b18d Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 24 Apr 2020 13:18:17 +0800 Subject: [PATCH] [TD-52] [TD-148] add cluster test script --- src/client/src/tscServer.c | 2 ++ src/client/src/tscSystem.c | 2 +- src/dnode/src/dnodeMClient.c | 17 ++++++++++++++++- src/dnode/src/dnodeMnode.c | 2 +- src/inc/dnode.h | 3 ++- src/mnode/src/mgmtDClient.c | 4 +++- src/mnode/src/mgmtDServer.c | 11 ++++++++--- src/mnode/src/mgmtShell.c | 15 ++++++++++----- tests/script/sh/deploy.sh | 2 +- tests/script/unique/mnode/mgmt33.sim | 6 +++--- tests/script/unique/mnode/mgmt34.sim | 6 +++--- 11 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f2570fb229..21980289d6 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -163,11 +163,13 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { tscGetQueryInfoDetailSafely(&pSql->cmd, 0, &pQueryInfo); pQueryInfo->command = TSDB_SQL_HB; + pSql->cmd.command = TSDB_SQL_HB; if (TSDB_CODE_SUCCESS != tscAllocPayload(&(pSql->cmd), TSDB_DEFAULT_PAYLOAD_SIZE)) { tfree(pSql); return; } + pSql->cmd.command = TSDB_SQL_HB; pSql->param = pObj; pSql->pTscObj = pObj; pSql->signature = pSql; diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 6713f84f99..484c9e344e 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -67,7 +67,6 @@ int32_t tscInitRpc(const char *user, const char *secret) { rpcInit.label = "TSC-vnode"; rpcInit.numOfThreads = tscNumOfThreads; rpcInit.cfp = tscProcessMsgFromServer; - rpcInit.ufp = tscUpdateIpSet; rpcInit.sessions = tsMaxVnodeConnections; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.user = (char*)user; @@ -96,6 +95,7 @@ int32_t tscInitRpc(const char *user, const char *secret) { rpcInit.label = "TSC-mgmt"; rpcInit.numOfThreads = 1; rpcInit.cfp = tscProcessMsgFromServer; + rpcInit.ufp = tscUpdateIpSet; rpcInit.sessions = tsMaxMgmtConnections; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = 2000; diff --git a/src/dnode/src/dnodeMClient.c b/src/dnode/src/dnodeMClient.c index ee805a2a0c..151d44922d 100644 --- a/src/dnode/src/dnodeMClient.c +++ b/src/dnode/src/dnodeMClient.c @@ -59,6 +59,19 @@ void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) { tsMnodeIpSet = *pIpSet; } +void dnodeGetMnodeIpSet(void *ipSetRaw, bool usePublicIp) { + SRpcIpSet *ipSet = ipSetRaw; + ipSet->numOfIps = tsMnodeInfos.nodeNum; + ipSet->inUse = tsMnodeInfos.inUse; + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) { + if (usePublicIp) { + ipSet->ip[i] = tsMnodeInfos.nodeInfos[i].nodeIp; + } else { + ipSet->ip[i] = tsMnodeInfos.nodeInfos[i].nodeIp; + } + } +} + int32_t dnodeInitMClient() { dnodeReadDnodeCfg(); tsRebootTime = taosGetTimestampSec(); @@ -138,7 +151,9 @@ static void dnodeProcessRspFromMnode(SRpcMsg *pMsg) { if (tsDnodeProcessMgmtRspFp[pMsg->msgType]) { (*tsDnodeProcessMgmtRspFp[pMsg->msgType])(pMsg); } else { - dError("%s is not processed in mnode rpc client", taosMsg[pMsg->msgType]); + dError("%s is not processed in dnode mclient", taosMsg[pMsg->msgType]); + SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = pMsg->handle}; + rpcSendResponse(&rpcRsp); } rpcFreeCont(pMsg->pCont); diff --git a/src/dnode/src/dnodeMnode.c b/src/dnode/src/dnodeMnode.c index 9672a34a9f..ac477c4de1 100644 --- a/src/dnode/src/dnodeMnode.c +++ b/src/dnode/src/dnodeMnode.c @@ -88,7 +88,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) { if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); } else { - dError("%s is not processed in mserver", taosMsg[pMsg->msgType]); + dError("%s is not processed in dnode mserver", taosMsg[pMsg->msgType]); rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; rpcSendResponse(&rspMsg); rpcFreeCont(pMsg->pCont); diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 618cf79b14..6fbfa7ffa9 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -41,8 +41,9 @@ void *dnodeAllocateRqueue(void *pVnode); void dnodeFreeRqueue(void *rqueue); void dnodeSendRpcWriteRsp(void *pVnode, void *param, int32_t code); -bool dnodeIsFirstDeploy(); +bool dnodeIsFirstDeploy(); uint32_t dnodeGetMnodeMasteIp(); +void dnodeGetMnodeIpSet(void *ipSet, bool usePublicIp); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); diff --git a/src/mnode/src/mgmtDClient.c b/src/mnode/src/mgmtDClient.c index f547128f00..759d400eb8 100644 --- a/src/mnode/src/mgmtDClient.c +++ b/src/mnode/src/mgmtDClient.c @@ -79,7 +79,9 @@ static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) { if (mgmtProcessDnodeRspFp[rpcMsg->msgType]) { (*mgmtProcessDnodeRspFp[rpcMsg->msgType])(rpcMsg); } else { - mError("%s is not processed in dclient", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mgmt dclient", taosMsg[rpcMsg->msgType]); + SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = rpcMsg->handle}; + rpcSendResponse(&rpcRsp); } rpcFreeCont(rpcMsg->pCont); diff --git a/src/mnode/src/mgmtDServer.c b/src/mnode/src/mgmtDServer.c index b551c0eae5..9f65cd5d4a 100644 --- a/src/mnode/src/mgmtDServer.c +++ b/src/mnode/src/mgmtDServer.c @@ -108,8 +108,12 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { bool usePublicIp = false; SRpcIpSet ipSet = {0}; - mgmtGetMnodeIpSet(&ipSet, usePublicIp); - mTrace("conn from dnode ip:%s redirect msg", taosIpStr(connInfo.clientIp)); + ipSet.port = tsMnodeDnodePort; + dnodeGetMnodeIpSet(&ipSet, usePublicIp); + mTrace("conn from dnode ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); + for (int32_t i = 0; i < ipSet.numOfIps; ++i) { + mTrace("index:%d ip:%s", i, taosIpStr(ipSet.ip[i])); + } rpcSendRedirectRsp(rpcMsg->handle, &ipSet); return; } @@ -119,7 +123,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { memcpy(pMsg, rpcMsg, sizeof(SRpcMsg)); mgmtAddToDServerQueue(pMsg); } else { - mError("%s is not processed in dserver", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mgmt dserver", taosMsg[rpcMsg->msgType]); + mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED); rpcFreeCont(rpcMsg->pCont); } } diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 752f33db13..927bbe4ed1 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -151,8 +151,13 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { bool usePublicIp = (connInfo.serverIp == tsPublicIpInt); SRpcIpSet ipSet = {0}; - mgmtGetMnodeIpSet(&ipSet, usePublicIp); - mTrace("conn from ip:%s user:%s redirect msg", taosIpStr(connInfo.clientIp), connInfo.user); + ipSet.port = tsMnodeShellPort; + dnodeGetMnodeIpSet(&ipSet, usePublicIp); + mTrace("conn from shell ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); + for (int32_t i = 0; i < ipSet.numOfIps; ++i) { + mTrace("index:%d ip:%s", i, taosIpStr(ipSet.ip[i])); + } + rpcSendRedirectRsp(rpcMsg->handle, &ipSet); return; } @@ -429,9 +434,9 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { connect_over: rpcRsp.code = code; if (code != TSDB_CODE_SUCCESS) { - mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); + mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code)); } else { - mLPrint("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); + mLPrint("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code)); rpcRsp.pCont = pConnectRsp; rpcRsp.contLen = sizeof(SCMConnectRsp); } @@ -488,7 +493,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) { } static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg) { - mError("%s is not processed in shell", taosMsg[rpcMsg->msgType]); + mError("%s is not processed in mnode shell", taosMsg[rpcMsg->msgType]); SRpcMsg rpcRsp = { .msgType = 0, .pCont = 0, diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index b1aa7c6382..41ba3c425a 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -93,7 +93,7 @@ echo "privateIp $NODE_IP" >> $TAOS_CFG echo "dDebugFlag 199" >> $TAOS_CFG echo "mDebugFlag 199" >> $TAOS_CFG echo "sdbDebugFlag 199" >> $TAOS_CFG -echo "rpcDebugFlag 131" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG echo "cDebugFlag 135" >> $TAOS_CFG echo "httpDebugFlag 131" >> $TAOS_CFG diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim index 629adad029..b2235ca6dc 100644 --- a/tests/script/unique/mnode/mgmt33.sim +++ b/tests/script/unique/mnode/mgmt33.sim @@ -116,7 +116,7 @@ sleep 8000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_4 $dnode3Role = $data3_3 print 192.168.0.1 ==> $dnode1Role print 192.168.0.2 ==> $dnode2Role @@ -138,13 +138,13 @@ sleep 10000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_4 $dnode3Role = $data3_3 print 192.168.0.1 ==> $dnode1Role print 192.168.0.2 ==> $dnode2Role print 192.168.0.3 ==> $dnode3Role -if $dnode1Role != undecided then +if $dnode1Role != offline then return -1 endi #if $dnode2Role != master then diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim index c811728deb..1c12b2ee39 100644 --- a/tests/script/unique/mnode/mgmt34.sim +++ b/tests/script/unique/mnode/mgmt34.sim @@ -183,7 +183,7 @@ endi print ============== step7 system sh/exec_up.sh -n dnode1 -s stop -sleep 10000 +sleep 4000 sql show mnodes $dnode1Role = $data3_1 @@ -195,7 +195,7 @@ print 192.168.0.2 ==> $dnode2Role print 192.168.0.3 ==> $dnode3Role print 192.168.0.4 ==> $dnode4Role -if $dnode1Role != undecided then +if $dnode1Role != offline then return -1 endi @@ -205,7 +205,7 @@ sleep 8000 sql show mnodes $dnode1Role = $data3_1 -$dnode2Role = $data3_2 +$dnode2Role = $data3_5 $dnode3Role = $data3_3 $dnode4Role = $data3_4 print 192.168.0.1 ==> $dnode1Role -- GitLab