Merge pull request #9619 from taosdata/feature/dnode3
rename some variables
This commit is contained in:
commit
ad1e992951
|
@ -506,7 +506,7 @@ typedef struct {
|
|||
int64_t qId;
|
||||
}; // query handle
|
||||
int8_t free;
|
||||
} SRetrieveTableMsg;
|
||||
} SRetrieveTableReq;
|
||||
|
||||
typedef struct SRetrieveTableRsp {
|
||||
int64_t useconds;
|
||||
|
@ -808,7 +808,7 @@ typedef struct {
|
|||
char db[TSDB_DB_FNAME_LEN];
|
||||
int16_t payloadLen;
|
||||
char payload[];
|
||||
} SShowMsg;
|
||||
} SShowReq;
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
|
|
|
@ -90,14 +90,14 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
|
|||
|
||||
if (pRequest->type == TDMT_MND_SHOW_RETRIEVE || pRequest->type == TDMT_VND_SHOW_TABLES_FETCH) {
|
||||
if (pRequest->type == TDMT_MND_SHOW_RETRIEVE) {
|
||||
SRetrieveTableMsg* pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg));
|
||||
SRetrieveTableReq* pRetrieveMsg = calloc(1, sizeof(SRetrieveTableReq));
|
||||
if (pRetrieveMsg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pRetrieveMsg->showId = htobe64(pRequest->body.showInfo.execId);
|
||||
pMsgSendInfo->msgInfo.pData = pRetrieveMsg;
|
||||
pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableMsg);
|
||||
pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableReq);
|
||||
} else {
|
||||
SVShowTablesFetchReq* pFetchMsg = calloc(1, sizeof(SVShowTablesFetchReq));
|
||||
if (pFetchMsg == NULL) {
|
||||
|
|
|
@ -6,13 +6,11 @@ add_subdirectory(snode)
|
|||
|
||||
# add_subdirectory(auth)
|
||||
# add_subdirectory(balance)
|
||||
add_subdirectory(cluster)
|
||||
add_subdirectory(db)
|
||||
add_subdirectory(dnode)
|
||||
# add_subdirectory(func)
|
||||
add_subdirectory(mnode)
|
||||
add_subdirectory(profile)
|
||||
add_subdirectory(show)
|
||||
add_subdirectory(stb)
|
||||
# add_subdirectory(sync)
|
||||
# add_subdirectory(telem)
|
||||
|
|
|
@ -32,9 +32,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
|
|||
SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
|
|||
SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -54,9 +54,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
|
|||
SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -67,9 +67,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
|
|||
SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
|
|||
SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -91,9 +91,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
|
|||
SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -102,9 +102,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
|
|||
SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -115,9 +115,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
|
|||
SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -126,8 +126,8 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
|
|||
SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
aux_source_directory(. CLUSTER_SRC)
|
||||
add_executable(dnode_test_cluster ${CLUSTER_SRC})
|
||||
target_link_libraries(
|
||||
dnode_test_cluster
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_cluster
|
||||
COMMAND dnode_test_cluster
|
||||
)
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
* @file cluster.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module cluster-msg tests
|
||||
* @version 0.1
|
||||
* @date 2021-12-15
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sut.h"
|
||||
|
||||
class DndTestCluster : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_cluster", 9030); }
|
||||
static void TearDownTestSuite() { test.Cleanup(); }
|
||||
|
||||
static Testbase test;
|
||||
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
Testbase DndTestCluster::test;
|
||||
|
||||
TEST_F(DndTestCluster, 01_ShowCluster) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, "");
|
||||
CHECK_META( "show cluster", 3);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
IgnoreInt64();
|
||||
IgnoreBinary(TSDB_CLUSTER_ID_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
|
@ -26,7 +26,7 @@ class DndTestDb : public ::testing::Test {
|
|||
Testbase DndTestDb::test;
|
||||
|
||||
TEST_F(DndTestDb, 01_ShowDb) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
@ -47,7 +47,7 @@ TEST_F(DndTestDb, 01_ShowDb) {
|
|||
CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
|
||||
CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -77,15 +77,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
pReq->cacheLastRow = 0;
|
||||
pReq->ignoreExist = 1;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
CheckTimestamp();
|
||||
|
@ -106,14 +106,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
CheckBinary("ms", 3); // precision
|
||||
CheckInt8(0); // update
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_VGROUP, "1.d1");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_VGROUP, "1.d1");
|
||||
CHECK_META("show vgroups", 4);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
|
@ -138,13 +138,13 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
pReq->quorum = 2;
|
||||
pReq->cacheLastRow = 1;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
CheckTimestamp();
|
||||
|
@ -168,10 +168,10 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
|
@ -199,15 +199,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
SDropDbMsg* pReq = (SDropDbMsg*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->db, "1.d1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -237,15 +237,15 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
pReq->cacheLastRow = 0;
|
||||
pReq->ignoreExist = 1;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 18);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d2", TSDB_DB_NAME_LEN - 1);
|
||||
|
||||
|
@ -256,7 +256,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
strcpy(pReq->db, "1.d2");
|
||||
pReq->vgVersion = htonl(-1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_USE_DB, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_USE_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ TestServer DndTestDnode::server4;
|
|||
TestServer DndTestDnode::server5;
|
||||
|
||||
TEST_F(DndTestDnode, 01_ShowDnode) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
|
@ -62,7 +62,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
|
|||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -81,9 +81,9 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
|
|||
pReq->dnodeId = htonl(1);
|
||||
strcpy(pReq->config, "ddebugflag 131");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONFIG_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONFIG_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
||||
|
@ -94,16 +94,16 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9042);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
taosMsleep(1300);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -127,14 +127,14 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -152,9 +152,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9043);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -164,9 +164,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9044);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -176,15 +176,15 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9045);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -225,9 +225,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
|
|||
server5.Restart();
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
CheckInt16(1);
|
||||
|
|
|
@ -51,7 +51,7 @@ TestServer DndTestMnode::server4;
|
|||
TestServer DndTestMnode::server5;
|
||||
|
||||
TEST_F(DndTestMnode, 01_ShowDnode) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
CHECK_META("show mnodes", 5);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
|
@ -60,7 +60,7 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
|
|||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -77,9 +77,9 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
|
|||
SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MNODE_ALREADY_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MNODE_ALREADY_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
|
|||
SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9062);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -122,12 +122,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -149,12 +149,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
SMDropMnodeMsg* pReq = (SMDropMnodeMsg*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_MNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -170,14 +170,14 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
// SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
|
||||
// pReq->dnodeId = htonl(2);
|
||||
|
||||
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pMsg, nullptr);
|
||||
// ASSERT_EQ(pMsg->code, 0);
|
||||
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pRsp, nullptr);
|
||||
// ASSERT_EQ(pRsp->code, 0);
|
||||
// }
|
||||
|
||||
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// CHECK_META("show dnodes", 7);
|
||||
// test.SendShowRetrieveMsg();
|
||||
// test.SendShowRetrieveReq();
|
||||
// EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
// CheckInt16(1);
|
||||
|
@ -194,9 +194,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
|
||||
// strcpy(pReq->ep, "localhost:9063");
|
||||
|
||||
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pMsg, nullptr);
|
||||
// ASSERT_EQ(pMsg->code, 0);
|
||||
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pRsp, nullptr);
|
||||
// ASSERT_EQ(pRsp->code, 0);
|
||||
// }
|
||||
|
||||
// {
|
||||
|
@ -205,9 +205,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
|
||||
// strcpy(pReq->ep, "localhost:9064");
|
||||
|
||||
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pMsg, nullptr);
|
||||
// ASSERT_EQ(pMsg->code, 0);
|
||||
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pRsp, nullptr);
|
||||
// ASSERT_EQ(pRsp->code, 0);
|
||||
// }
|
||||
|
||||
// {
|
||||
|
@ -216,15 +216,15 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
|
||||
// strcpy(pReq->ep, "localhost:9065");
|
||||
|
||||
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pMsg, nullptr);
|
||||
// ASSERT_EQ(pMsg->code, 0);
|
||||
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
// ASSERT_NE(pRsp, nullptr);
|
||||
// ASSERT_EQ(pRsp->code, 0);
|
||||
// }
|
||||
|
||||
// taosMsleep(1300);
|
||||
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// CHECK_META("show dnodes", 7);
|
||||
// test.SendShowRetrieveMsg();
|
||||
// test.SendShowRetrieveReq();
|
||||
// EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
// CheckInt16(1);
|
||||
|
@ -265,9 +265,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
|
|||
// server5.Restart();
|
||||
|
||||
// taosMsleep(1300);
|
||||
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
// CHECK_META("show dnodes", 7);
|
||||
// test.SendShowRetrieveMsg();
|
||||
// test.SendShowRetrieveReq();
|
||||
// EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
// CheckInt16(1);
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
|
|||
strcpy(pReq->app, "dnode_test_profile");
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
@ -67,14 +67,14 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
|
|||
strcpy(pReq->app, "dnode_test_profile");
|
||||
strcpy(pReq->db, "invalid_db");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_DB);
|
||||
ASSERT_EQ(pMsg->contLen, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB);
|
||||
ASSERT_EQ(pRsp->contLen, 0);
|
||||
}
|
||||
|
||||
TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_CONNS, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, "");
|
||||
CHECK_META("show connections", 7);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "connId");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user");
|
||||
|
@ -84,7 +84,7 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
|
|||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "login_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_access");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckInt32(1);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
@ -105,7 +105,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
|
|||
pReq->numOfStreams = htonl(0);
|
||||
strcpy(pReq->app, "dnode_test_profile");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
@ -138,9 +138,9 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
|
|||
SKillConnMsg* pReq = (SKillConnMsg*)rpcMallocCont(contLen);
|
||||
pReq->connId = htonl(connId);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_CONN, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_CONN, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -153,10 +153,10 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
|
|||
pReq->numOfStreams = htonl(0);
|
||||
strcpy(pReq->app, "dnode_test_profile");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONNECTION);
|
||||
ASSERT_EQ(pMsg->contLen, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONNECTION);
|
||||
ASSERT_EQ(pRsp->contLen, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
|
|||
strcpy(pReq->app, "dnode_test_profile");
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
@ -198,9 +198,9 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
|
|||
SKillConnMsg* pReq = (SKillConnMsg*)rpcMallocCont(contLen);
|
||||
pReq->connId = htonl(2345);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_CONN, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONN_ID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_CONN, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONN_ID);
|
||||
}
|
||||
|
||||
TEST_F(DndTestProfile, 07_KillQueryMsg) {
|
||||
|
@ -211,10 +211,10 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
|
|||
pReq->connId = htonl(connId);
|
||||
pReq->queryId = htonl(1234);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_QUERY, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
ASSERT_EQ(pMsg->contLen, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_QUERY, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
ASSERT_EQ(pRsp->contLen, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
|
|||
pReq->numOfStreams = htonl(0);
|
||||
strcpy(pReq->app, "dnode_test_profile");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
@ -261,13 +261,13 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
|
|||
pReq->connId = htonl(2345);
|
||||
pReq->queryId = htonl(1234);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_QUERY, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONN_ID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_QUERY, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONN_ID);
|
||||
}
|
||||
|
||||
TEST_F(DndTestProfile, 09_KillQueryMsg) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QUERIES, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QUERIES, "");
|
||||
CHECK_META("show queries", 14);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "queryId");
|
||||
|
@ -285,6 +285,6 @@ TEST_F(DndTestProfile, 09_KillQueryMsg) {
|
|||
CHECK_SCHEMA(12, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, "sub_query_info");
|
||||
CHECK_SCHEMA(13, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, "sql");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
|
|||
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
|
|||
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -54,9 +54,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
|
|||
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -67,9 +67,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
|
|||
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
|
|||
SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -91,9 +91,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
|
|||
SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -102,9 +102,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
|
|||
SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -115,9 +115,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
|
|||
SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -126,8 +126,8 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
|
|||
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
aux_source_directory(. SHOW_SRC)
|
||||
add_executable(dnode_test_show ${SHOW_SRC})
|
||||
target_link_libraries(
|
||||
dnode_test_show
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_show
|
||||
COMMAND dnode_test_show
|
||||
)
|
|
@ -1,87 +0,0 @@
|
|||
/**
|
||||
* @file show.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module show-msg tests
|
||||
* @version 0.1
|
||||
* @date 2021-12-15
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sut.h"
|
||||
|
||||
class DndTestShow : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_show", 9091); }
|
||||
static void TearDownTestSuite() { test.Cleanup(); }
|
||||
|
||||
static Testbase test;
|
||||
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
Testbase DndTestShow::test;
|
||||
|
||||
TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
||||
int32_t contLen = sizeof(SShowMsg);
|
||||
|
||||
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
|
||||
pReq->type = TSDB_MGMT_TABLE_MAX;
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||
int32_t contLen = sizeof(SShowMsg);
|
||||
|
||||
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
||||
pReq->type = TSDB_MGMT_TABLE_START;
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(DndTestShow, 02_ShowMsg_Conn) {
|
||||
int32_t contLen = sizeof(SConnectMsg);
|
||||
|
||||
SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen);
|
||||
pReq->pid = htonl(1234);
|
||||
strcpy(pReq->app, "dnode_test_show");
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_CONNS, "");
|
||||
|
||||
STableMetaMsg* pMeta = test.GetShowMeta();
|
||||
EXPECT_STREQ(pMeta->tbFname, "show connections");
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, 7);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->update, 0);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tuid, 0);
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
|
||||
SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp();
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->completed, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
}
|
|
@ -32,9 +32,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
|
|||
SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
|
|||
SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -54,9 +54,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
|
|||
SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -67,9 +67,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
|
|||
SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
|
|||
SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ID_INVALID);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ID_INVALID);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -91,9 +91,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
|
|||
SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -102,9 +102,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
|
|||
SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -115,9 +115,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
|
|||
SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -126,8 +126,8 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
|
|||
SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
|
@ -51,9 +51,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
pReq->cacheLastRow = 0;
|
||||
pReq->ignoreExist = 1;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -101,12 +101,12 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
strcpy(pSchema->name, "tag3");
|
||||
}
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_STB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
CHECK_META("show stables", 4);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
|
@ -114,7 +114,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
|
@ -128,7 +128,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
STableInfoMsg* pReq = (STableInfoMsg*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->tableFname, "1.d1.stb");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_STB_META, pReq, contLen);
|
||||
SRpcMsg* pMsg = test.SendReq(TDMT_MND_STB_META, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
|
@ -203,9 +203,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
CHECK_META("show stables", 4);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
|
@ -219,13 +219,13 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
SDropStbMsg* pReq = (SDropStbMsg*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->name, "1.d1.stb");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_STB, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1");
|
||||
CHECK_META("show stables", 4);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class TestClient {
|
|||
bool Init(const char* user, const char* pass, const char* fqdn, uint16_t port);
|
||||
void Cleanup();
|
||||
|
||||
SRpcMsg* SendMsg(SRpcMsg* pMsg);
|
||||
SRpcMsg* SendReq(SRpcMsg* pReq);
|
||||
void SetRpcRsp(SRpcMsg* pRsp);
|
||||
tsem_t* GetSem();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Testbase {
|
|||
void Restart();
|
||||
void ServerStop();
|
||||
void ServerStart();
|
||||
SRpcMsg* SendMsg(tmsg_t msgType, void* pCont, int32_t contLen);
|
||||
SRpcMsg* SendReq(tmsg_t msgType, void* pCont, int32_t contLen);
|
||||
|
||||
private:
|
||||
void InitLog(const char* path);
|
||||
|
@ -50,8 +50,8 @@ class Testbase {
|
|||
int32_t connId;
|
||||
|
||||
public:
|
||||
void SendShowMetaMsg(int8_t showType, const char* db);
|
||||
void SendShowRetrieveMsg();
|
||||
void SendShowMetaReq(int8_t showType, const char* db);
|
||||
void SendShowRetrieveReq();
|
||||
|
||||
STableMetaMsg* GetShowMeta();
|
||||
SRetrieveTableRsp* GetRetrieveRsp();
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
#include "sut.h"
|
||||
|
||||
static void processClientRsp(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||
static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) {
|
||||
TestClient* client = (TestClient*)parent;
|
||||
client->SetRpcRsp(pMsg);
|
||||
uInfo("response:%s from dnode, code:0x%x", TMSG_INFO(pMsg->msgType), pMsg->code);
|
||||
client->SetRpcRsp(pRsp);
|
||||
uInfo("response:%s from dnode, code:0x%x", TMSG_INFO(pRsp->msgType), pRsp->code);
|
||||
tsem_post(client->GetSem());
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,14 @@ void TestClient::Cleanup() {
|
|||
rpcClose(clientRpc);
|
||||
}
|
||||
|
||||
SRpcMsg* TestClient::SendMsg(SRpcMsg* pMsg) {
|
||||
SRpcMsg* TestClient::SendReq(SRpcMsg* pReq) {
|
||||
SEpSet epSet = {0};
|
||||
epSet.inUse = 0;
|
||||
epSet.numOfEps = 1;
|
||||
epSet.port[0] = port;
|
||||
memcpy(epSet.fqdn[0], fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
rpcSendRequest(clientRpc, &epSet, pMsg, NULL);
|
||||
rpcSendRequest(clientRpc, &epSet, pReq, NULL);
|
||||
tsem_wait(&sem);
|
||||
|
||||
return pRsp;
|
||||
|
|
|
@ -64,23 +64,23 @@ void Testbase::ServerStop() { server.Stop(); }
|
|||
|
||||
void Testbase::ServerStart() { server.DoStart(); }
|
||||
|
||||
SRpcMsg* Testbase::SendMsg(tmsg_t msgType, void* pCont, int32_t contLen) {
|
||||
SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pCont;
|
||||
rpcMsg.contLen = contLen;
|
||||
rpcMsg.msgType = msgType;
|
||||
|
||||
return client.SendMsg(&rpcMsg);
|
||||
return client.SendReq(&rpcMsg);
|
||||
}
|
||||
|
||||
void Testbase::SendShowMetaMsg(int8_t showType, const char* db) {
|
||||
int32_t contLen = sizeof(SShowMsg);
|
||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(contLen);
|
||||
void Testbase::SendShowMetaReq(int8_t showType, const char* db) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
SShowReq* pShow = (SShowReq*)rpcMallocCont(contLen);
|
||||
pShow->type = showType;
|
||||
strcpy(pShow->db, db);
|
||||
|
||||
SRpcMsg* pMsg = SendMsg(TDMT_MND_SHOW, pShow, contLen);
|
||||
SShowRsp* pShowRsp = (SShowRsp*)pMsg->pCont;
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pShow, contLen);
|
||||
SShowRsp* pShowRsp = (SShowRsp*)pRsp->pCont;
|
||||
|
||||
ASSERT(pShowRsp != nullptr);
|
||||
pShowRsp->showId = htobe64(pShowRsp->showId);
|
||||
|
@ -121,15 +121,15 @@ int32_t Testbase::GetMetaNum() { return pMeta->numOfColumns; }
|
|||
|
||||
const char* Testbase::GetMetaTbName() { return pMeta->tbFname; }
|
||||
|
||||
void Testbase::SendShowRetrieveMsg() {
|
||||
int32_t contLen = sizeof(SRetrieveTableMsg);
|
||||
void Testbase::SendShowRetrieveReq() {
|
||||
int32_t contLen = sizeof(SRetrieveTableReq);
|
||||
|
||||
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(contLen);
|
||||
SRetrieveTableReq* pRetrieve = (SRetrieveTableReq*)rpcMallocCont(contLen);
|
||||
pRetrieve->showId = htobe64(showId);
|
||||
pRetrieve->free = 0;
|
||||
|
||||
SRpcMsg* pMsg = SendMsg(TDMT_MND_SHOW_RETRIEVE, pRetrieve, contLen);
|
||||
pRetrieveRsp = (SRetrieveTableRsp*)pMsg->pCont;
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW_RETRIEVE, pRetrieve, contLen);
|
||||
pRetrieveRsp = (SRetrieveTableRsp*)pRsp->pCont;
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
|
|
@ -60,9 +60,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
|
|||
pReplica->port = htons(9150);
|
||||
}
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
|
|||
pReplica->port = htons(9150);
|
||||
}
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_ALTER_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
|
|||
rpcMsg.contLen = sizeof(SDropVnodeMsg);
|
||||
rpcMsg.msgType = TDMT_DND_DROP_VNODE;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_VNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw);
|
|||
static int32_t mndAcctActionInsert(SSdb *pSdb, SAcctObj *pAcct);
|
||||
static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct);
|
||||
static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew);
|
||||
static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessCreateAcctReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessAlterAcctReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessDropAcctReq(SMnodeMsg *pReq);
|
||||
|
||||
int32_t mndInitAcct(SMnode *pMnode) {
|
||||
SSdbTable table = {.sdbType = SDB_ACCT,
|
||||
|
@ -185,19 +185,19 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg) {
|
||||
static int32_t mndProcessCreateAcctReq(SMnodeMsg *pReq) {
|
||||
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg) {
|
||||
static int32_t mndProcessAlterAcctReq(SMnodeMsg *pReq) {
|
||||
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg) {
|
||||
static int32_t mndProcessDropAcctReq(SMnodeMsg *pReq) {
|
||||
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "mndAuth.h"
|
||||
|
||||
int32_t mndInitAuth(SMnode *pMnode) { return 0; }
|
||||
|
|
|
@ -27,12 +27,12 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw);
|
|||
static int32_t mndBnodeActionInsert(SSdb *pSdb, SBnodeObj *pObj);
|
||||
static int32_t mndBnodeActionDelete(SSdb *pSdb, SBnodeObj *pObj);
|
||||
static int32_t mndBnodeActionUpdate(SSdb *pSdb, SBnodeObj *pOld, SBnodeObj *pNew);
|
||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveBnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveBnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextBnode(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitBnode(SMnode *pMnode) {
|
||||
|
@ -185,22 +185,22 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) {
|
||||
SDCreateBnodeReq *pMsg = malloc(sizeof(SDCreateBnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDCreateBnodeReq *pReq = malloc(sizeof(SDCreateBnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDCreateBnodeReq);
|
||||
action.msgType = TDMT_DND_CREATE_BNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,29 +208,29 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) {
|
||||
SDDropBnodeReq *pMsg = malloc(sizeof(SDDropBnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropBnodeReq *pReq = malloc(sizeof(SDDropBnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropBnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_BNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateBnodeReq *pCreate) {
|
||||
static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateBnodeReq *pCreate) {
|
||||
int32_t code = -1;
|
||||
|
||||
SBnodeObj bnodeObj = {0};
|
||||
|
@ -238,7 +238,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
|
|||
bnodeObj.createdTime = taosGetTimestampMs();
|
||||
bnodeObj.updateTime = bnodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto CREATE_BNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to create bnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -256,9 +256,9 @@ CREATE_BNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMCreateBnodeReq *pCreate = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMCreateBnodeReq *pCreate = pReq->rpcMsg.pCont;
|
||||
|
||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
||||
|
||||
|
@ -282,7 +282,7 @@ static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndCreateBnode(pMnode, pMsg, pDnode, pCreate);
|
||||
int32_t code = mndCreateBnode(pMnode, pReq, pDnode, pCreate);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
||||
if (code != 0) {
|
||||
|
@ -310,32 +310,32 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) {
|
||||
SDDropBnodeReq *pMsg = malloc(sizeof(SDDropBnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropBnodeReq *pReq = malloc(sizeof(SDDropBnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropBnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_BNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndDropBnode(SMnode *pMnode, SMnodeMsg *pMsg, SBnodeObj *pObj) {
|
||||
static int32_t mndDropBnode(SMnode *pMnode, SMnodeMsg *pReq, SBnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto DROP_BNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop bnode:%d", pTrans->id, pObj->id);
|
||||
|
@ -351,9 +351,9 @@ DROP_BNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMDropBnodeReq *pDrop = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMDropBnodeReq *pDrop = pReq->rpcMsg.pCont;
|
||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
||||
|
||||
mDebug("bnode:%d, start to drop", pDrop->dnodeId);
|
||||
|
@ -370,7 +370,7 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndDropBnode(pMnode, pMsg, pObj);
|
||||
int32_t code = mndDropBnode(pMnode, pReq, pObj);
|
||||
if (code != 0) {
|
||||
sdbRelease(pMnode->pSdb, pObj);
|
||||
mError("bnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||
|
@ -381,18 +381,18 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
|
@ -431,8 +431,8 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveBnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndRetrieveBnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "mndCluster.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
|
||||
#define TSDB_CLUSTER_VER_NUMBE 1
|
||||
#define TSDB_CLUSTER_RESERVE_SIZE 64
|
||||
|
|
|
@ -27,12 +27,12 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw);
|
|||
static int32_t mndQnodeActionInsert(SSdb *pSdb, SQnodeObj *pObj);
|
||||
static int32_t mndQnodeActionDelete(SSdb *pSdb, SQnodeObj *pObj);
|
||||
static int32_t mndQnodeActionUpdate(SSdb *pSdb, SQnodeObj *pOld, SQnodeObj *pNew);
|
||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveQnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveQnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextQnode(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitQnode(SMnode *pMnode) {
|
||||
|
@ -185,22 +185,22 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) {
|
||||
SDCreateQnodeReq *pMsg = malloc(sizeof(SDCreateQnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDCreateQnodeReq *pReq = malloc(sizeof(SDCreateQnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDCreateQnodeReq);
|
||||
action.msgType = TDMT_DND_CREATE_QNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,29 +208,29 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) {
|
||||
SDDropQnodeReq *pMsg = malloc(sizeof(SDDropQnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropQnodeReq *pReq = malloc(sizeof(SDDropQnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropQnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_QNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateQnodeReq *pCreate) {
|
||||
static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateQnodeReq *pCreate) {
|
||||
int32_t code = -1;
|
||||
|
||||
SQnodeObj qnodeObj = {0};
|
||||
|
@ -238,7 +238,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
|
|||
qnodeObj.createdTime = taosGetTimestampMs();
|
||||
qnodeObj.updateTime = qnodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto CREATE_QNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to create qnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -256,9 +256,9 @@ CREATE_QNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMCreateQnodeReq *pCreate = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMCreateQnodeReq *pCreate = pReq->rpcMsg.pCont;
|
||||
|
||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
||||
|
||||
|
@ -282,7 +282,7 @@ static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndCreateQnode(pMnode, pMsg, pDnode, pCreate);
|
||||
int32_t code = mndCreateQnode(pMnode, pReq, pDnode, pCreate);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
||||
if (code != 0) {
|
||||
|
@ -310,32 +310,32 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) {
|
||||
SDDropQnodeReq *pMsg = malloc(sizeof(SDDropQnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropQnodeReq *pReq = malloc(sizeof(SDDropQnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropQnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_QNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndDropQnode(SMnode *pMnode, SMnodeMsg *pMsg, SQnodeObj *pObj) {
|
||||
static int32_t mndDropQnode(SMnode *pMnode, SMnodeMsg *pReq, SQnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto DROP_QNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id);
|
||||
|
@ -351,9 +351,9 @@ DROP_QNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMDropQnodeReq *pDrop = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMDropQnodeReq *pDrop = pReq->rpcMsg.pCont;
|
||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
||||
|
||||
mDebug("qnode:%d, start to drop", pDrop->dnodeId);
|
||||
|
@ -370,7 +370,7 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndDropQnode(pMnode, pMsg, pObj);
|
||||
int32_t code = mndDropQnode(pMnode, pReq, pObj);
|
||||
if (code != 0) {
|
||||
sdbRelease(pMnode->pSdb, pObj);
|
||||
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||
|
@ -381,18 +381,18 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
|
@ -431,8 +431,8 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveQnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndRetrieveQnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
#define SHOW_STEP_SIZE 100
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg);
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq);
|
||||
static void mndFreeShowObj(SShowObj *pShow);
|
||||
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId);
|
||||
static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove);
|
||||
static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg);
|
||||
static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessShowReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq);
|
||||
static bool mndCheckRetrieveFinished(SShowObj *pShow);
|
||||
|
||||
int32_t mndInitShow(SMnode *pMnode) {
|
||||
|
@ -36,8 +36,8 @@ int32_t mndInitShow(SMnode *pMnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW, mndProcessShowMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_RETRIEVE, mndProcessRetrieveMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW, mndProcessShowReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_RETRIEVE, mndProcessRetrieveReq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -49,20 +49,20 @@ void mndCleanupShow(SMnode *pMnode) {
|
|||
}
|
||||
}
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) {
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq) {
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
|
||||
int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
|
||||
if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
|
||||
|
||||
int32_t size = sizeof(SShowObj) + pMsg->payloadLen;
|
||||
int32_t size = sizeof(SShowObj) + pReq->payloadLen;
|
||||
SShowObj showObj = {0};
|
||||
showObj.id = showId;
|
||||
showObj.pMnode = pMnode;
|
||||
showObj.type = pMsg->type;
|
||||
showObj.payloadLen = pMsg->payloadLen;
|
||||
memcpy(showObj.db, pMsg->db, TSDB_DB_FNAME_LEN);
|
||||
memcpy(showObj.payload, pMsg->payload, pMsg->payloadLen);
|
||||
showObj.type = pReq->type;
|
||||
showObj.payloadLen = pReq->payloadLen;
|
||||
memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
|
||||
memcpy(showObj.payload, pReq->payload, pReq->payloadLen);
|
||||
|
||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 6 * 1000;
|
||||
SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
|
||||
|
@ -115,12 +115,12 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
|
|||
taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove);
|
||||
}
|
||||
|
||||
static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
|
||||
SMnode *pMnode = pMnodeMsg->pMnode;
|
||||
static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
SShowMsg *pMsg = pMnodeMsg->rpcMsg.pCont;
|
||||
int8_t type = pMsg->type;
|
||||
int16_t payloadLen = htonl(pMsg->payloadLen);
|
||||
SShowReq *pShowReq = pReq->rpcMsg.pCont;
|
||||
int8_t type = pShowReq->type;
|
||||
int16_t payloadLen = htonl(pShowReq->payloadLen);
|
||||
|
||||
if (type <= TSDB_MGMT_TABLE_START || type >= TSDB_MGMT_TABLE_MAX) {
|
||||
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
||||
|
@ -135,7 +135,7 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SShowObj *pShow = mndCreateShowObj(pMnode, pMsg);
|
||||
SShowObj *pShow = mndCreateShowObj(pMnode, pShowReq);
|
||||
if (pShow == NULL) {
|
||||
mError("failed to process show-meta msg:%s since %s", mndShowStr(type), terrstr());
|
||||
return -1;
|
||||
|
@ -151,13 +151,13 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = (*metaFp)(pMnodeMsg, pShow, &pRsp->tableMeta);
|
||||
int32_t code = (*metaFp)(pReq, pShow, &pRsp->tableMeta);
|
||||
mDebug("show:0x%" PRIx64 ", get meta finished, numOfRows:%d cols:%d type:%s, result:%s", pShow->id, pShow->numOfRows,
|
||||
pShow->numOfColumns, mndShowStr(type), tstrerror(code));
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
pMnodeMsg->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns;
|
||||
pMnodeMsg->pCont = pRsp;
|
||||
pReq->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns;
|
||||
pReq->pCont = pRsp;
|
||||
pRsp->showId = htobe64(pShow->id);
|
||||
mndReleaseShowObj(pShow, false);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -168,14 +168,14 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
|
||||
SMnode *pMnode = pMnodeMsg->pMnode;
|
||||
static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
int32_t rowsToRead = 0;
|
||||
int32_t size = 0;
|
||||
int32_t rowsRead = 0;
|
||||
|
||||
SRetrieveTableMsg *pRetrieve = pMnodeMsg->rpcMsg.pCont;
|
||||
SRetrieveTableReq *pRetrieve = pReq->rpcMsg.pCont;
|
||||
int64_t showId = htobe64(pRetrieve->showId);
|
||||
|
||||
SShowObj *pShow = mndAcquireShowObj(pMnode, showId);
|
||||
|
@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
|
|||
|
||||
// if free flag is set, client wants to clean the resources
|
||||
if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE) {
|
||||
rowsRead = (*retrieveFp)(pMnodeMsg, pShow, pRsp->data, rowsToRead);
|
||||
rowsRead = (*retrieveFp)(pReq, pShow, pRsp->data, rowsToRead);
|
||||
}
|
||||
|
||||
mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d rowsToRead:%d", pShow->id, rowsRead, rowsToRead);
|
||||
|
@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
|
|||
pRsp->numOfRows = htonl(rowsRead);
|
||||
pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision
|
||||
|
||||
pMnodeMsg->pCont = pRsp;
|
||||
pMnodeMsg->contLen = size;
|
||||
pReq->pCont = pRsp;
|
||||
pReq->contLen = size;
|
||||
|
||||
if (rowsRead == 0 || rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) {
|
||||
pRsp->completed = 1;
|
||||
|
|
|
@ -27,12 +27,12 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw);
|
|||
static int32_t mndSnodeActionInsert(SSdb *pSdb, SSnodeObj *pObj);
|
||||
static int32_t mndSnodeActionDelete(SSdb *pSdb, SSnodeObj *pObj);
|
||||
static int32_t mndSnodeActionUpdate(SSdb *pSdb, SSnodeObj *pOld, SSnodeObj *pNew);
|
||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pMsg);
|
||||
static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveSnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pRsp);
|
||||
static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveSnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextSnode(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitSnode(SMnode *pMnode) {
|
||||
|
@ -185,22 +185,22 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) {
|
||||
SDCreateSnodeReq *pMsg = malloc(sizeof(SDCreateSnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDCreateSnodeReq *pReq = malloc(sizeof(SDCreateSnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDCreateSnodeReq);
|
||||
action.msgType = TDMT_DND_CREATE_SNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,29 +208,29 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
}
|
||||
|
||||
static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) {
|
||||
SDDropSnodeReq *pMsg = malloc(sizeof(SDDropSnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropSnodeReq *pReq = malloc(sizeof(SDDropSnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropSnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_SNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateSnodeReq *pCreate) {
|
||||
static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateSnodeReq *pCreate) {
|
||||
int32_t code = -1;
|
||||
|
||||
SSnodeObj snodeObj = {0};
|
||||
|
@ -238,7 +238,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
|
|||
snodeObj.createdTime = taosGetTimestampMs();
|
||||
snodeObj.updateTime = snodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto CREATE_SNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to create snode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -257,9 +257,9 @@ CREATE_SNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMCreateSnodeReq *pCreate = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMCreateSnodeReq *pCreate = pReq->rpcMsg.pCont;
|
||||
|
||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
||||
|
||||
|
@ -283,7 +283,7 @@ static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndCreateSnode(pMnode, pMsg, pDnode, pCreate);
|
||||
int32_t code = mndCreateSnode(pMnode, pReq, pDnode, pCreate);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
||||
if (code != 0) {
|
||||
|
@ -311,32 +311,32 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
|
|||
}
|
||||
|
||||
static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) {
|
||||
SDDropSnodeReq *pMsg = malloc(sizeof(SDDropSnodeReq));
|
||||
if (pMsg == NULL) {
|
||||
SDDropSnodeReq *pReq = malloc(sizeof(SDDropSnodeReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pMsg->dnodeId = htonl(pDnode->id);
|
||||
pReq->dnodeId = htonl(pDnode->id);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pMsg;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SDDropSnodeReq);
|
||||
action.msgType = TDMT_DND_DROP_SNODE;
|
||||
action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
free(pMsg);
|
||||
free(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndDropSnode(SMnode *pMnode, SMnodeMsg *pMsg, SSnodeObj *pObj) {
|
||||
static int32_t mndDropSnode(SMnode *pMnode, SMnodeMsg *pReq, SSnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) goto DROP_SNODE_OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop snode:%d", pTrans->id, pObj->id);
|
||||
|
@ -353,9 +353,9 @@ DROP_SNODE_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMDropSnodeReq *pDrop = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SMDropSnodeReq *pDrop = pReq->rpcMsg.pCont;
|
||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
||||
|
||||
mDebug("snode:%d, start to drop", pDrop->dnodeId);
|
||||
|
@ -372,7 +372,7 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndDropSnode(pMnode, pMsg, pObj);
|
||||
int32_t code = mndDropSnode(pMnode, pReq, pObj);
|
||||
if (code != 0) {
|
||||
sdbRelease(pMnode->pSdb, pObj);
|
||||
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||
|
@ -383,18 +383,18 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pMsg) {
|
||||
mndTransProcessRsp(pMsg);
|
||||
static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pRsp) {
|
||||
mndTransProcessRsp(pRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
|
@ -433,8 +433,8 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveSnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndRetrieveSnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "mndUser.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSync.h"
|
||||
#include "mndTrans.h"
|
||||
#include "tkey.h"
|
||||
|
||||
|
@ -29,12 +28,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
|
|||
static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser);
|
||||
static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser);
|
||||
static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew);
|
||||
static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg);
|
||||
static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pReq);
|
||||
static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq);
|
||||
static int32_t mndProcessDropUserReq(SMnodeMsg *pReq);
|
||||
static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta);
|
||||
static int32_t mndRetrieveUsers(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextUser(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitUser(SMnode *pMnode) {
|
||||
|
@ -213,7 +212,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser) {
|
|||
sdbRelease(pSdb, pUser);
|
||||
}
|
||||
|
||||
static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg) {
|
||||
static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pReq) {
|
||||
SUserObj userObj = {0};
|
||||
tstrncpy(userObj.user, user, TSDB_USER_LEN);
|
||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||
|
@ -222,7 +221,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
|
|||
userObj.updateTime = userObj.createdTime;
|
||||
userObj.superUser = 0;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to create since %s", user, terrstr());
|
||||
return -1;
|
||||
|
@ -247,9 +246,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SCreateUserReq *pCreate = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SCreateUserReq *pCreate = pReq->rpcMsg.pCont;
|
||||
|
||||
mDebug("user:%s, start to create", pCreate->user);
|
||||
|
||||
|
@ -273,14 +272,14 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user);
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pOperUser == NULL) {
|
||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||
mError("user:%s, failed to create since %s", pCreate->user, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndCreateUser(pMnode, pOperUser->acct, pCreate->user, pCreate->pass, pMsg);
|
||||
int32_t code = mndCreateUser(pMnode, pOperUser->acct, pCreate->user, pCreate->pass, pReq);
|
||||
mndReleaseUser(pMnode, pOperUser);
|
||||
|
||||
if (code != 0) {
|
||||
|
@ -291,8 +290,8 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMnodeMsg *pMsg) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMnodeMsg *pReq) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to update since %s", pOld->user, terrstr());
|
||||
return -1;
|
||||
|
@ -317,9 +316,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMn
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SAlterUserReq *pAlter = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SAlterUserReq *pAlter = pReq->rpcMsg.pCont;
|
||||
|
||||
mDebug("user:%s, start to alter", pAlter->user);
|
||||
|
||||
|
@ -342,7 +341,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user);
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pOperUser == NULL) {
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||
|
@ -356,7 +355,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
|
|||
taosEncryptPass((uint8_t *)pAlter->pass, strlen(pAlter->pass), pUser->pass);
|
||||
newUser.updateTime = taosGetTimestampMs();
|
||||
|
||||
int32_t code = mndUpdateUser(pMnode, pUser, &newUser, pMsg);
|
||||
int32_t code = mndUpdateUser(pMnode, pUser, &newUser, pReq);
|
||||
mndReleaseUser(pMnode, pOperUser);
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
|
@ -368,8 +367,8 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
|
||||
static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pReq, SUserObj *pUser) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to drop since %s", pUser->user, terrstr());
|
||||
return -1;
|
||||
|
@ -394,9 +393,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SDropUserReq *pDrop = pMsg->rpcMsg.pCont;
|
||||
static int32_t mndProcessDropUserReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SDropUserReq *pDrop = pReq->rpcMsg.pCont;
|
||||
|
||||
mDebug("user:%s, start to drop", pDrop->user);
|
||||
|
||||
|
@ -413,7 +412,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user);
|
||||
SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pOperUser == NULL) {
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||
|
@ -421,7 +420,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = mndDropUser(pMnode, pMsg, pUser);
|
||||
int32_t code = mndDropUser(pMnode, pReq, pUser);
|
||||
mndReleaseUser(pMnode, pOperUser);
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
|
@ -433,8 +432,8 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
|
|||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
|
@ -479,8 +478,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
static int32_t mndRetrieveUsers(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
SUserObj *pUser = NULL;
|
||||
|
|
|
@ -6,4 +6,4 @@ add_subdirectory(trans)
|
|||
add_subdirectory(qnode)
|
||||
add_subdirectory(snode)
|
||||
add_subdirectory(bnode)
|
||||
|
||||
add_subdirectory(show)
|
||||
|
|
|
@ -30,9 +30,9 @@ TEST_F(MndTestAcct, 01_Create_Acct) {
|
|||
|
||||
SCreateAcctReq* pReq = (SCreateAcctReq*)rpcMallocCont(contLen);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 02_Alter_Acct) {
|
||||
|
@ -40,9 +40,9 @@ TEST_F(MndTestAcct, 02_Alter_Acct) {
|
|||
|
||||
SAlterAcctReq* pReq = (SAlterAcctReq*)rpcMallocCont(contLen);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 03_Drop_Acct) {
|
||||
|
@ -50,18 +50,18 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
|
|||
|
||||
SDropAcctReq* pReq = (SDropAcctReq*)rpcMallocCont(contLen);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 04_Show_Acct) {
|
||||
int32_t contLen = sizeof(SShowMsg);
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
|
||||
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen);
|
||||
pReq->type = TSDB_MGMT_TABLE_ACCT;
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
|
@ -39,14 +39,14 @@ Testbase MndTestBnode::test;
|
|||
TestServer MndTestBnode::server2;
|
||||
|
||||
TEST_F(MndTestBnode, 01_Show_Bnode) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
CHECK_META("show bnodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -68,13 +68,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
CHECK_META("show bnodes", 3);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -88,9 +88,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_BNODE_ALREADY_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_BNODE_ALREADY_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9019);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -140,12 +140,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -159,9 +159,9 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_BNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_BNODE_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -187,9 +187,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -200,9 +200,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -219,9 +219,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -251,9 +251,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -264,9 +264,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -283,9 +283,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
|||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ Testbase MndTestQnode::test;
|
|||
TestServer MndTestQnode::server2;
|
||||
|
||||
TEST_F(MndTestQnode, 01_Show_Qnode) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -68,13 +68,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -88,9 +88,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9015);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -140,12 +140,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -159,9 +159,9 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_QNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -187,9 +187,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -200,9 +200,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -219,9 +219,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -251,9 +251,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -264,9 +264,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -283,9 +283,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
|||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
aux_source_directory(. SHOW_SRC)
|
||||
add_executable(mnode_test_show ${SHOW_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_show
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_show
|
||||
COMMAND mnode_test_show
|
||||
)
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* @file show.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief MNODE module show tests
|
||||
* @version 1.0
|
||||
* @date 2022-01-06
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sut.h"
|
||||
|
||||
class MndTestShow : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_show", 9020); }
|
||||
static void TearDownTestSuite() { test.Cleanup(); }
|
||||
|
||||
static Testbase test;
|
||||
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
Testbase MndTestShow::test;
|
||||
|
||||
TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen);
|
||||
pReq->type = TSDB_MGMT_TABLE_MAX;
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(sizeof(SShowReq));
|
||||
pReq->type = TSDB_MGMT_TABLE_START;
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
||||
int32_t contLen = sizeof(SConnectMsg);
|
||||
|
||||
SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen);
|
||||
pReq->pid = htonl(1234);
|
||||
strcpy(pReq->app, "mnode_test_show");
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, "");
|
||||
|
||||
STableMetaMsg* pMeta = test.GetShowMeta();
|
||||
EXPECT_STREQ(pMeta->tbFname, "show connections");
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, 7);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->update, 0);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tuid, 0);
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
|
||||
SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp();
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->completed, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 04_ShowMsg_Cluster) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CLUSTER, "");
|
||||
CHECK_META( "show cluster", 3);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
IgnoreInt64();
|
||||
IgnoreBinary(TSDB_CLUSTER_ID_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
|
@ -39,14 +39,14 @@ Testbase MndTestSnode::test;
|
|||
TestServer MndTestSnode::server2;
|
||||
|
||||
TEST_F(MndTestSnode, 01_Show_Snode) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
CHECK_META("show snodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -68,13 +68,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
CHECK_META("show snodes", 3);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -88,9 +88,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(1);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_SNODE_ALREADY_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_SNODE_ALREADY_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
strcpy(pReq->fqdn, "localhost");
|
||||
pReq->port = htonl(9017);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -140,12 +140,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
|
@ -159,9 +159,9 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_SNODE_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_SNODE_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -187,9 +187,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -200,9 +200,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -219,9 +219,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -251,9 +251,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -264,9 +264,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
|||
pReq->dnodeId = htonl(2);
|
||||
|
||||
server2.Stop();
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -283,9 +283,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
|||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
||||
pReq->dnodeId = htonl(2);
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
if (pMsg->code == 0) break;
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
if (pRsp->code == 0) break;
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,21 +58,21 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "p1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
KillThenRestartServer();
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
|
@ -83,4 +83,4 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
|||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class MndTestUser : public ::testing::Test {
|
|||
Testbase MndTestUser::test;
|
||||
|
||||
TEST_F(MndTestUser, 01_Show_User) {
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
|
@ -34,7 +34,7 @@ TEST_F(MndTestUser, 01_Show_User) {
|
|||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account");
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
@ -51,9 +51,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
strcpy(pReq->user, "");
|
||||
strcpy(pReq->pass, "p1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -63,9 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_PASS_FORMAT);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -75,9 +75,9 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
strcpy(pReq->user, "root");
|
||||
strcpy(pReq->pass, "1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_ALREADY_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_ALREADY_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -87,15 +87,15 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "p1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
strcpy(pReq->user, "");
|
||||
strcpy(pReq->pass, "p1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -119,9 +119,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_PASS_FORMAT);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -131,9 +131,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
strcpy(pReq->user, "u4");
|
||||
strcpy(pReq->pass, "1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -143,9 +143,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,9 +156,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
|
|||
SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->user, "");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -167,9 +167,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
|
|||
SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->user, "u4");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_NOT_EXIST);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -178,15 +178,15 @@ TEST_F(MndTestUser, 04_Drop_User) {
|
|||
SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->user, "u1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
||||
|
@ -198,9 +198,9 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "p1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -210,15 +210,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
|
|||
strcpy(pReq->user, "u2");
|
||||
strcpy(pReq->pass, "p2");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
|
@ -241,15 +241,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
|
|||
strcpy(pReq->user, "u1");
|
||||
strcpy(pReq->pass, "p2");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
|
@ -271,15 +271,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
|
|||
SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
|
||||
strcpy(pReq->user, "u1");
|
||||
|
||||
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
@ -294,10 +294,10 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
|
|||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveMsg();
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
SCreateUserReq* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SCreateAcctReq* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen);
|
||||
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen);
|
||||
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf);
|
||||
SCreateStbMsg* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
|
|
|
@ -85,8 +85,8 @@ SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, cha
|
|||
return pMsg;
|
||||
}
|
||||
|
||||
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, char* msgBuf, int32_t msgLen) {
|
||||
SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg));
|
||||
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, char* msgBuf, int32_t msgLen) {
|
||||
SShowReq* pShowMsg = calloc(1, sizeof(SShowReq));
|
||||
|
||||
pShowMsg->type = pShowInfo->showType;
|
||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||
|
|
|
@ -111,7 +111,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** ou
|
|||
|
||||
*pEpSet = pCtx->mgmtEpSet;
|
||||
*output = buildShowMsg(pShowInfo, pCtx, pMsgBuf->buf, pMsgBuf->len);
|
||||
*outputLen = sizeof(SShowMsg) /* + htons(pShowMsg->payloadLen)*/;
|
||||
*outputLen = sizeof(SShowReq) /* + htons(pShowMsg->payloadLen)*/;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -603,7 +603,7 @@ int tscBuildAndSendRequest(SSqlObj *pSql, SQueryInfo* pQueryInfo) {
|
|||
}
|
||||
|
||||
int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg *) pSql->cmd.payload;
|
||||
SRetrieveTableReq *pRetrieveMsg = (SRetrieveTableReq *) pSql->cmd.payload;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd);
|
||||
|
||||
|
@ -638,10 +638,10 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
pSql->res.qId);
|
||||
}
|
||||
|
||||
pSql->cmd.payloadLen = sizeof(SRetrieveTableMsg);
|
||||
pSql->cmd.payloadLen = sizeof(SRetrieveTableReq);
|
||||
pSql->cmd.msgType = TDMT_VND_FETCH;
|
||||
|
||||
pRetrieveMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg));
|
||||
pRetrieveMsg->header.contLen = htonl(sizeof(SRetrieveTableReq));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1420,7 +1420,7 @@ int32_t tscBuildSyncDbReplicaMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
|
|||
int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
pCmd->msgType = TDMT_MND_SHOW;
|
||||
pCmd->payloadLen = sizeof(SShowMsg) + 100;
|
||||
pCmd->payloadLen = sizeof(SShowReq) + 100;
|
||||
|
||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
||||
tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self);
|
||||
|
@ -1428,13 +1428,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
|
||||
SShowInfo *pShowInfo = &pInfo->pMiscInfo->showOpt;
|
||||
SShowMsg *pShowMsg = (SShowMsg *)pCmd->payload;
|
||||
SShowReq *pShowMsg = (SShowReq *)pCmd->payload;
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0);
|
||||
if (pShowInfo->showType == TSDB_MGMT_TABLE_FUNCTION) {
|
||||
pShowMsg->type = pShowInfo->showType;
|
||||
pShowMsg->payloadLen = 0;
|
||||
pCmd->payloadLen = sizeof(SShowMsg);
|
||||
pCmd->payloadLen = sizeof(SShowReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1463,7 +1463,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
pShowMsg->payloadLen = htons(pEpAddr->n);
|
||||
}
|
||||
|
||||
pCmd->payloadLen = sizeof(SShowMsg) + htons(pShowMsg->payloadLen);
|
||||
pCmd->payloadLen = sizeof(SShowReq) + htons(pShowMsg->payloadLen);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1742,7 +1742,7 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
pCmd->msgType = TDMT_MND_SHOW_RETRIEVE;
|
||||
pCmd->payloadLen = sizeof(SRetrieveTableMsg);
|
||||
pCmd->payloadLen = sizeof(SRetrieveTableReq);
|
||||
|
||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
||||
tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self);
|
||||
|
@ -1750,7 +1750,7 @@ int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd);
|
||||
SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg*)pCmd->payload;
|
||||
SRetrieveTableReq *pRetrieveMsg = (SRetrieveTableReq*)pCmd->payload;
|
||||
pRetrieveMsg->qId = htobe64(pSql->res.qId);
|
||||
pRetrieveMsg->free = htons(pQueryInfo->type);
|
||||
|
||||
|
|
Loading…
Reference in New Issue