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

refactor: make more object global

上级 1f886b11
......@@ -260,7 +260,7 @@ static void dmWatchNodes(SDnode *pDnode) {
taosThreadMutexUnlock(&pDnode->mutex);
}
int32_t dnRunDnode(SDnode *pDnode) {
int32_t dmRunDnode(SDnode *pDnode) {
if (dmOpenNodes(pDnode) != 0) {
dError("failed to open nodes since %s", terrstr());
return -1;
......
......@@ -24,10 +24,9 @@ class TestServer {
bool DoStart();
private:
SDnodeOpt BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
void BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp);
private:
SDnode* pDnode;
TdThread threadId;
char path[PATH_MAX];
char fqdn[TSDB_FQDN_LEN];
......
......@@ -16,35 +16,29 @@
#include "sut.h"
void* serverLoop(void* param) {
SDnode* pDnode = (SDnode*)param;
dmRun(pDnode);
dmRun();
return NULL;
}
SDnodeOpt TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
SDnodeOpt option = {0};
option.numOfSupportVnodes = 16;
option.serverPort = port;
strcpy(option.dataDir, path);
snprintf(option.localEp, TSDB_EP_LEN, "%s:%u", fqdn, port);
snprintf(option.localFqdn, TSDB_FQDN_LEN, "%s", fqdn);
snprintf(option.firstEp, TSDB_EP_LEN, "%s", firstEp);
return option;
void TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
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() {
SDnodeOpt option = BuildOption(path, fqdn, port, firstEp);
taosMkDir(path);
pDnode = dmCreate(&option);
if (pDnode == NULL) {
if (dmInit(0) != 0) {
return false;
}
TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
taosThreadCreate(&threadId, &thAttr, serverLoop, pDnode);
taosThreadCreate(&threadId, &thAttr, serverLoop, NULL);
taosThreadAttrDestroy(&thAttr);
taosMsleep(2100);
return true;
......@@ -68,11 +62,7 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const
}
void TestServer::Stop() {
dmSetEvent(pDnode, DND_EVENT_STOP);
dmStop();
taosThreadJoin(threadId, NULL);
if (pDnode != NULL) {
dmClose(pDnode);
pDnode = NULL;
}
dmCleanup();
}
......@@ -40,7 +40,7 @@ void Testbase::InitLog(const char* path) {
}
void Testbase::Init(const char* path, int16_t port) {
dmInit();
dmInit(0);
char fqdn[] = "localhost";
char firstEp[TSDB_EP_LEN] = {0};
......
......@@ -15,7 +15,7 @@
#include "mndUser.h"
#include "tcache.h"
void reportStartup(SMgmtWrapper *pWrapper, const char *name, const char *desc) {}
void reportStartup(const char *name, const char *desc) {}
class MndTestTrans2 : public ::testing::Test {
protected:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册