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

minor changes

上级 e0e4c504
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestMnode : public ::testing::Test { class DndTestMnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_mnode", 9113); } static void SetUpTestSuite() { test.Init("/tmp/dnode_test_mnode", 9114); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestSnode : public ::testing::Test { class DndTestSnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_snode", 9112); } static void SetUpTestSuite() { test.Init("/tmp/dnode_test_snode", 9113); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestVnode : public ::testing::Test { class DndTestVnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_vnode", 9150); } static void SetUpTestSuite() { test.Init("/tmp/dnode_test_vnode", 9115); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
...@@ -57,7 +57,7 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) { ...@@ -57,7 +57,7 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) {
for (int r = 0; r < pReq->replica; ++r) { for (int r = 0; r < pReq->replica; ++r) {
SReplica* pReplica = &pReq->replicas[r]; SReplica* pReplica = &pReq->replicas[r];
pReplica->id = htonl(1); pReplica->id = htonl(1);
pReplica->port = htons(9150); pReplica->port = htons(9527);
} }
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_VNODE, pReq, contLen); SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_VNODE, pReq, contLen);
...@@ -102,7 +102,7 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) { ...@@ -102,7 +102,7 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) {
for (int r = 0; r < pReq->replica; ++r) { for (int r = 0; r < pReq->replica; ++r) {
SReplica* pReplica = &pReq->replicas[r]; SReplica* pReplica = &pReq->replicas[r];
pReplica->id = htonl(1); pReplica->id = htonl(1);
pReplica->port = htons(9150); pReplica->port = htons(9527);
} }
SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_VNODE, pReq, contLen); SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_VNODE, pReq, contLen);
......
...@@ -29,14 +29,14 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw); ...@@ -29,14 +29,14 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb); static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb); static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb);
static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOldDb, SDbObj *pNewDb); static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOldDb, SDbObj *pNewDb);
static int32_t mndProcessCreateDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessCreateDbReq(SMnodeMsg *pReq);
static int32_t mndProcessAlterDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessAlterDbReq(SMnodeMsg *pReq);
static int32_t mndProcessDropDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessDropDbReq(SMnodeMsg *pReq);
static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessUseDbReq(SMnodeMsg *pReq);
static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessSyncDbReq(SMnodeMsg *pReq);
static int32_t mndProcessCompactDbMsg(SMnodeMsg *pMsg); static int32_t mndProcessCompactDbReq(SMnodeMsg *pReq);
static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); static int32_t mndGetDbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta);
static int32_t mndRetrieveDbs(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); static int32_t mndRetrieveDbs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
static void mndCancelGetNextDb(SMnode *pMnode, void *pIter); static void mndCancelGetNextDb(SMnode *pMnode, void *pIter);
int32_t mndInitDb(SMnode *pMnode) { int32_t mndInitDb(SMnode *pMnode) {
...@@ -48,12 +48,12 @@ int32_t mndInitDb(SMnode *pMnode) { ...@@ -48,12 +48,12 @@ int32_t mndInitDb(SMnode *pMnode) {
.updateFp = (SdbUpdateFp)mndDbActionUpdate, .updateFp = (SdbUpdateFp)mndDbActionUpdate,
.deleteFp = (SdbDeleteFp)mndDbActionDelete}; .deleteFp = (SdbDeleteFp)mndDbActionDelete};
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_DB, mndProcessCreateDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_CREATE_DB, mndProcessCreateDbReq);
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_DB, mndProcessAlterDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_ALTER_DB, mndProcessAlterDbReq);
mndSetMsgHandle(pMnode, TDMT_MND_DROP_DB, mndProcessDropDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_DROP_DB, mndProcessDropDbReq);
mndSetMsgHandle(pMnode, TDMT_MND_USE_DB, mndProcessUseDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_USE_DB, mndProcessUseDbReq);
mndSetMsgHandle(pMnode, TDMT_MND_SYNC_DB, mndProcessSyncDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_SYNC_DB, mndProcessSyncDbReq);
mndSetMsgHandle(pMnode, TDMT_MND_COMPACT_DB, mndProcessCompactDbMsg); mndSetMsgHandle(pMnode, TDMT_MND_COMPACT_DB, mndProcessCompactDbReq);
mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_DB, mndGetDbMeta); mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_DB, mndGetDbMeta);
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_DB, mndRetrieveDbs); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_DB, mndRetrieveDbs);
...@@ -471,7 +471,7 @@ CREATE_DB_OVER: ...@@ -471,7 +471,7 @@ CREATE_DB_OVER:
return code; return code;
} }
static int32_t mndProcessCreateDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessCreateDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCreateDbMsg *pCreate = pMsg->rpcMsg.pCont; SCreateDbMsg *pCreate = pMsg->rpcMsg.pCont;
...@@ -668,7 +668,7 @@ UPDATE_DB_OVER: ...@@ -668,7 +668,7 @@ UPDATE_DB_OVER:
return code; return code;
} }
static int32_t mndProcessAlterDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessAlterDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SAlterDbMsg *pAlter = pMsg->rpcMsg.pCont; SAlterDbMsg *pAlter = pMsg->rpcMsg.pCont;
pAlter->totalBlocks = htonl(pAlter->totalBlocks); pAlter->totalBlocks = htonl(pAlter->totalBlocks);
...@@ -832,7 +832,7 @@ DROP_DB_OVER: ...@@ -832,7 +832,7 @@ DROP_DB_OVER:
return code; return code;
} }
static int32_t mndProcessDropDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessDropDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SDropDbMsg *pDrop = pMsg->rpcMsg.pCont; SDropDbMsg *pDrop = pMsg->rpcMsg.pCont;
...@@ -861,7 +861,7 @@ static int32_t mndProcessDropDbMsg(SMnodeMsg *pMsg) { ...@@ -861,7 +861,7 @@ static int32_t mndProcessDropDbMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_ACTION_IN_PROGRESS; return TSDB_CODE_MND_ACTION_IN_PROGRESS;
} }
static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessUseDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SUseDbMsg *pUse = pMsg->rpcMsg.pCont; SUseDbMsg *pUse = pMsg->rpcMsg.pCont;
...@@ -929,7 +929,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) { ...@@ -929,7 +929,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) {
return 0; return 0;
} }
static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessSyncDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SSyncDbMsg *pSync = pMsg->rpcMsg.pCont; SSyncDbMsg *pSync = pMsg->rpcMsg.pCont;
SDbObj *pDb = mndAcquireDb(pMnode, pSync->db); SDbObj *pDb = mndAcquireDb(pMnode, pSync->db);
...@@ -942,7 +942,7 @@ static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) { ...@@ -942,7 +942,7 @@ static int32_t mndProcessSyncDbMsg(SMnodeMsg *pMsg) {
return 0; return 0;
} }
static int32_t mndProcessCompactDbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessCompactDbReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCompactDbMsg *pCompact = pMsg->rpcMsg.pCont; SCompactDbMsg *pCompact = pMsg->rpcMsg.pCont;
SDbObj *pDb = mndAcquireDb(pMnode, pCompact->db); SDbObj *pDb = mndAcquireDb(pMnode, pCompact->db);
...@@ -1096,8 +1096,8 @@ char *mnGetDbStr(char *src) { ...@@ -1096,8 +1096,8 @@ char *mnGetDbStr(char *src) {
return pos; return pos;
} }
static int32_t mndRetrieveDbs(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { static int32_t mndRetrieveDbs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pReq->pMnode;
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
int32_t numOfRows = 0; int32_t numOfRows = 0;
SDbObj *pDb = NULL; SDbObj *pDb = NULL;
......
...@@ -13,17 +13,28 @@ ...@@ -13,17 +13,28 @@
class MndTestDb : public ::testing::Test { class MndTestDb : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_db", 9030); } static void SetUpTestSuite() {
static void TearDownTestSuite() { test.Cleanup(); } test.Init("/tmp/mnode_test_db", 9030);
const char* fqdn = "localhost";
const char* firstEp = "localhost:9030";
static Testbase test; server2.Start("/tmp/mnode_test_db2", fqdn, 9031, firstEp);
}
static void TearDownTestSuite() {
server2.Stop();
test.Cleanup();
}
static Testbase test;
static TestServer server2;
public: public:
void SetUp() override {} void SetUp() override {}
void TearDown() override {} void TearDown() override {}
}; };
Testbase MndTestDb::test; Testbase MndTestDb::test;
TestServer MndTestDb::server2;
TEST_F(MndTestDb, 01_ShowDb) { TEST_F(MndTestDb, 01_ShowDb) {
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
...@@ -149,7 +160,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -149,7 +160,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
CheckTimestamp(); CheckTimestamp();
CheckInt16(2); // vgroups CheckInt16(2); // vgroups
CheckInt32(0); CheckInt32(0); // tables
CheckInt16(1); // replica CheckInt16(1); // replica
CheckInt16(2); // quorum CheckInt16(2); // quorum
CheckInt16(10); // days CheckInt16(10); // days
...@@ -177,7 +188,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -177,7 +188,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
CheckTimestamp(); CheckTimestamp();
CheckInt16(2); // vgroups CheckInt16(2); // vgroups
CheckInt32(0); CheckInt32(0); // tables
CheckInt16(1); // replica CheckInt16(1); // replica
CheckInt16(2); // quorum CheckInt16(2); // quorum
CheckInt16(10); // days CheckInt16(10); // days
...@@ -301,4 +312,15 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { ...@@ -301,4 +312,15 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
EXPECT_STREQ(pAddr->fqdn, "localhost"); EXPECT_STREQ(pAddr->fqdn, "localhost");
} }
} }
{
int32_t contLen = sizeof(SDropDbMsg);
SDropDbMsg* pReq = (SDropDbMsg*)rpcMallocCont(contLen);
strcpy(pReq->db, "1.d2");
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册