未验证 提交 8d482158 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #8931 from taosdata/feature/dnode3

[TD-10431]<feature> add test cases for dnode
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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);
}
......
......@@ -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()
......
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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);
......
......@@ -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
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册