diff --git a/source/dnode/mgmt/impl/test/util/dndTestDeploy.cpp b/source/dnode/mgmt/impl/test/sut/deploy.cpp similarity index 98% rename from source/dnode/mgmt/impl/test/util/dndTestDeploy.cpp rename to source/dnode/mgmt/impl/test/sut/deploy.cpp index 4b4f0fa763..132ce54ec6 100644 --- a/source/dnode/mgmt/impl/test/util/dndTestDeploy.cpp +++ b/source/dnode/mgmt/impl/test/sut/deploy.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "dndTestDeploy.h" +#include "deploy.h" void initLog(char *path) { mDebugFlag = 207; @@ -80,7 +80,7 @@ void dropServer(SServer* pServer) { void processClientRsp(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { SClient* pClient = (SClient*)parent; pClient->pRsp = pMsg; - taosMsleep(100000); + //taosMsleep(1000000); tsem_post(&pClient->sem); } diff --git a/source/dnode/mgmt/impl/test/util/dndTestDeploy.h b/source/dnode/mgmt/impl/test/sut/deploy.h similarity index 100% rename from source/dnode/mgmt/impl/test/util/dndTestDeploy.h rename to source/dnode/mgmt/impl/test/sut/deploy.h diff --git a/source/dnode/mgmt/impl/test/test01/CMakeLists.txt b/source/dnode/mgmt/impl/test/test01/CMakeLists.txt index c3037dfdff..5f88e9c116 100644 --- a/source/dnode/mgmt/impl/test/test01/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/test01/CMakeLists.txt @@ -2,8 +2,8 @@ add_executable(dndTest01 "") target_sources(dndTest01 PRIVATE - "dndTest01.cpp" - "../util/dndTestDeploy.cpp" + "test01.cpp" + "../sut/deploy.cpp" ) target_link_libraries( @@ -18,7 +18,7 @@ target_include_directories(dndTest01 PUBLIC "${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt" "${CMAKE_CURRENT_SOURCE_DIR}/../../inc" - "${CMAKE_CURRENT_SOURCE_DIR}/../util" + "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) enable_testing() diff --git a/source/dnode/mgmt/impl/test/test01/dndTest01.cpp b/source/dnode/mgmt/impl/test/test01/test01.cpp similarity index 93% rename from source/dnode/mgmt/impl/test/test01/dndTest01.cpp rename to source/dnode/mgmt/impl/test/test01/test01.cpp index 70f649cc07..6c440074dc 100644 --- a/source/dnode/mgmt/impl/test/test01/dndTest01.cpp +++ b/source/dnode/mgmt/impl/test/test01/test01.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "dndTestDeploy.h" +#include "deploy.h" class DndTest01 : public ::testing::Test { protected: @@ -43,16 +43,16 @@ TEST_F(DndTest01, connectMsg) { sendMsg(pClient, &rpcMsg); - SConnectRsp* pRsp = (SConnectRsp*)pClient->pRsp; - ASSERT(pRsp); + SConnectRsp* pRsp = (SConnectRsp*)pClient->pRsp->pCont; + ASSERT_NE(pRsp, nullptr); pRsp->acctId = htonl(pRsp->acctId); pRsp->clusterId = htonl(pRsp->clusterId); pRsp->connId = htonl(pRsp->connId); - pRsp->epSet.port[0] = htonl(pRsp->epSet.port[0]); + pRsp->epSet.port[0] = htons(pRsp->epSet.port[0]); EXPECT_EQ(pRsp->acctId, 1); EXPECT_GT(pRsp->clusterId, 0); - EXPECT_GT(pRsp->connId, 1); + EXPECT_EQ(pRsp->connId, 1); EXPECT_EQ(pRsp->superAuth, 1); EXPECT_EQ(pRsp->readAuth, 1); EXPECT_EQ(pRsp->writeAuth, 1); diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index e3464cd327..eabcce04c5 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -137,4 +137,24 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) { return true; } -void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {} \ No newline at end of file +void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { + SSdb *pSdb = pMnode->pSdb; + + pEpSet->numOfEps = 0; + + void *pIter = NULL; + while (1) { + SMnodeObj *pMnodeObj = NULL; + pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMnodeObj); + if (pIter == NULL) break; + if (pMnodeObj->pDnode == NULL) break; + + pEpSet->port[pEpSet->numOfEps] = htons(pMnodeObj->pDnode->port); + tstrncpy(pEpSet->fqdn[pEpSet->numOfEps], pMnodeObj->pDnode->fqdn, TSDB_FQDN_LEN); + if (pMnodeObj->role == TAOS_SYNC_STATE_LEADER) { + pEpSet->inUse = pEpSet->numOfEps; + } + + pEpSet->numOfEps++; + } +} \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 2afb5f0665..bdd0ab500a 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -130,6 +130,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, char *user, uint32_t ip, uint16_t static void mndFreeConn(SConnObj *pConn) { tfree(pConn->pQueries); tfree(pConn->pStreams); + tfree(pConn); mDebug("conn:%d, is destroyed", pConn->connId); } diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index f59ef8f8e3..a3dd255577 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -59,6 +59,8 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char taosEncryptPass((uint8_t *)pass, strlen(pass), userObj.pass); userObj.createdTime = taosGetTimestampMs(); userObj.updateTime = userObj.createdTime; + userObj.readAuth = 1; + userObj.writeAuth = 1; if (strcmp(user, TSDB_DEFAULT_USER) == 0) { userObj.superAuth = 1; @@ -95,6 +97,8 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) { SDB_SET_INT64(pRaw, dataPos, pUser->createdTime) SDB_SET_INT64(pRaw, dataPos, pUser->updateTime) SDB_SET_INT8(pRaw, dataPos, pUser->superAuth) + SDB_SET_INT8(pRaw, dataPos, pUser->readAuth) + SDB_SET_INT8(pRaw, dataPos, pUser->writeAuth) SDB_SET_DATALEN(pRaw, dataPos); return pRaw; @@ -121,6 +125,8 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->updateTime) SDB_GET_INT8(pRaw, pRow, dataPos, &pUser->superAuth) + SDB_GET_INT8(pRaw, pRow, dataPos, &pUser->readAuth) + SDB_GET_INT8(pRaw, pRow, dataPos, &pUser->writeAuth) return pRow; } @@ -164,6 +170,8 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pSrcUser, SUserObj *pDs pSrcUser->createdTime = pDstUser->createdTime; pSrcUser->updateTime = pDstUser->updateTime; pSrcUser->superAuth = pDstUser->superAuth; + pSrcUser->readAuth = pDstUser->readAuth; + pSrcUser->writeAuth = pDstUser->writeAuth; return 0; } @@ -185,6 +193,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, userObj.createdTime = taosGetTimestampMs(); userObj.updateTime = userObj.createdTime; userObj.superAuth = 0; + userObj.readAuth = 1; + userObj.writeAuth = 1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, pMsg->rpcMsg.handle); if (pTrans == NULL) return -1;