TD-10431 refact dnode test
This commit is contained in:
parent
6941b14878
commit
6be2787796
|
@ -16,10 +16,7 @@
|
||||||
#include "deploy.h"
|
#include "deploy.h"
|
||||||
|
|
||||||
class DndTestDnode : public ::testing::Test {
|
class DndTestDnode : public ::testing::Test {
|
||||||
protected:
|
public:
|
||||||
void SetUp() override {}
|
|
||||||
void TearDown() override {}
|
|
||||||
|
|
||||||
static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||||
SServer* pServer = createServer(path, fqdn, port, firstEp);
|
SServer* pServer = createServer(path, fqdn, port, firstEp);
|
||||||
ASSERT(pServer);
|
ASSERT(pServer);
|
||||||
|
@ -27,14 +24,17 @@ class DndTestDnode : public ::testing::Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
|
initLog("/tmp/dndTestDnode1");
|
||||||
|
|
||||||
const char* fqdn = "localhost";
|
const char* fqdn = "localhost";
|
||||||
const char* firstEp = "localhost:9521";
|
const char* firstEp = "localhost:9521";
|
||||||
pServer1 = CreateServer("/tmp/dndTestDnode1", fqdn, 9521, firstEp);
|
pServer1 = CreateServer("/tmp/dndTestDnode1", fqdn, 9521, firstEp);
|
||||||
pServer2 = CreateServer("/tmp/dndTestDnode2", fqdn, 9522, firstEp);
|
pServer2 = CreateServer("/tmp/dndTestDnode2", fqdn, 9522, firstEp);
|
||||||
pServer3 = CreateServer("/tmp/dndTestDnode3", fqdn, 9523, firstEp);
|
// pServer3 = CreateServer("/tmp/dndTestDnode3", fqdn, 9523, firstEp);
|
||||||
pServer4 = CreateServer("/tmp/dndTestDnode4", fqdn, 9524, firstEp);
|
// pServer4 = CreateServer("/tmp/dndTestDnode4", fqdn, 9524, firstEp);
|
||||||
pServer5 = CreateServer("/tmp/dndTestDnode5", fqdn, 9525, firstEp);
|
// pServer5 = CreateServer("/tmp/dndTestDnode5", fqdn, 9525, firstEp);
|
||||||
pClient = createClient("root", "taosdata", fqdn, 9521);
|
pClient = createClient("root", "taosdata", fqdn, 9521);
|
||||||
|
taosMsleep(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestSuite() {
|
static void TearDownTestSuite() {
|
||||||
|
@ -53,9 +53,127 @@ class DndTestDnode : public ::testing::Test {
|
||||||
static SServer* pServer5;
|
static SServer* pServer5;
|
||||||
static SClient* pClient;
|
static SClient* pClient;
|
||||||
|
|
||||||
void CheckShowMsg(int8_t msgType) {
|
public:
|
||||||
|
void SetUp() override {}
|
||||||
|
void TearDown() override {}
|
||||||
|
|
||||||
|
void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns) {
|
||||||
|
//--- meta ---
|
||||||
|
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
||||||
|
pShow->type = showType;
|
||||||
|
strcpy(pShow->db, "");
|
||||||
|
|
||||||
|
SRpcMsg showRpcMsg = {0};
|
||||||
|
showRpcMsg.pCont = pShow;
|
||||||
|
showRpcMsg.contLen = sizeof(SShowMsg);
|
||||||
|
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
||||||
|
|
||||||
|
sendMsg(pClient, &showRpcMsg);
|
||||||
|
ASSERT_NE(pClient->pRsp, nullptr);
|
||||||
|
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||||
|
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||||
|
|
||||||
|
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
|
||||||
|
ASSERT_NE(pShowRsp, nullptr);
|
||||||
|
pShowRsp->showId = htonl(pShowRsp->showId);
|
||||||
|
pMeta = &pShowRsp->tableMeta;
|
||||||
|
pMeta->numOfTags = htons(pMeta->numOfTags);
|
||||||
|
pMeta->numOfColumns = htons(pMeta->numOfColumns);
|
||||||
|
pMeta->sversion = htons(pMeta->sversion);
|
||||||
|
pMeta->tversion = htons(pMeta->tversion);
|
||||||
|
pMeta->tuid = htobe64(pMeta->tuid);
|
||||||
|
pMeta->suid = htobe64(pMeta->suid);
|
||||||
|
|
||||||
|
showId = pShowRsp->showId;
|
||||||
|
|
||||||
|
EXPECT_NE(pShowRsp->showId, 0);
|
||||||
|
EXPECT_STREQ(pMeta->tbFname, showName);
|
||||||
|
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||||
|
EXPECT_EQ(pMeta->numOfColumns, columns);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||||
|
SSchema* pSchema = &pMeta->pSchema[index];
|
||||||
|
pSchema->bytes = htons(pSchema->bytes);
|
||||||
|
EXPECT_EQ(pSchema->colId, 0);
|
||||||
|
EXPECT_EQ(pSchema->type, type);
|
||||||
|
EXPECT_EQ(pSchema->bytes, bytes);
|
||||||
|
EXPECT_STREQ(pSchema->name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendThenCheckShowRetrieveMsg(int32_t rows) {
|
||||||
|
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
||||||
|
pRetrieve->showId = htonl(showId);
|
||||||
|
pRetrieve->free = 0;
|
||||||
|
|
||||||
|
SRpcMsg retrieveRpcMsg = {0};
|
||||||
|
retrieveRpcMsg.pCont = pRetrieve;
|
||||||
|
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
||||||
|
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
||||||
|
|
||||||
|
sendMsg(pClient, &retrieveRpcMsg);
|
||||||
|
|
||||||
|
ASSERT_NE(pClient->pRsp, nullptr);
|
||||||
|
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||||
|
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||||
|
|
||||||
|
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||||
|
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||||
|
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||||
|
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
|
||||||
|
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||||
|
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||||
|
|
||||||
|
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||||
|
EXPECT_EQ(pRetrieveRsp->offset, 0);
|
||||||
|
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->reserved, 0);
|
||||||
|
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||||
|
|
||||||
|
pData = pRetrieveRsp->data;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckInt16(int16_t val) {
|
||||||
|
int16_t data = *((int16_t*)(pData + pos));
|
||||||
|
pos += sizeof(int16_t);
|
||||||
|
EXPECT_EQ(data, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckInt64(int64_t val) {
|
||||||
|
int64_t data = *((int64_t*)(pData + pos));
|
||||||
|
pos += sizeof(int64_t);
|
||||||
|
EXPECT_EQ(data, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckTimestamp() {
|
||||||
|
int64_t data = *((int64_t*)(pData + pos));
|
||||||
|
pos += sizeof(int64_t);
|
||||||
|
EXPECT_GT(data, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckBinary(const char* val, int32_t len) {
|
||||||
|
pos += sizeof(VarDataLenT);
|
||||||
|
char* data = (char*)(pData + pos);
|
||||||
|
pos += len;
|
||||||
|
EXPECT_STREQ(data, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t showId;
|
||||||
|
STableMetaMsg* pMeta;
|
||||||
|
SRetrieveTableRsp* pRetrieveRsp;
|
||||||
|
char* pData;
|
||||||
|
int32_t pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
SServer* DndTestDnode::pServer1;
|
SServer* DndTestDnode::pServer1;
|
||||||
|
@ -66,250 +184,59 @@ SServer* DndTestDnode::pServer5;
|
||||||
SClient* DndTestDnode::pClient;
|
SClient* DndTestDnode::pClient;
|
||||||
|
|
||||||
TEST_F(DndTestDnode, ShowDnode) {
|
TEST_F(DndTestDnode, ShowDnode) {
|
||||||
int32_t showId = 0;
|
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
|
||||||
|
CheckSchema(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||||
|
CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "end point");
|
||||||
|
CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes");
|
||||||
|
CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "max vnodes");
|
||||||
|
CheckSchema(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status");
|
||||||
|
CheckSchema(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time");
|
||||||
|
CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline reason");
|
||||||
|
|
||||||
//--- meta ---
|
SendThenCheckShowRetrieveMsg(1);
|
||||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
CheckInt16(1);
|
||||||
pShow->type = TSDB_MGMT_TABLE_DNODE;
|
CheckBinary("localhost:9521", TSDB_EP_LEN);
|
||||||
strcpy(pShow->db, "");
|
CheckInt16(0);
|
||||||
|
CheckInt16(1);
|
||||||
SRpcMsg showRpcMsg = {0};
|
CheckBinary("ready", 10);
|
||||||
showRpcMsg.pCont = pShow;
|
CheckTimestamp();
|
||||||
showRpcMsg.contLen = sizeof(SShowMsg);
|
CheckBinary("", 24);
|
||||||
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
|
||||||
|
|
||||||
sendMsg(pClient, &showRpcMsg);
|
|
||||||
ASSERT_NE(pClient->pRsp, nullptr);
|
|
||||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
|
||||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
|
||||||
|
|
||||||
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
|
|
||||||
ASSERT_NE(pShowRsp, nullptr);
|
|
||||||
pShowRsp->showId = htonl(pShowRsp->showId);
|
|
||||||
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
|
|
||||||
pMeta->numOfTags = htons(pMeta->numOfTags);
|
|
||||||
pMeta->numOfColumns = htons(pMeta->numOfColumns);
|
|
||||||
pMeta->sversion = htons(pMeta->sversion);
|
|
||||||
pMeta->tversion = htons(pMeta->tversion);
|
|
||||||
pMeta->tuid = htobe64(pMeta->tuid);
|
|
||||||
pMeta->suid = htobe64(pMeta->suid);
|
|
||||||
|
|
||||||
showId = pShowRsp->showId;
|
|
||||||
|
|
||||||
EXPECT_NE(pShowRsp->showId, 0);
|
|
||||||
EXPECT_STREQ(pMeta->tbFname, "show dnodes");
|
|
||||||
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);
|
|
||||||
|
|
||||||
SSchema* pSchema = NULL;
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[0];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_SMALLINT);
|
|
||||||
EXPECT_EQ(pSchema->bytes, 2);
|
|
||||||
EXPECT_STREQ(pSchema->name, "id");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[1];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
|
||||||
EXPECT_EQ(pSchema->bytes, TSDB_EP_LEN + VARSTR_HEADER_SIZE);
|
|
||||||
EXPECT_STREQ(pSchema->name, "end point");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[2];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_SMALLINT);
|
|
||||||
EXPECT_EQ(pSchema->bytes, 2);
|
|
||||||
EXPECT_STREQ(pSchema->name, "vnodes");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[3];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_SMALLINT);
|
|
||||||
EXPECT_EQ(pSchema->bytes, 2);
|
|
||||||
EXPECT_STREQ(pSchema->name, "max vnodes");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[4];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
|
||||||
EXPECT_EQ(pSchema->bytes, 10 + VARSTR_HEADER_SIZE);
|
|
||||||
EXPECT_STREQ(pSchema->name, "status");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[5];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
EXPECT_EQ(pSchema->bytes, 8);
|
|
||||||
EXPECT_STREQ(pSchema->name, "create time");
|
|
||||||
|
|
||||||
pSchema = &pMeta->pSchema[6];
|
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
EXPECT_EQ(pSchema->colId, 0);
|
|
||||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
|
||||||
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
|
|
||||||
EXPECT_STREQ(pSchema->name, "offline reason");
|
|
||||||
|
|
||||||
//--- retrieve ---
|
|
||||||
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
|
||||||
pRetrieve->showId = htonl(showId);
|
|
||||||
pRetrieve->free = 0;
|
|
||||||
|
|
||||||
SRpcMsg retrieveRpcMsg = {0};
|
|
||||||
retrieveRpcMsg.pCont = pRetrieve;
|
|
||||||
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
|
||||||
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
|
||||||
|
|
||||||
sendMsg(pClient, &retrieveRpcMsg);
|
|
||||||
ASSERT_NE(pClient->pRsp, nullptr);
|
|
||||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
|
||||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
|
||||||
|
|
||||||
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
|
||||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
|
||||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
|
||||||
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
|
|
||||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
|
||||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
|
||||||
|
|
||||||
EXPECT_EQ(pRetrieveRsp->numOfRows, 1);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->offset, 0);
|
|
||||||
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->reserved, 0);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
|
||||||
|
|
||||||
char* pData = pRetrieveRsp->data;
|
|
||||||
int32_t pos = 0;
|
|
||||||
char* strVal = NULL;
|
|
||||||
int64_t int64Val = 0;
|
|
||||||
int16_t int16Val = 0;
|
|
||||||
|
|
||||||
//--- name ---
|
|
||||||
{
|
|
||||||
int16Val = *((int16_t*)(pData + pos));
|
|
||||||
pos += sizeof(int16_t);
|
|
||||||
EXPECT_EQ(int16Val, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// //--- privilege ---
|
|
||||||
// {
|
|
||||||
// pos += sizeof(VarDataLenT);
|
|
||||||
// strVal = (char*)(pData + pos);
|
|
||||||
// pos += 10;
|
|
||||||
// EXPECT_STREQ(strVal, "super");
|
|
||||||
|
|
||||||
// pos += sizeof(VarDataLenT);
|
|
||||||
// strVal = (char*)(pData + pos);
|
|
||||||
// pos += 10;
|
|
||||||
// EXPECT_STREQ(strVal, "writable");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //--- create_time ---
|
|
||||||
// {
|
|
||||||
// int64Val = *((int64_t*)(pData + pos));
|
|
||||||
// pos += sizeof(int64_t);
|
|
||||||
// EXPECT_GT(int64Val, 0);
|
|
||||||
|
|
||||||
// int64Val = *((int64_t*)(pData + pos));
|
|
||||||
// pos += sizeof(int64_t);
|
|
||||||
// EXPECT_GT(int64Val, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //--- account ---
|
|
||||||
// {
|
|
||||||
// pos += sizeof(VarDataLenT);
|
|
||||||
// strVal = (char*)(pData + pos);
|
|
||||||
// pos += TSDB_USER_LEN;
|
|
||||||
// EXPECT_STREQ(strVal, "root");
|
|
||||||
|
|
||||||
// pos += sizeof(VarDataLenT);
|
|
||||||
// strVal = (char*)(pData + pos);
|
|
||||||
// pos += TSDB_USER_LEN;
|
|
||||||
// EXPECT_STREQ(strVal, "root");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
TEST_F(DndTestDnode, CreateDnode_01) {
|
||||||
TEST_F(DndTestDnode, CreateUser_01) {
|
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(sizeof(SCreateDnodeMsg));
|
||||||
ASSERT_NE(pClient, nullptr);
|
strcpy(pReq->ep, "localhost:9522");
|
||||||
|
|
||||||
//--- create user ---
|
|
||||||
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg));
|
|
||||||
strcpy(pReq->user, "u1");
|
|
||||||
strcpy(pReq->pass, "p1");
|
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg rpcMsg = {0};
|
||||||
rpcMsg.pCont = pReq;
|
rpcMsg.pCont = pReq;
|
||||||
rpcMsg.contLen = sizeof(SCreateUserMsg);
|
rpcMsg.contLen = sizeof(SCreateDnodeMsg);
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_USER;
|
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_DNODE;
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
sendMsg(pClient, &rpcMsg);
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
SRpcMsg* pMsg = pClient->pRsp;
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
|
|
||||||
//--- meta ---
|
taosMsleep(1300);
|
||||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
|
||||||
pShow->type = TSDB_MGMT_TABLE_USER;
|
SendThenCheckShowRetrieveMsg(2);
|
||||||
SRpcMsg showRpcMsg = {0};
|
CheckInt16(1);
|
||||||
showRpcMsg.pCont = pShow;
|
CheckInt16(2);
|
||||||
showRpcMsg.contLen = sizeof(SShowMsg);
|
CheckBinary("localhost:9521", TSDB_EP_LEN);
|
||||||
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
CheckBinary("localhost:9522", TSDB_EP_LEN);
|
||||||
|
CheckInt16(0);
|
||||||
sendMsg(pClient, &showRpcMsg);
|
CheckInt16(0);
|
||||||
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
|
CheckInt16(1);
|
||||||
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
|
CheckInt16(1);
|
||||||
pMeta->numOfColumns = htons(pMeta->numOfColumns);
|
CheckBinary("ready", 10);
|
||||||
EXPECT_EQ(pMeta->numOfColumns, 4);
|
CheckBinary("ready", 10);
|
||||||
|
CheckTimestamp();
|
||||||
//--- retrieve ---
|
CheckTimestamp();
|
||||||
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
CheckBinary("", 24);
|
||||||
pRetrieve->showId = pShowRsp->showId;
|
CheckBinary("", 24);
|
||||||
SRpcMsg retrieveRpcMsg = {0};
|
|
||||||
retrieveRpcMsg.pCont = pRetrieve;
|
|
||||||
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
|
||||||
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
|
||||||
|
|
||||||
sendMsg(pClient, &retrieveRpcMsg);
|
|
||||||
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
|
||||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->numOfRows, 3);
|
|
||||||
|
|
||||||
char* pData = pRetrieveRsp->data;
|
|
||||||
int32_t pos = 0;
|
|
||||||
char* strVal = NULL;
|
|
||||||
|
|
||||||
//--- name ---
|
|
||||||
{
|
|
||||||
pos += sizeof(VarDataLenT);
|
|
||||||
strVal = (char*)(pData + pos);
|
|
||||||
pos += TSDB_USER_LEN;
|
|
||||||
EXPECT_STREQ(strVal, "u1");
|
|
||||||
|
|
||||||
pos += sizeof(VarDataLenT);
|
|
||||||
strVal = (char*)(pData + pos);
|
|
||||||
pos += TSDB_USER_LEN;
|
|
||||||
EXPECT_STREQ(strVal, "root");
|
|
||||||
|
|
||||||
pos += sizeof(VarDataLenT);
|
|
||||||
strVal = (char*)(pData + pos);
|
|
||||||
pos += TSDB_USER_LEN;
|
|
||||||
EXPECT_STREQ(strVal, "_root");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
TEST_F(DndTestDnode, AlterUser_01) {
|
TEST_F(DndTestDnode, AlterUser_01) {
|
||||||
ASSERT_NE(pClient, nullptr);
|
ASSERT_NE(pClient, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ void initOption(SDnodeOpt* pOption, const char* path, const char* fqdn, uint16_t
|
||||||
SServer* createServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
SServer* createServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||||
taosRemoveDir(path);
|
taosRemoveDir(path);
|
||||||
taosMkDir(path);
|
taosMkDir(path);
|
||||||
initLog(path);
|
|
||||||
|
|
||||||
SDnodeOpt option = {0};
|
SDnodeOpt option = {0};
|
||||||
initOption(&option, path, fqdn, port, firstEp);
|
initOption(&option, path, fqdn, port, firstEp);
|
||||||
|
|
|
@ -39,8 +39,11 @@ typedef struct {
|
||||||
tsem_t sem;
|
tsem_t sem;
|
||||||
} SClient;
|
} SClient;
|
||||||
|
|
||||||
|
void initLog(const char* path);
|
||||||
SServer* createServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
SServer* createServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
||||||
void dropServer(SServer* pServer);
|
void dropServer(SServer* pServer);
|
||||||
SClient* createClient(const char* user, const char* pass, const char* fqdn, uint16_t port);
|
SClient* createClient(const char* user, const char* pass, const char* fqdn, uint16_t port);
|
||||||
void dropClient(SClient* pClient);
|
void dropClient(SClient* pClient);
|
||||||
void sendMsg(SClient* pClient, SRpcMsg* pMsg);
|
void sendMsg(SClient* pClient, SRpcMsg* pMsg);
|
||||||
|
|
||||||
|
// class DndTest
|
|
@ -756,7 +756,11 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]);
|
if (pDnode->status == DND_STATUS_READY) {
|
||||||
|
STR_TO_VARSTR(pWrite, "");
|
||||||
|
} else {
|
||||||
|
STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]);
|
||||||
|
}
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
Loading…
Reference in New Issue