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

TD-10431 rename test file

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