提交 9a9a1927 编写于 作者: S Shengliang Guan

refactor: make more object global

上级 b16a21b2
...@@ -141,6 +141,8 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg); ...@@ -141,6 +141,8 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
// dmNodes.c // dmNodes.c
int32_t dmOpenNode(SMgmtWrapper *pWrapper); int32_t dmOpenNode(SMgmtWrapper *pWrapper);
int32_t dmStartNode(SMgmtWrapper *pWrapper);
void dmStopNode(SMgmtWrapper *pWrapper);
void dmCloseNode(SMgmtWrapper *pWrapper); void dmCloseNode(SMgmtWrapper *pWrapper);
int32_t dmRunDnode(SDnode *pDnode); int32_t dmRunDnode(SDnode *pDnode);
......
...@@ -124,6 +124,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { ...@@ -124,6 +124,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
} else { } else {
dInfo("node:%s, has been created", pWrapper->name); dInfo("node:%s, has been created", pWrapper->name);
(void)dmOpenNode(pWrapper); (void)dmOpenNode(pWrapper);
(void)dmStartNode(pWrapper);
pWrapper->required = true; pWrapper->required = true;
pWrapper->deployed = true; pWrapper->deployed = true;
pWrapper->proc.ptype = pDnode->ptype; pWrapper->proc.ptype = pDnode->ptype;
...@@ -159,6 +160,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { ...@@ -159,6 +160,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
dmReleaseWrapper(pWrapper); dmReleaseWrapper(pWrapper);
if (code == 0) { if (code == 0) {
dmStopNode(pWrapper);
dmCloseNode(pWrapper); dmCloseNode(pWrapper);
taosRemoveDir(pWrapper->path); taosRemoveDir(pWrapper->path);
} }
......
...@@ -3,7 +3,7 @@ if(${BUILD_TEST}) ...@@ -3,7 +3,7 @@ if(${BUILD_TEST})
add_subdirectory(qnode) add_subdirectory(qnode)
add_subdirectory(bnode) add_subdirectory(bnode)
add_subdirectory(snode) add_subdirectory(snode)
#add_subdirectory(mnode) add_subdirectory(mnode)
add_subdirectory(vnode) add_subdirectory(vnode)
add_subdirectory(sut) add_subdirectory(sut)
endif(${BUILD_TEST}) endif(${BUILD_TEST})
...@@ -14,11 +14,10 @@ ...@@ -14,11 +14,10 @@
class DndTestBnode : public ::testing::Test { class DndTestBnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { static void SetUpTestSuite() {
test.Init("/tmp/dnode_test_bnode", 9112); test.Init("/tmp/dbnodeTest", 9112);
taosMsleep(1100); taosMsleep(1100);
} }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
public: public:
...@@ -68,7 +67,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { ...@@ -68,7 +67,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED);
} }
test.Restart(); // test.Restart();
{ {
SDCreateBnodeReq createReq = {0}; SDCreateBnodeReq createReq = {0};
...@@ -84,7 +83,6 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { ...@@ -84,7 +83,6 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
} }
TEST_F(DndTestBnode, 02_Drop_Bnode) { TEST_F(DndTestBnode, 02_Drop_Bnode) {
#if 0
{ {
SDDropBnodeReq dropReq = {0}; SDDropBnodeReq dropReq = {0};
dropReq.dnodeId = 2; dropReq.dnodeId = 2;
...@@ -97,7 +95,7 @@ TEST_F(DndTestBnode, 02_Drop_Bnode) { ...@@ -97,7 +95,7 @@ TEST_F(DndTestBnode, 02_Drop_Bnode) {
ASSERT_NE(pRsp, nullptr); ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION); ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION);
} }
#endif
{ {
SDDropBnodeReq dropReq = {0}; SDDropBnodeReq dropReq = {0};
dropReq.dnodeId = 1; dropReq.dnodeId = 1;
...@@ -124,7 +122,7 @@ TEST_F(DndTestBnode, 02_Drop_Bnode) { ...@@ -124,7 +122,7 @@ TEST_F(DndTestBnode, 02_Drop_Bnode) {
ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
} }
test.Restart(); // test.Restart();
{ {
SDDropBnodeReq dropReq = {0}; SDDropBnodeReq dropReq = {0};
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestMnode : public ::testing::Test { class DndTestMnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_mnode", 9114); } static void SetUpTestSuite() { test.Init("/tmp/dmnodeTest", 9114); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestQnode : public ::testing::Test { class DndTestQnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_qnode", 9111); } static void SetUpTestSuite() { test.Init("/tmp/dqnodeTest", 9111); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestSnode : public ::testing::Test { class DndTestSnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_snode", 9113); } static void SetUpTestSuite() { test.Init("/tmp/dsnodeTest", 9113); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
class TestClient { class TestClient {
public: public:
bool Init(const char* user, const char* pass, const char* fqdn, uint16_t port); bool Init(const char* user, const char* pass);
void Cleanup(); void Cleanup();
void DoInit(); void DoInit();
SRpcMsg* SendReq(SRpcMsg* pReq); SRpcMsg* SendReq(SRpcMsg* pReq);
...@@ -29,8 +28,6 @@ class TestClient { ...@@ -29,8 +28,6 @@ class TestClient {
void Restart(); void Restart();
private: private:
char fqdn[TSDB_FQDN_LEN];
uint16_t port;
char user[128]; char user[128];
char pass[128]; char pass[128];
void* clientRpc; void* clientRpc;
......
...@@ -18,20 +18,11 @@ ...@@ -18,20 +18,11 @@
class TestServer { class TestServer {
public: public:
bool Start(const char* path, const char* fqdn, uint16_t port, const char* firstEp); bool Start();
void Stop(); void Stop();
void Restart();
bool DoStart();
private:
void BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
private: private:
TdThread threadId; TdThread 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_ */
\ No newline at end of file
...@@ -58,11 +58,9 @@ void TestClient::DoInit() { ...@@ -58,11 +58,9 @@ void TestClient::DoInit() {
tsem_init(&this->sem, 0, 0); tsem_init(&this->sem, 0, 0);
} }
bool TestClient::Init(const char* user, const char* pass, const char* fqdn, uint16_t port) { bool TestClient::Init(const char* user, const char* pass) {
strcpy(this->fqdn, fqdn);
strcpy(this->user, user); strcpy(this->user, user);
strcpy(this->pass, pass); strcpy(this->pass, pass);
this->port = port;
this->pRsp = NULL; this->pRsp = NULL;
this->DoInit(); this->DoInit();
return true; return true;
...@@ -77,9 +75,10 @@ void TestClient::Restart() { ...@@ -77,9 +75,10 @@ void TestClient::Restart() {
this->Cleanup(); this->Cleanup();
this->DoInit(); this->DoInit();
} }
SRpcMsg* TestClient::SendReq(SRpcMsg* pReq) { SRpcMsg* TestClient::SendReq(SRpcMsg* pReq) {
SEpSet epSet = {0}; SEpSet epSet = {0};
addEpIntoEpSet(&epSet, fqdn, port); addEpIntoEpSet(&epSet, tsLocalFqdn, tsServerPort);
rpcSendRequest(clientRpc, &epSet, pReq, NULL); rpcSendRequest(clientRpc, &epSet, pReq, NULL);
tsem_wait(&sem); tsem_wait(&sem);
uInfo("y response:%s from dnode, code:0x%x, msgSize: %d", TMSG_INFO(pRsp->msgType), pRsp->code, pRsp->contLen); uInfo("y response:%s from dnode, code:0x%x, msgSize: %d", TMSG_INFO(pRsp->msgType), pRsp->code, pRsp->contLen);
......
...@@ -16,25 +16,13 @@ ...@@ -16,25 +16,13 @@
#include "sut.h" #include "sut.h"
void* serverLoop(void* param) { void* serverLoop(void* param) {
dmInit(0);
dmRun(); dmRun();
dmCleanup();
return NULL; return NULL;
} }
void TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) { bool TestServer::Start() {
tsNumOfSupportVnodes = 16;
tsServerPort = port;
strcpy(tsDataDir, path);
snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", fqdn, port);
snprintf(tsLocalFqdn, TSDB_FQDN_LEN, "%s", fqdn);
snprintf(tsFirst, TSDB_EP_LEN, "%s", firstEp);
taosMkDir(path);
}
bool TestServer::DoStart() {
if (dmInit(0) != 0) {
return false;
}
TdThreadAttr thAttr; TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr); taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
...@@ -44,25 +32,7 @@ bool TestServer::DoStart() { ...@@ -44,25 +32,7 @@ bool TestServer::DoStart() {
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() {
dmStop(); dmStop();
taosThreadJoin(threadId, NULL); taosThreadJoin(threadId, NULL);
dmCleanup();
} }
...@@ -40,15 +40,17 @@ void Testbase::InitLog(const char* path) { ...@@ -40,15 +40,17 @@ void Testbase::InitLog(const char* path) {
} }
void Testbase::Init(const char* path, int16_t port) { void Testbase::Init(const char* path, int16_t port) {
dmInit(0); tsServerPort = port;
strcpy(tsLocalFqdn, "localhost");
char fqdn[] = "localhost"; snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
char firstEp[TSDB_EP_LEN] = {0}; strcpy(tsFirst, tsLocalEp);
snprintf(firstEp, TSDB_EP_LEN, "%s:%u", fqdn, port); strcpy(tsDataDir, path);
taosRemoveDir(path);
taosMkDir(path);
InitLog("/tmp/td"); InitLog("/tmp/td");
server.Start(path, fqdn, port, firstEp);
client.Init("root", "taosdata", fqdn, port); server.Start();
client.Init("root", "taosdata");
showRsp = NULL; showRsp = NULL;
} }
...@@ -64,13 +66,12 @@ void Testbase::Cleanup() { ...@@ -64,13 +66,12 @@ void Testbase::Cleanup() {
} }
void Testbase::Restart() { void Testbase::Restart() {
server.Restart(); // server.Restart();
client.Restart(); client.Restart();
} }
void Testbase::ServerStop() { server.Stop(); } void Testbase::ServerStop() { server.Stop(); }
void Testbase::ServerStart() { server.Start(); }
void Testbase::ServerStart() { server.DoStart(); }
void Testbase::ClientRestart() { client.Restart(); } void Testbase::ClientRestart() { client.Restart(); }
SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) { SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class DndTestVnode : public ::testing::Test { class DndTestVnode : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_vnode", 9115); } static void SetUpTestSuite() { test.Init("/tmp/dvnodeTest", 9115); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
...@@ -122,6 +122,7 @@ static void mndCleanupTimer(SMnode *pMnode) { ...@@ -122,6 +122,7 @@ static void mndCleanupTimer(SMnode *pMnode) {
pMnode->stopped = true; pMnode->stopped = true;
if (taosCheckPthreadValid(pMnode->thread)) { if (taosCheckPthreadValid(pMnode->thread)) {
taosThreadJoin(pMnode->thread, NULL); taosThreadJoin(pMnode->thread, NULL);
memset(&pMnode->thread, 0, sizeof(pMnode->thread));
} }
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class MndTestAcct : public ::testing::Test { class MndTestAcct : public ::testing::Test {
protected: protected:
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_acct", 9012); } static void SetUpTestSuite() { test.Init("/tmp/acctTest", 9012); }
static void TearDownTestSuite() { test.Cleanup(); } static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
......
aux_source_directory(. MNODE_BNODE_TEST_SRC) # aux_source_directory(. MNODE_BNODE_TEST_SRC)
add_executable(mbnodeTest ${MNODE_BNODE_TEST_SRC}) # add_executable(mbnodeTest ${MNODE_BNODE_TEST_SRC})
target_link_libraries( # target_link_libraries(
mbnodeTest # mbnodeTest
PUBLIC sut # PUBLIC sut
) # )
add_test( # add_test(
NAME mbnodeTest # NAME mbnodeTest
COMMAND mbnodeTest # COMMAND mbnodeTest
) # )
...@@ -22,7 +22,7 @@ class MndTestBnode : public ::testing::Test { ...@@ -22,7 +22,7 @@ class MndTestBnode : public ::testing::Test {
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9018"; const char* firstEp = "localhost:9018";
server2.Start("/tmp/mnode_test_bnode2", fqdn, 9019, firstEp); server2.Start("/tmp/mnode_test_bnode2", 9019);
taosMsleep(300); taosMsleep(300);
} }
......
aux_source_directory(. MNODE_DNODE_TEST_SRC) # aux_source_directory(. MNODE_DNODE_TEST_SRC)
add_executable(mdnodeTest ${MNODE_DNODE_TEST_SRC}) # add_executable(mdnodeTest ${MNODE_DNODE_TEST_SRC})
target_link_libraries( # target_link_libraries(
mdnodeTest # mdnodeTest
PUBLIC sut # PUBLIC sut
) # )
add_test( # add_test(
NAME mdnodeTest # NAME mdnodeTest
COMMAND mdnodeTest # COMMAND mdnodeTest
) # )
...@@ -22,10 +22,10 @@ class MndTestDnode : public ::testing::Test { ...@@ -22,10 +22,10 @@ class MndTestDnode : public ::testing::Test {
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9023"; const char* firstEp = "localhost:9023";
server2.Start("/tmp/dnode_test_dnode2", fqdn, 9024, firstEp); // server2.Start("/tmp/dnode_test_dnode2", fqdn, 9024, firstEp);
server3.Start("/tmp/dnode_test_dnode3", fqdn, 9025, firstEp); // server3.Start("/tmp/dnode_test_dnode3", fqdn, 9025, firstEp);
server4.Start("/tmp/dnode_test_dnode4", fqdn, 9026, firstEp); // server4.Start("/tmp/dnode_test_dnode4", fqdn, 9026, firstEp);
server5.Start("/tmp/dnode_test_dnode5", fqdn, 9027, firstEp); // server5.Start("/tmp/dnode_test_dnode5", fqdn, 9027, firstEp);
taosMsleep(300); taosMsleep(300);
} }
...@@ -205,7 +205,7 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) { ...@@ -205,7 +205,7 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
taosMsleep(2000); taosMsleep(2000);
server2.Stop(); server2.Stop();
server2.DoStart(); server2.Start();
} }
TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) { TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
......
aux_source_directory(. MNODE_MNODE_TEST_SRC) # aux_source_directory(. MNODE_MNODE_TEST_SRC)
add_executable(mmnodeTest ${MNODE_MNODE_TEST_SRC}) # add_executable(mmnodeTest ${MNODE_MNODE_TEST_SRC})
target_link_libraries( # target_link_libraries(
mmnodeTest # mmnodeTest
PUBLIC sut # PUBLIC sut
) # )
add_test( # add_test(
NAME mmnodeTest # NAME mmnodeTest
COMMAND mmnodeTest # COMMAND mmnodeTest
) # )
...@@ -22,7 +22,7 @@ class MndTestMnode : public ::testing::Test { ...@@ -22,7 +22,7 @@ class MndTestMnode : public ::testing::Test {
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9028"; const char* firstEp = "localhost:9028";
server2.Start("/tmp/mnode_test_mnode2", fqdn, 9029, firstEp); // server2.Start("/tmp/mnode_test_mnode2", fqdn, 9029, firstEp);
taosMsleep(300); taosMsleep(300);
} }
...@@ -188,7 +188,7 @@ TEST_F(MndTestMnode, 03_Create_Mnode_Rollback) { ...@@ -188,7 +188,7 @@ TEST_F(MndTestMnode, 03_Create_Mnode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); // server2.Start();
taosMsleep(1000); taosMsleep(1000);
int32_t retry = 0; int32_t retry = 0;
...@@ -258,7 +258,7 @@ TEST_F(MndTestMnode, 04_Drop_Mnode_Rollback) { ...@@ -258,7 +258,7 @@ TEST_F(MndTestMnode, 04_Drop_Mnode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); // server2.Start();
taosMsleep(1000); taosMsleep(1000);
int32_t retry = 0; int32_t retry = 0;
......
aux_source_directory(. MNODE_QNODE_TEST_SRC) # aux_source_directory(. MNODE_QNODE_TEST_SRC)
add_executable(mqnodeTest ${MNODE_QNODE_TEST_SRC}) # add_executable(mqnodeTest ${MNODE_QNODE_TEST_SRC})
target_link_libraries( # target_link_libraries(
mqnodeTest # mqnodeTest
PUBLIC sut # PUBLIC sut
) # )
add_test( # add_test(
NAME mqnodeTest # NAME mqnodeTest
COMMAND mqnodeTest # COMMAND mqnodeTest
) # )
...@@ -22,7 +22,7 @@ class MndTestQnode : public ::testing::Test { ...@@ -22,7 +22,7 @@ class MndTestQnode : public ::testing::Test {
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9014"; const char* firstEp = "localhost:9014";
server2.Start("/tmp/mnode_test_qnode2", fqdn, 9015, firstEp); // server2.Start("/tmp/mnode_test_qnode2", fqdn, 9015, firstEp);
taosMsleep(300); taosMsleep(300);
} }
...@@ -201,7 +201,7 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { ...@@ -201,7 +201,7 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); server2.Start();
test.ClientRestart(); test.ClientRestart();
taosMsleep(1000); taosMsleep(1000);
...@@ -270,7 +270,7 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { ...@@ -270,7 +270,7 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); server2.Start();
taosMsleep(1000); taosMsleep(1000);
int32_t retry = 0; int32_t retry = 0;
......
aux_source_directory(. MNODE_SNODE_TEST_SRC) # aux_source_directory(. MNODE_SNODE_TEST_SRC)
add_executable(msnodeTest ${MNODE_SNODE_TEST_SRC}) # add_executable(msnodeTest ${MNODE_SNODE_TEST_SRC})
target_link_libraries( # target_link_libraries(
msnodeTest # msnodeTest
PUBLIC sut # PUBLIC sut
) # )
add_test( # add_test(
NAME msnodeTest # NAME msnodeTest
COMMAND msnodeTest # COMMAND msnodeTest
) # )
...@@ -22,7 +22,7 @@ class MndTestSnode : public ::testing::Test { ...@@ -22,7 +22,7 @@ class MndTestSnode : public ::testing::Test {
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9016"; const char* firstEp = "localhost:9016";
server2.Start("/tmp/mnode_test_snode2", fqdn, 9017, firstEp); // server2.Start("/tmp/mnode_test_snode2", fqdn, 9017, firstEp);
taosMsleep(300); taosMsleep(300);
} }
...@@ -198,7 +198,7 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { ...@@ -198,7 +198,7 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); server2.Start();
taosMsleep(1000); taosMsleep(1000);
int32_t retry = 0; int32_t retry = 0;
...@@ -268,7 +268,7 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { ...@@ -268,7 +268,7 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
{ {
// server start, wait until the rollback finished // server start, wait until the rollback finished
server2.DoStart(); server2.Start();
taosMsleep(1000); taosMsleep(1000);
int32_t retry = 0; int32_t retry = 0;
......
add_executable(transTest1 "") # add_executable(transTest1 "")
target_sources(transTest1 # target_sources(transTest1
PRIVATE # PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/trans1.cpp" # "${CMAKE_CURRENT_SOURCE_DIR}/trans1.cpp"
) # )
target_link_libraries( # target_link_libraries(
transTest1 # transTest1
PUBLIC sut # PUBLIC sut
) # )
target_include_directories( # target_include_directories(
transTest1 # transTest1
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode" # PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../inc" # PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
) # )
add_test( # add_test(
NAME transTest1 # NAME transTest1
COMMAND transTest1 # COMMAND transTest1
) # )
add_executable(transTest2 "") add_executable(transTest2 "")
target_sources(transTest2 target_sources(transTest2
......
...@@ -17,7 +17,7 @@ class MndTestTrans1 : public ::testing::Test { ...@@ -17,7 +17,7 @@ class MndTestTrans1 : public ::testing::Test {
test.Init("/tmp/mnode_test_trans1", 9013); test.Init("/tmp/mnode_test_trans1", 9013);
const char* fqdn = "localhost"; const char* fqdn = "localhost";
const char* firstEp = "localhost:9013"; const char* firstEp = "localhost:9013";
server2.Start("/tmp/mnode_test_trans2", fqdn, 9020, firstEp); // server2.Start("/tmp/mnode_test_trans2", fqdn, 9020, firstEp);
} }
static void TearDownTestSuite() { static void TearDownTestSuite() {
...@@ -220,7 +220,7 @@ TEST_F(MndTestTrans1, 03_Create_Qnode2_Crash) { ...@@ -220,7 +220,7 @@ TEST_F(MndTestTrans1, 03_Create_Qnode2_Crash) {
uInfo("======== kill and restart server") KillThenRestartServer(); uInfo("======== kill and restart server") KillThenRestartServer();
uInfo("======== server2 start") server2.DoStart(); uInfo("======== server2 start") server2.Start();
uInfo("======== server2 started") uInfo("======== server2 started")
......
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
#include "tcache.h" #include "tcache.h"
void reportStartup(const char *name, const char *desc) {} void reportStartup(const char *name, const char *desc) {}
void sendRsp(const SRpcMsg *pMsg) { rpcFreeCont(pMsg->pCont); }
int32_t sendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
// rpcFreeCont(pMsg->pCont);
terrno = TSDB_CODE_INVALID_PTR;
return -1;
}
class MndTestTrans2 : public ::testing::Test { class MndTestTrans2 : public ::testing::Test {
protected: protected:
...@@ -47,6 +54,8 @@ class MndTestTrans2 : public ::testing::Test { ...@@ -47,6 +54,8 @@ class MndTestTrans2 : public ::testing::Test {
static void InitMnode() { static void InitMnode() {
static SMsgCb msgCb = {0}; static SMsgCb msgCb = {0};
msgCb.reportStartupFp = reportStartup; msgCb.reportStartupFp = reportStartup;
msgCb.sendReqFp = sendReq;
msgCb.sendRspFp = sendRsp;
msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack
tmsgSetDefaultMsgCb(&msgCb); tmsgSetDefaultMsgCb(&msgCb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册