fix smaTest failed caused by mnode not inited
This commit is contained in:
parent
f9834898c6
commit
22aad41810
|
@ -44,6 +44,11 @@ int32_t dmRun();
|
||||||
*/
|
*/
|
||||||
void dmStop();
|
void dmStop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for tests
|
||||||
|
*/
|
||||||
|
bool dmReadyForTest();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -415,3 +415,7 @@ void dmReportStartup(const char *pName, const char *pDesc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t dmGetClusterId() { return globalDnode.data.clusterId; }
|
int64_t dmGetClusterId() { return globalDnode.data.clusterId; }
|
||||||
|
|
||||||
|
bool dmReadyForTest() {
|
||||||
|
return dmInstance()->data.dnodeVer > 0;
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class TestServer {
|
||||||
public:
|
public:
|
||||||
bool Start();
|
bool Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
bool runnning;
|
bool running;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TdThread threadId;
|
TdThread threadId;
|
||||||
|
|
|
@ -17,13 +17,11 @@
|
||||||
|
|
||||||
void* serverLoop(void* param) {
|
void* serverLoop(void* param) {
|
||||||
TestServer* server = (TestServer*)param;
|
TestServer* server = (TestServer*)param;
|
||||||
server->runnning = false;
|
|
||||||
|
|
||||||
if (dmInit() != 0) {
|
if (dmInit() != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->runnning = true;
|
|
||||||
if (dmRun() != 0) {
|
if (dmRun() != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -33,13 +31,18 @@ void* serverLoop(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestServer::Start() {
|
bool TestServer::Start() {
|
||||||
|
tstrncpy(tsVersionName, "trial", strlen("trial"));
|
||||||
|
running = false;
|
||||||
TdThreadAttr thAttr;
|
TdThreadAttr thAttr;
|
||||||
taosThreadAttrInit(&thAttr);
|
taosThreadAttrInit(&thAttr);
|
||||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
taosThreadCreate(&threadId, &thAttr, serverLoop, this);
|
taosThreadCreate(&threadId, &thAttr, serverLoop, this);
|
||||||
taosThreadAttrDestroy(&thAttr);
|
taosThreadAttrDestroy(&thAttr);
|
||||||
taosMsleep(10000);
|
while (!dmReadyForTest()) {
|
||||||
return runnning;
|
taosMsleep(500);
|
||||||
|
}
|
||||||
|
running = true;
|
||||||
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestServer::Stop() {
|
void TestServer::Stop() {
|
||||||
|
|
|
@ -49,6 +49,7 @@ TEST_F(MndTestFunc, 01_Show_Func) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestFunc, 02_Create_Func) {
|
TEST_F(MndTestFunc, 02_Create_Func) {
|
||||||
|
#ifndef WINDOWS
|
||||||
{
|
{
|
||||||
SCreateFuncReq createReq = {0};
|
SCreateFuncReq createReq = {0};
|
||||||
strcpy(createReq.name, "");
|
strcpy(createReq.name, "");
|
||||||
|
@ -159,9 +160,11 @@ TEST_F(MndTestFunc, 02_Create_Func) {
|
||||||
|
|
||||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
|
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
|
||||||
EXPECT_EQ(test.GetShowRows(), 1);
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
|
#ifndef WINDOWS
|
||||||
{
|
{
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 1;
|
retrieveReq.numOfFuncs = 1;
|
||||||
|
@ -376,9 +379,11 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_FUNC_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_FUNC_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestFunc, 04_Drop_Func) {
|
TEST_F(MndTestFunc, 04_Drop_Func) {
|
||||||
|
#ifndef WINDOWS
|
||||||
{
|
{
|
||||||
SDropFuncReq dropReq = {0};
|
SDropFuncReq dropReq = {0};
|
||||||
strcpy(dropReq.name, "");
|
strcpy(dropReq.name, "");
|
||||||
|
@ -441,9 +446,11 @@ TEST_F(MndTestFunc, 04_Drop_Func) {
|
||||||
|
|
||||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
|
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
|
||||||
EXPECT_EQ(test.GetShowRows(), 1);
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestFunc, 05_Actual_code) {
|
TEST_F(MndTestFunc, 05_Actual_code) {
|
||||||
|
#ifndef WINDOWS
|
||||||
{
|
{
|
||||||
SCreateFuncReq createReq = {0};
|
SCreateFuncReq createReq = {0};
|
||||||
strcpy(createReq.name, "udf1");
|
strcpy(createReq.name, "udf1");
|
||||||
|
@ -507,4 +514,5 @@ TEST_F(MndTestFunc, 05_Actual_code) {
|
||||||
}
|
}
|
||||||
tFreeSRetrieveFuncRsp(&retrieveRsp);
|
tFreeSRetrieveFuncRsp(&retrieveRsp);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
Loading…
Reference in New Issue