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

TD-10431 rename test file

上级 1f600bb6
add_subdirectory(test01)
\ No newline at end of file
add_subdirectory(profile)
\ No newline at end of file
add_executable(dndTest01 "")
add_executable(dndTestProfile "")
target_sources(dndTest01
target_sources(dndTestProfile
PRIVATE
"test01.cpp"
"profile.cpp"
"../sut/deploy.cpp"
)
target_link_libraries(
dndTest01
dndTestProfile
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories(dndTest01
target_include_directories(dndTestProfile
PUBLIC
"${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt"
"${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
......@@ -24,6 +24,6 @@ target_include_directories(dndTest01
enable_testing()
add_test(
NAME dndTest01
COMMAND dndTest01
NAME dndTestProfile
COMMAND dndTestProfile
)
......@@ -15,22 +15,32 @@
#include "deploy.h"
class DndTest01 : public ::testing::Test {
class DndTestProfile : public ::testing::Test {
protected:
void SetUp() override {
pServer = createServer("/tmp/dndTest01");
void SetUp() override {}
void TearDown() override {}
static void SetUpTestSuite() {
pServer = createServer("/tmp/dndTestProfile", "localhost", 9527);
pClient = createClient("root", "taosdata");
}
void TearDown() override {
static void TearDownTestSuite() {
dropServer(pServer);
dropClient(pClient);
}
SServer* pServer;
SClient* pClient;
static SServer* pServer;
static SClient* pClient;
};
TEST_F(DndTest01, connectMsg) {
SServer* DndTestProfile::pServer;
SClient* DndTestProfile::pClient;
TEST_F(DndTestProfile, connectMsg_01) {
ASSERT_NE(pServer, nullptr);
ASSERT_NE(pClient, nullptr);
SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(sizeof(SConnectMsg));
pReq->pid = htonl(1234);
strcpy(pReq->app, "test01");
......@@ -63,33 +73,42 @@ TEST_F(DndTest01, connectMsg) {
EXPECT_STREQ(pRsp->epSet.fqdn[0], "localhost");
}
// TEST_F(DndTest01, heartbeatMsg) {
// SHeartBeatMsg* pReq = (SHeartBeatMsg*)rpcMallocCont(sizeof(SHeartBeatMsg));
// pReq->connId = htonl(1);
// pReq->pid = htonl(1234);
// pReq->numOfQueries = htonl(0);
// pReq->numOfStreams = htonl(0);
// strcpy(pReq->app, "test01");
// SRpcMsg rpcMsg = {0};
// rpcMsg.pCont = pReq;
// rpcMsg.contLen = sizeof(SHeartBeatMsg);
// rpcMsg.msgType = TSDB_MSG_TYPE_HEARTBEAT;
// sendMsg(pClient, &rpcMsg);
// SHeartBeatRsp* pRsp = (SHeartBeatRsp*)pClient->pRsp;
// ASSERT(pRsp);
// pRsp->epSet.port[0] = htonl(pRsp->epSet.port[0]);
// EXPECT_EQ(htonl(pRsp->connId), 1);
// EXPECT_GT(htonl(pRsp->queryId), 0);
// EXPECT_GT(htonl(pRsp->streamId), 1);
// EXPECT_EQ(htonl(pRsp->totalDnodes), 1);
// EXPECT_EQ(htonl(pRsp->onlineDnodes), 1);
// EXPECT_EQ(pRsp->killConnection, 0);
// EXPECT_EQ(pRsp->epSet.inUse, 0);
// EXPECT_EQ(pRsp->epSet.numOfEps, 1);
// EXPECT_EQ(pRsp->epSet.port[0], 9527);
// EXPECT_STREQ(pRsp->epSet.fqdn[0], "localhost");
// }
TEST_F(DndTestProfile, heartbeatMsg_01) {
ASSERT_NE(pServer, nullptr);
ASSERT_NE(pClient, nullptr);
SHeartBeatMsg* pReq = (SHeartBeatMsg*)rpcMallocCont(sizeof(SHeartBeatMsg));
pReq->connId = htonl(1);
pReq->pid = htonl(1234);
pReq->numOfQueries = htonl(0);
pReq->numOfStreams = htonl(0);
strcpy(pReq->app, "test01");
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pReq;
rpcMsg.contLen = sizeof(SHeartBeatMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_HEARTBEAT;
sendMsg(pClient, &rpcMsg);
SHeartBeatRsp* pRsp = (SHeartBeatRsp*)pClient->pRsp->pCont;
ASSERT_NE(pRsp, nullptr);
pRsp->connId = htonl(pRsp->connId);
pRsp->queryId = htonl(pRsp->queryId);
pRsp->streamId = htonl(pRsp->streamId);
pRsp->totalDnodes = htonl(pRsp->totalDnodes);
pRsp->onlineDnodes = htonl(pRsp->onlineDnodes);
pRsp->epSet.port[0] = htons(pRsp->epSet.port[0]);
EXPECT_EQ(pRsp->connId, 1);
EXPECT_EQ(pRsp->queryId, 0);
EXPECT_EQ(pRsp->streamId, 0);
EXPECT_EQ(pRsp->totalDnodes, 1);
EXPECT_EQ(pRsp->onlineDnodes, 1);
EXPECT_EQ(pRsp->killConnection, 0);
EXPECT_EQ(pRsp->epSet.inUse, 0);
EXPECT_EQ(pRsp->epSet.numOfEps, 1);
EXPECT_EQ(pRsp->epSet.port[0], 9527);
EXPECT_STREQ(pRsp->epSet.fqdn[0], "localhost");
}
......@@ -15,7 +15,7 @@
#include "deploy.h"
void initLog(char *path) {
void initLog(char* path) {
mDebugFlag = 207;
char temp[PATH_MAX];
snprintf(temp, PATH_MAX, "%s/taosdlog", path);
......@@ -32,7 +32,7 @@ void* runServer(void* param) {
}
}
void initOption(SDnodeOpt* pOption, char *path) {
void initOption(SDnodeOpt* pOption, char* path, char* fqdn, uint16_t port) {
pOption->sver = 1;
pOption->numOfCores = 1;
pOption->numOfSupportMnodes = 1;
......@@ -44,19 +44,19 @@ void initOption(SDnodeOpt* pOption, char *path) {
pOption->ratioOfQueryCores = 1;
pOption->maxShellConns = 1000;
pOption->shellActivityTimer = 30;
pOption->serverPort = 9527;
pOption->serverPort = port;
strcpy(pOption->dataDir, path);
strcpy(pOption->localEp, "localhost:9527");
strcpy(pOption->localFqdn, "localhost");
strcpy(pOption->firstEp, "localhost:9527");
snprintf(pOption->localEp, TSDB_EP_LEN, "%s:&u", fqdn, port);
snprintf(pOption->localFqdn, TSDB_FQDN_LEN, "%s", fqdn);
snprintf(pOption->firstEp, TSDB_EP_LEN, "%s:&u", fqdn, port);
taosRemoveDir(path);
taosMkDir(path);
}
SServer* createServer(char *path) {
SServer* createServer(char* path, char* fqdn, uint16_t port) {
SDnodeOpt option = {0};
initOption(&option, path);
initOption(&option, path, fqdn, port);
SDnode* pDnode = dndInit(&option);
ASSERT(pDnode);
......
......@@ -36,7 +36,7 @@ typedef struct {
tsem_t sem;
} SClient;
SServer* createServer(char* path);
SServer* createServer(char* path, char *fqdn, uint16_t port);
void dropServer(SServer* pServer);
SClient* createClient(char *user, char *pass);
void dropClient(SClient* pClient);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册