提交 a536e608 编写于 作者: S Shengliang Guan

add show dnodes case

上级 c6e81f92
......@@ -826,7 +826,7 @@ typedef struct SShowRsp {
} SShowRsp;
typedef struct {
char ep[TSDB_FQDN_LEN]; // end point, hostname:port
char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port
int32_t port;
} SCreateDnodeMsg;
......
......@@ -91,7 +91,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9042");
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9042);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
......@@ -148,7 +149,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9043");
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9043);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
......@@ -159,7 +161,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9044");
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(904);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
......@@ -170,7 +173,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9045");
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9045);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
......
......@@ -102,7 +102,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->ep, "localhost:9062");
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9062);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
......
......@@ -386,20 +386,16 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
dnodeObj.id = sdbGetMaxId(pMnode->pSdb, SDB_DNODE);
dnodeObj.createdTime = taosGetTimestampMs();
dnodeObj.updateTime = dnodeObj.createdTime;
taosGetFqdnPortFromEp(pCreate->ep, dnodeObj.fqdn, &dnodeObj.port);
if (dnodeObj.fqdn[0] == 0 || dnodeObj.port <= 0) {
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr());
return terrno;
}
dnodeObj.port = pCreate->port;
memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
snprintf(dnodeObj.ep, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
if (pTrans == NULL) {
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr());
mError("dnode:%s, failed to create since %s", dnodeObj.ep, terrstr());
return -1;
}
mDebug("trans:%d, used to create dnode:%s", pTrans->id, pCreate->ep);
mDebug("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
SSdbRaw *pRedoRaw = mndDnodeActionEncode(&dnodeObj);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
......@@ -423,17 +419,20 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode;
SCreateDnodeMsg *pCreate = pMsg->rpcMsg.pCont;
mDebug("dnode:%s, start to create", pCreate->ep);
mDebug("dnode:%s:%d, start to create", pCreate->fqdn, pCreate->port);
if (pCreate->ep[0] == 0) {
pCreate->port = htonl(pCreate->port);
if (pCreate->fqdn[0] == 0 || pCreate->port <= 0 || pCreate->port > UINT16_MAX) {
terrno = TSDB_CODE_MND_INVALID_DNODE_EP;
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr());
mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
return -1;
}
SDnodeObj *pDnode = mndAcquireDnodeByEp(pMnode, pCreate->ep);
char ep[TSDB_EP_LEN];
snprintf(ep, TSDB_EP_LEN, "%s:%d", pCreate->fqdn, pCreate->port);
SDnodeObj *pDnode = mndAcquireDnodeByEp(pMnode, ep);
if (pDnode != NULL) {
mError("dnode:%d, already exist", pDnode->id);
mError("dnode:%d, already exist, %s:%u", pDnode->id, pCreate->fqdn, pCreate->port);
mndReleaseDnode(pMnode, pDnode);
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
return -1;
......@@ -442,7 +441,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
int32_t code = mndCreateDnode(pMnode, pMsg, pCreate);
if (code != 0) {
mError("dnode:%s, failed to create since %s", pCreate->ep, terrstr());
mError("dnode:%s:%d, failed to create since %s", pCreate->fqdn, pCreate->port, terrstr());
return -1;
}
......
......@@ -414,8 +414,8 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return NULL;
}
strncpy(pCreate->ep, id->z, id->n);
pCreate->port = val;
strncpy(pCreate->fqdn, id->z, id->n);
pCreate->port = htonl(val);
*len = sizeof(SCreateDnodeMsg);
return pCreate;
......
......@@ -33,7 +33,9 @@ if $data02 != master then
endi
print =============== create dnodes
sql create dnode $hostname2
sql create dnode $hostname port 7200
sleep 2000
sql show dnodes;
if $rows != 2 then
return -1
......@@ -47,6 +49,22 @@ if $data10 != 2 then
return -1
endi
if $data02 != 0 then
return -1
endi
if $data12 != 0 then
return -1
endi
if $data04 != ready then
return -1
endi
if $data14 != ready then
return -1
endi
sql show mnodes;
if $rows != 1 then
return -1
......@@ -56,7 +74,7 @@ if $data00 != 1 then
return -1
endi
if $data01 != master then
if $data02 != master then
return -1
endi
......
......@@ -42,41 +42,7 @@ char *simParseArbitratorName(char *varName) {
char *simParseHostName(char *varName) {
static char hostName[140];
int32_t index = atoi(varName + 8);
int32_t port = 7100;
switch (index) {
case 1:
port = 7100;
break;
case 2:
port = 7200;
break;
case 3:
port = 7300;
break;
case 4:
port = 7400;
break;
case 5:
port = 7500;
break;
case 6:
port = 7600;
break;
case 7:
port = 7700;
break;
case 8:
port = 7800;
break;
case 9:
port = 7900;
break;
}
sprintf(hostName, "'%s:%d'", simHostName, port);
// simInfo("hostName:%s", hostName);
sprintf(hostName, "%s", simHostName);
return hostName;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册