TD-10431 refact dnode test
This commit is contained in:
parent
15a43d5ae4
commit
a628054f51
|
@ -1,10 +1,10 @@
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
#add_subdirectory(acct)
|
add_subdirectory(acct)
|
||||||
# add_subdirectory(auth)
|
# add_subdirectory(auth)
|
||||||
# add_subdirectory(balance)
|
# add_subdirectory(balance)
|
||||||
#add_subdirectory(cluster)
|
add_subdirectory(cluster)
|
||||||
#add_subdirectory(db)
|
add_subdirectory(db)
|
||||||
#add_subdirectory(dnode)
|
#add_subdirectory(dnode)
|
||||||
# add_subdirectory(func)
|
# add_subdirectory(func)
|
||||||
# add_subdirectory(mnode)
|
# add_subdirectory(mnode)
|
||||||
|
|
|
@ -23,6 +23,8 @@ class DndTestAcct : public ::testing::Test {
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Testbase DndTestAcct::test;
|
||||||
|
|
||||||
TEST_F(DndTestAcct, 01_CreateAcct) {
|
TEST_F(DndTestAcct, 01_CreateAcct) {
|
||||||
int32_t contLen = sizeof(SCreateAcctMsg);
|
int32_t contLen = sizeof(SCreateAcctMsg);
|
||||||
|
|
||||||
|
@ -61,5 +63,5 @@ TEST_F(DndTestAcct, 04_ShowAcct) {
|
||||||
|
|
||||||
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_SHOW, pReq, contLen);
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_SHOW, pReq, contLen);
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||||
}
|
}
|
|
@ -26,24 +26,16 @@ class DndTestCluster : public ::testing::Test {
|
||||||
Testbase DndTestCluster::test;
|
Testbase DndTestCluster::test;
|
||||||
|
|
||||||
TEST_F(DndTestCluster, 01_ShowCluster) {
|
TEST_F(DndTestCluster, 01_ShowCluster) {
|
||||||
test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, "");
|
||||||
EXPECT_EQ(test.GetMetaNum(), 3);
|
CHECK_META( "show cluster", 3);
|
||||||
EXPECT_STREQ(test.GetMetaTbName(), "show cluster");
|
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "id");
|
||||||
|
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name");
|
||||||
EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_INT);
|
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||||
EXPECT_EQ(test.GetMetaBytes(0), 4);
|
|
||||||
EXPECT_STREQ(test.GetMetaName(0), "id");
|
|
||||||
|
|
||||||
EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_BINARY);
|
|
||||||
EXPECT_EQ(test.GetMetaBytes(0), TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE);
|
|
||||||
EXPECT_STREQ(test.GetMetaName(0), "name");
|
|
||||||
|
|
||||||
EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
EXPECT_EQ(test.GetMetaBytes(0), 8);
|
|
||||||
EXPECT_STREQ(test.GetMetaName(0), "create_time");
|
|
||||||
|
|
||||||
test.SendShowRetrieveMsg();
|
test.SendShowRetrieveMsg();
|
||||||
test.GetShowInt32();
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
test.GetShowBinary(TSDB_CLUSTER_ID_LEN);
|
|
||||||
EXPECT_GT(test.GetShowTimestamp(), 0);
|
IgnoreInt32();
|
||||||
|
IgnoreBinary(TSDB_CLUSTER_ID_LEN);
|
||||||
|
CheckTimestamp();
|
||||||
}
|
}
|
|
@ -1,24 +1,8 @@
|
||||||
add_executable(dnode_test_db "")
|
aux_source_directory(. DB_SRC)
|
||||||
|
add_executable(dnode_test_db ${DB_SRC})
|
||||||
target_sources(dnode_test_db
|
|
||||||
PRIVATE
|
|
||||||
"db.cpp"
|
|
||||||
"../sut/deploy.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode_test_db
|
dnode_test_db
|
||||||
PUBLIC dnode
|
PUBLIC sut
|
||||||
PUBLIC util
|
|
||||||
PUBLIC os
|
|
||||||
PUBLIC gtest_main
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(dnode_test_db
|
|
||||||
PUBLIC
|
|
||||||
"${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
|
|
|
@ -9,199 +9,52 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "deploy.h"
|
#include "base.h"
|
||||||
|
|
||||||
class DndTestDb : public ::testing::Test {
|
class DndTestDb : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_db", 9040); }
|
||||||
SServer* pServer = createServer(path, fqdn, port, firstEp);
|
static void TearDownTestSuite() { test.Cleanup(); }
|
||||||
ASSERT(pServer);
|
|
||||||
return pServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetUpTestSuite() {
|
static Testbase test;
|
||||||
initLog("/tmp/tdlog");
|
|
||||||
|
|
||||||
const char* fqdn = "localhost";
|
|
||||||
const char* firstEp = "localhost:9040";
|
|
||||||
pServer = CreateServer("/tmp/dnode_test_db", fqdn, 9040, firstEp);
|
|
||||||
pClient = createClient("root", "taosdata", fqdn, 9040);
|
|
||||||
taosMsleep(1100);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TearDownTestSuite() {
|
|
||||||
stopServer(pServer);
|
|
||||||
dropClient(pClient);
|
|
||||||
pServer = NULL;
|
|
||||||
pClient = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SServer* pServer;
|
|
||||||
static SClient* pClient;
|
|
||||||
static int32_t connId;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetUp() override {}
|
void SetUp() override {}
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
|
|
||||||
void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns, const char* db) {
|
|
||||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
|
||||||
pShow->type = showType;
|
|
||||||
if (db != NULL) {
|
|
||||||
strcpy(pShow->db, 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 = htonl(pMeta->numOfTags);
|
|
||||||
pMeta->numOfColumns = htonl(pMeta->numOfColumns);
|
|
||||||
pMeta->sversion = htonl(pMeta->sversion);
|
|
||||||
pMeta->tversion = htonl(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 = htonl(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->useconds = htobe64(pRetrieveRsp->useconds);
|
|
||||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
|
||||||
|
|
||||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
|
||||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
|
||||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
|
||||||
|
|
||||||
pData = pRetrieveRsp->data;
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckInt8(int8_t val) {
|
|
||||||
int8_t data = *((int8_t*)(pData + pos));
|
|
||||||
pos += sizeof(int8_t);
|
|
||||||
EXPECT_EQ(data, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckInt16(int16_t val) {
|
|
||||||
int16_t data = *((int16_t*)(pData + pos));
|
|
||||||
pos += sizeof(int16_t);
|
|
||||||
EXPECT_EQ(data, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckInt32(int32_t val) {
|
|
||||||
int32_t data = *((int32_t*)(pData + pos));
|
|
||||||
pos += sizeof(int32_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* DndTestDb::pServer;
|
Testbase DndTestDb::test;
|
||||||
SClient* DndTestDb::pClient;
|
|
||||||
int32_t DndTestDb::connId;
|
|
||||||
|
|
||||||
TEST_F(DndTestDb, 01_ShowDb) {
|
TEST_F(DndTestDb, 01_ShowDb) {
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
CHECK_META("show databases", 17);
|
||||||
CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
||||||
CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
|
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||||
CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "replica");
|
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
|
||||||
CheckSchema(4, TSDB_DATA_TYPE_SMALLINT, 2, "quorum");
|
CHECK_SCHEMA(3, TSDB_DATA_TYPE_SMALLINT, 2, "replica");
|
||||||
CheckSchema(5, TSDB_DATA_TYPE_SMALLINT, 2, "days");
|
CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "quorum");
|
||||||
CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2");
|
CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "days");
|
||||||
CheckSchema(7, TSDB_DATA_TYPE_INT, 4, "cache");
|
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2");
|
||||||
CheckSchema(8, TSDB_DATA_TYPE_INT, 4, "blocks");
|
CHECK_SCHEMA(7, TSDB_DATA_TYPE_INT, 4, "cache");
|
||||||
CheckSchema(9, TSDB_DATA_TYPE_INT, 4, "minrows");
|
CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "blocks");
|
||||||
CheckSchema(10, TSDB_DATA_TYPE_INT, 4, "maxrows");
|
CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "minrows");
|
||||||
CheckSchema(11, TSDB_DATA_TYPE_TINYINT, 1, "wallevel");
|
CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "maxrows");
|
||||||
CheckSchema(12, TSDB_DATA_TYPE_INT, 4, "fsync");
|
CHECK_SCHEMA(11, TSDB_DATA_TYPE_TINYINT, 1, "wallevel");
|
||||||
CheckSchema(13, TSDB_DATA_TYPE_TINYINT, 1, "comp");
|
CHECK_SCHEMA(12, TSDB_DATA_TYPE_INT, 4, "fsync");
|
||||||
CheckSchema(14, TSDB_DATA_TYPE_TINYINT, 1, "cachelast");
|
CHECK_SCHEMA(13, TSDB_DATA_TYPE_TINYINT, 1, "comp");
|
||||||
CheckSchema(15, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
|
CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "cachelast");
|
||||||
CheckSchema(16, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
CHECK_SCHEMA(15, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
|
||||||
|
CHECK_SCHEMA(16, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
||||||
|
|
||||||
SendThenCheckShowRetrieveMsg(0);
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
{
|
{
|
||||||
SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(sizeof(SCreateDbMsg));
|
int32_t contLen = sizeof(SCreateDbMsg);
|
||||||
|
|
||||||
|
SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(contLen);
|
||||||
strcpy(pReq->db, "1.d1");
|
strcpy(pReq->db, "1.d1");
|
||||||
pReq->numOfVgroups = htonl(2);
|
pReq->numOfVgroups = htonl(2);
|
||||||
pReq->cacheBlockSize = htonl(16);
|
pReq->cacheBlockSize = htonl(16);
|
||||||
|
@ -223,20 +76,16 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
pReq->cacheLastRow = 0;
|
pReq->cacheLastRow = 0;
|
||||||
pReq->ignoreExist = 1;
|
pReq->ignoreExist = 1;
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DB, pReq, contLen);
|
||||||
rpcMsg.pCont = pReq;
|
|
||||||
rpcMsg.contLen = sizeof(SCreateDbMsg);
|
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_DB;
|
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
// taosMsleep(1000000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
SendThenCheckShowRetrieveMsg(1);
|
CHECK_META("show databases", 17);
|
||||||
|
|
||||||
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||||
CheckTimestamp();
|
CheckTimestamp();
|
||||||
CheckInt16(2); // vgroups
|
CheckInt16(2); // vgroups
|
||||||
|
@ -255,12 +104,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
CheckBinary("ms", 3); // precision
|
CheckBinary("ms", 3); // precision
|
||||||
CheckInt8(0); // update
|
CheckInt8(0); // update
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_VGROUP, "show vgroups", 4, "1.d1");
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_VGROUP, "1.d1");
|
||||||
CheckSchema(0, TSDB_DATA_TYPE_INT, 4, "vgId");
|
CHECK_META("show vgroups", 4);
|
||||||
CheckSchema(1, TSDB_DATA_TYPE_INT, 4, "tables");
|
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId");
|
||||||
CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode");
|
CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables");
|
||||||
CheckSchema(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status");
|
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode");
|
||||||
SendThenCheckShowRetrieveMsg(2);
|
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status");
|
||||||
|
|
||||||
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 2);
|
||||||
CheckInt32(1);
|
CheckInt32(1);
|
||||||
CheckInt32(2);
|
CheckInt32(2);
|
||||||
CheckInt32(0);
|
CheckInt32(0);
|
||||||
|
@ -271,7 +123,9 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
CheckBinary("master", 9);
|
CheckBinary("master", 9);
|
||||||
|
|
||||||
{
|
{
|
||||||
SAlterDbMsg* pReq = (SAlterDbMsg*)rpcMallocCont(sizeof(SAlterDbMsg));
|
int32_t contLen = sizeof(SAlterDbMsg);
|
||||||
|
|
||||||
|
SAlterDbMsg* pReq = (SAlterDbMsg*)rpcMallocCont(contLen);
|
||||||
strcpy(pReq->db, "1.d1");
|
strcpy(pReq->db, "1.d1");
|
||||||
pReq->totalBlocks = htonl(12);
|
pReq->totalBlocks = htonl(12);
|
||||||
pReq->daysToKeep0 = htonl(300);
|
pReq->daysToKeep0 = htonl(300);
|
||||||
|
@ -282,19 +136,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
pReq->quorum = 2;
|
pReq->quorum = 2;
|
||||||
pReq->cacheLastRow = 1;
|
pReq->cacheLastRow = 1;
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_ALTER_DB, pReq, contLen);
|
||||||
rpcMsg.pCont = pReq;
|
|
||||||
rpcMsg.contLen = sizeof(SAlterDbMsg);
|
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_ALTER_DB;
|
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
SendThenCheckShowRetrieveMsg(1);
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||||
CheckTimestamp();
|
CheckTimestamp();
|
||||||
CheckInt16(2); // vgroups
|
CheckInt16(2); // vgroups
|
||||||
|
@ -314,19 +163,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
CheckInt8(0); // update
|
CheckInt8(0); // update
|
||||||
|
|
||||||
// restart
|
// restart
|
||||||
stopServer(pServer);
|
test.Restart();
|
||||||
pServer = NULL;
|
|
||||||
|
|
||||||
uInfo("start all server");
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
|
CHECK_META("show databases", 17);
|
||||||
|
|
||||||
const char* fqdn = "localhost";
|
test.SendShowRetrieveMsg();
|
||||||
const char* firstEp = "localhost:9040";
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
pServer = startServer("/tmp/dnode_test_db", fqdn, 9040, firstEp);
|
|
||||||
|
|
||||||
uInfo("all server is running");
|
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
|
||||||
SendThenCheckShowRetrieveMsg(1);
|
|
||||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||||
CheckTimestamp();
|
CheckTimestamp();
|
||||||
CheckInt16(2); // vgroups
|
CheckInt16(2); // vgroups
|
||||||
|
@ -346,27 +190,28 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
CheckInt8(0); // update
|
CheckInt8(0); // update
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbMsg* pReq = (SDropDbMsg*)rpcMallocCont(sizeof(SDropDbMsg));
|
int32_t contLen = sizeof(SDropDbMsg);
|
||||||
|
|
||||||
|
SDropDbMsg* pReq = (SDropDbMsg*)rpcMallocCont(contLen);
|
||||||
strcpy(pReq->db, "1.d1");
|
strcpy(pReq->db, "1.d1");
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_DROP_DB, pReq, contLen);
|
||||||
rpcMsg.pCont = pReq;
|
|
||||||
rpcMsg.contLen = sizeof(SDropDbMsg);
|
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_DROP_DB;
|
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
SendThenCheckShowRetrieveMsg(0);
|
CHECK_META("show databases", 17);
|
||||||
|
|
||||||
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
|
TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
|
||||||
{
|
{
|
||||||
SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(sizeof(SCreateDbMsg));
|
int32_t contLen = sizeof(SCreateDbMsg);
|
||||||
|
|
||||||
|
SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(contLen);
|
||||||
strcpy(pReq->db, "1.d2");
|
strcpy(pReq->db, "1.d2");
|
||||||
pReq->numOfVgroups = htonl(2);
|
pReq->numOfVgroups = htonl(2);
|
||||||
pReq->cacheBlockSize = htonl(16);
|
pReq->cacheBlockSize = htonl(16);
|
||||||
|
@ -388,33 +233,26 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
|
||||||
pReq->cacheLastRow = 0;
|
pReq->cacheLastRow = 0;
|
||||||
pReq->ignoreExist = 1;
|
pReq->ignoreExist = 1;
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_CREATE_DB, pReq, contLen);
|
||||||
rpcMsg.pCont = pReq;
|
|
||||||
rpcMsg.contLen = sizeof(SCreateDbMsg);
|
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_DB;
|
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, "");
|
||||||
SendThenCheckShowRetrieveMsg(1);
|
CHECK_META("show databases", 17);
|
||||||
|
|
||||||
|
test.SendShowRetrieveMsg();
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
CheckBinary("d2", TSDB_DB_NAME_LEN - 1);
|
CheckBinary("d2", TSDB_DB_NAME_LEN - 1);
|
||||||
|
|
||||||
{
|
{
|
||||||
SUseDbMsg* pReq = (SUseDbMsg*)rpcMallocCont(sizeof(SUseDbMsg));
|
int32_t contLen = sizeof(SUseDbMsg);
|
||||||
|
|
||||||
|
SUseDbMsg* pReq = (SUseDbMsg*)rpcMallocCont(contLen);
|
||||||
strcpy(pReq->db, "1.d2");
|
strcpy(pReq->db, "1.d2");
|
||||||
pReq->vgVersion = htonl(-1);
|
pReq->vgVersion = htonl(-1);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg* pMsg = test.SendMsg(TSDB_MSG_TYPE_USE_DB, pReq, contLen);
|
||||||
rpcMsg.pCont = pReq;
|
|
||||||
rpcMsg.contLen = sizeof(SUseDbMsg);
|
|
||||||
rpcMsg.msgType = TSDB_MSG_TYPE_USE_DB;
|
|
||||||
|
|
||||||
sendMsg(pClient, &rpcMsg);
|
|
||||||
SRpcMsg* pMsg = pClient->pRsp;
|
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, 0);
|
ASSERT_EQ(pMsg->code, 0);
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,40 @@ TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||||
ASSERT_NE(pMsg, nullptr);
|
ASSERT_NE(pMsg, nullptr);
|
||||||
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
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(TSDB_MSG_TYPE_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);
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Testbase {
|
||||||
public:
|
public:
|
||||||
void Init(const char* path, int16_t port);
|
void Init(const char* path, int16_t port);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
void Restart();
|
||||||
SRpcMsg* SendMsg(int8_t msgType, void* pCont, int32_t contLen);
|
SRpcMsg* SendMsg(int8_t msgType, void* pCont, int32_t contLen);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -47,22 +48,27 @@ class Testbase {
|
||||||
int32_t connId;
|
int32_t connId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SendShowMetaMsg(int8_t showType);
|
void SendShowMetaMsg(int8_t showType, const char* db);
|
||||||
void SendShowRetrieveMsg();
|
void SendShowRetrieveMsg();
|
||||||
|
|
||||||
|
STableMetaMsg* GetShowMeta();
|
||||||
|
SRetrieveTableRsp* GetRetrieveRsp();
|
||||||
|
|
||||||
|
int32_t GetMetaNum();
|
||||||
|
const char* GetMetaTbName();
|
||||||
|
int32_t GetMetaColId(int32_t index);
|
||||||
|
int8_t GetMetaType(int32_t index);
|
||||||
|
int32_t GetMetaBytes(int32_t index);
|
||||||
|
const char* GetMetaName(int32_t index);
|
||||||
|
|
||||||
const char* GetShowName();
|
const char* GetShowName();
|
||||||
|
int32_t GetShowRows();
|
||||||
int8_t GetShowInt8();
|
int8_t GetShowInt8();
|
||||||
int16_t GetShowInt16();
|
int16_t GetShowInt16();
|
||||||
int32_t GetShowInt32();
|
int32_t GetShowInt32();
|
||||||
int64_t GetShowInt64();
|
int64_t GetShowInt64();
|
||||||
int64_t GetShowTimestamp();
|
int64_t GetShowTimestamp();
|
||||||
const char* GetShowBinary(int32_t len);
|
const char* GetShowBinary(int32_t len);
|
||||||
int32_t GetMetaColId(int32_t index);
|
|
||||||
int8_t GetMetaType(int32_t index);
|
|
||||||
int32_t GetMetaBytes(int32_t index);
|
|
||||||
const char* GetMetaName(int32_t index);
|
|
||||||
int32_t GetMetaNum();
|
|
||||||
const char* GetMetaTbName();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t showId;
|
int32_t showId;
|
||||||
|
@ -72,4 +78,53 @@ class Testbase {
|
||||||
int32_t pos;
|
int32_t pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CHECK_META(tbName, numOfColumns) \
|
||||||
|
{ \
|
||||||
|
EXPECT_EQ(test.GetMetaNum(), numOfColumns); \
|
||||||
|
EXPECT_STREQ(test.GetMetaTbName(), tbName); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CHECK_SCHEMA(colId, type, bytes, colName) \
|
||||||
|
{ \
|
||||||
|
EXPECT_EQ(test.GetMetaType(colId), type); \
|
||||||
|
EXPECT_EQ(test.GetMetaBytes(colId), bytes); \
|
||||||
|
EXPECT_STREQ(test.GetMetaName(colId), colName); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CheckBinary(val, len) \
|
||||||
|
{ EXPECT_STREQ(test.GetShowBinary(len), val); }
|
||||||
|
|
||||||
|
#define CheckInt8(val) \
|
||||||
|
{ EXPECT_EQ(test.GetShowInt8(), val); }
|
||||||
|
|
||||||
|
#define CheckInt16(val) \
|
||||||
|
{ EXPECT_EQ(test.GetShowInt16(), val); }
|
||||||
|
|
||||||
|
#define CheckInt32(val) \
|
||||||
|
{ EXPECT_EQ(test.GetShowInt32(), val); }
|
||||||
|
|
||||||
|
#define CheckInt64(val) \
|
||||||
|
{ EXPECT_EQ(test.GetShowInt64(), val); }
|
||||||
|
|
||||||
|
#define CheckTimestamp() \
|
||||||
|
{ EXPECT_GT(test.GetShowTimestamp(), 0); }
|
||||||
|
|
||||||
|
#define IgnoreBinary(len) \
|
||||||
|
{ test.GetShowBinary(len); }
|
||||||
|
|
||||||
|
#define IgnoreInt8() \
|
||||||
|
{ test.GetShowInt8(); }
|
||||||
|
|
||||||
|
#define IgnoreInt16() \
|
||||||
|
{ test.GetShowInt16(); }
|
||||||
|
|
||||||
|
#define IgnoreInt32() \
|
||||||
|
{ test.GetShowInt32(); }
|
||||||
|
|
||||||
|
#define IgnoreInt64() \
|
||||||
|
{ test.GetShowInt64(); }
|
||||||
|
|
||||||
|
#define IgnoreTimestamp() \
|
||||||
|
{ test.GetShowTimestamp(); }
|
||||||
|
|
||||||
#endif /* _TD_TEST_BASE_H_ */
|
#endif /* _TD_TEST_BASE_H_ */
|
|
@ -20,13 +20,19 @@ class TestServer {
|
||||||
public:
|
public:
|
||||||
bool Start(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
bool Start(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
||||||
void Stop();
|
void Stop();
|
||||||
|
void Restart();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDnodeOpt BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
SDnodeOpt BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
|
||||||
|
bool DoStart();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDnode* pDnode;
|
SDnode* pDnode;
|
||||||
pthread_t* threadId;
|
pthread_t* threadId;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char fqdn[TSDB_FQDN_LEN];
|
||||||
|
char firstEp[TSDB_EP_LEN];
|
||||||
|
uint16_t port;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _TD_TEST_SERVER_H_ */
|
#endif /* _TD_TEST_SERVER_H_ */
|
|
@ -58,20 +58,22 @@ void Testbase::Cleanup() {
|
||||||
client.Cleanup();
|
client.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Testbase::Restart() { server.Restart(); }
|
||||||
|
|
||||||
SRpcMsg* Testbase::SendMsg(int8_t msgType, void* pCont, int32_t contLen) {
|
SRpcMsg* Testbase::SendMsg(int8_t msgType, void* pCont, int32_t contLen) {
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg rpcMsg = {0};
|
||||||
rpcMsg.pCont = pCont;
|
rpcMsg.pCont = pCont;
|
||||||
rpcMsg.contLen = sizeof(SShowMsg);
|
rpcMsg.contLen = contLen;
|
||||||
rpcMsg.msgType = msgType;
|
rpcMsg.msgType = msgType;
|
||||||
|
|
||||||
return client.SendMsg(&rpcMsg);
|
return client.SendMsg(&rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Testbase::SendShowMetaMsg(int8_t showType) {
|
void Testbase::SendShowMetaMsg(int8_t showType, const char* db) {
|
||||||
int32_t contLen = sizeof(SShowMsg);
|
int32_t contLen = sizeof(SShowMsg);
|
||||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(contLen);
|
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(contLen);
|
||||||
pShow->type = showType;
|
pShow->type = showType;
|
||||||
strcpy(pShow->db, "");
|
strcpy(pShow->db, db);
|
||||||
|
|
||||||
SRpcMsg* pMsg = SendMsg(TSDB_MSG_TYPE_SHOW, pShow, contLen);
|
SRpcMsg* pMsg = SendMsg(TSDB_MSG_TYPE_SHOW, pShow, contLen);
|
||||||
SShowRsp* pShowRsp = (SShowRsp*)pMsg->pCont;
|
SShowRsp* pShowRsp = (SShowRsp*)pMsg->pCont;
|
||||||
|
@ -124,6 +126,9 @@ void Testbase::SendShowRetrieveMsg() {
|
||||||
|
|
||||||
SRpcMsg* pMsg = SendMsg(TSDB_MSG_TYPE_SHOW_RETRIEVE, pRetrieve, contLen);
|
SRpcMsg* pMsg = SendMsg(TSDB_MSG_TYPE_SHOW_RETRIEVE, pRetrieve, contLen);
|
||||||
pRetrieveRsp = (SRetrieveTableRsp*)pMsg->pCont;
|
pRetrieveRsp = (SRetrieveTableRsp*)pMsg->pCont;
|
||||||
|
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||||
|
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||||
|
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||||
|
|
||||||
pData = pRetrieveRsp->data;
|
pData = pRetrieveRsp->data;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -166,4 +171,10 @@ const char* Testbase::GetShowBinary(int32_t len) {
|
||||||
char* data = (char*)(pData + pos);
|
char* data = (char*)(pData + pos);
|
||||||
pos += len;
|
pos += len;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t Testbase::GetShowRows() { return pRetrieveRsp->numOfRows; }
|
||||||
|
|
||||||
|
STableMetaMsg* Testbase::GetShowMeta() { return pMeta; }
|
||||||
|
|
||||||
|
SRetrieveTableRsp* Testbase::GetRetrieveRsp() { return pRetrieveRsp; }
|
|
@ -42,9 +42,8 @@ SDnodeOpt TestServer::BuildOption(const char* path, const char* fqdn, uint16_t p
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
bool TestServer::DoStart() {
|
||||||
SDnodeOpt option = BuildOption(path, fqdn, port, firstEp);
|
SDnodeOpt option = BuildOption(path, fqdn, port, firstEp);
|
||||||
taosRemoveDir(path);
|
|
||||||
taosMkDir(path);
|
taosMkDir(path);
|
||||||
|
|
||||||
pDnode = dndInit(&option);
|
pDnode = dndInit(&option);
|
||||||
|
@ -59,6 +58,23 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestServer::Restart() {
|
||||||
|
uInfo("start all server");
|
||||||
|
Stop();
|
||||||
|
DoStart();
|
||||||
|
uInfo("all server is running");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||||
|
strcpy(this->path, path);
|
||||||
|
strcpy(this->fqdn, fqdn);
|
||||||
|
this->port = port;
|
||||||
|
strcpy(this->firstEp, firstEp);
|
||||||
|
|
||||||
|
taosRemoveDir(path);
|
||||||
|
return DoStart();
|
||||||
|
}
|
||||||
|
|
||||||
void TestServer::Stop() {
|
void TestServer::Stop() {
|
||||||
if (threadId != NULL) {
|
if (threadId != NULL) {
|
||||||
taosDestoryThread(threadId);
|
taosDestoryThread(threadId);
|
||||||
|
|
|
@ -138,7 +138,7 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
|
||||||
ShowMetaFp metaFp = pMgmt->metaFps[type];
|
ShowMetaFp metaFp = pMgmt->metaFps[type];
|
||||||
if (metaFp == NULL) {
|
if (metaFp == NULL) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
||||||
mError("failed to process show-meta msg:%s since no message handle", mndShowStr(type));
|
mError("failed to process show-meta msg:%s since %s", mndShowStr(type), terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue