diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index 82823e3f57..15cb6d59aa 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -44,6 +44,11 @@ int32_t dmRun(); */ void dmStop(); +/** + * for tests + */ +bool dmReadyForTest(); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 8e760c28be..5b1f31e6c6 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -415,3 +415,7 @@ void dmReportStartup(const char *pName, const char *pDesc) { } int64_t dmGetClusterId() { return globalDnode.data.clusterId; } + +bool dmReadyForTest() { + return dmInstance()->data.dnodeVer > 0; +} diff --git a/source/dnode/mgmt/test/sut/inc/server.h b/source/dnode/mgmt/test/sut/inc/server.h index 7343276210..78055393b5 100644 --- a/source/dnode/mgmt/test/sut/inc/server.h +++ b/source/dnode/mgmt/test/sut/inc/server.h @@ -20,10 +20,10 @@ class TestServer { public: bool Start(); void Stop(); -bool runnning; + bool running; private: TdThread threadId; }; -#endif /* _TD_TEST_SERVER_H_ */ \ No newline at end of file +#endif /* _TD_TEST_SERVER_H_ */ diff --git a/source/dnode/mgmt/test/sut/src/server.cpp b/source/dnode/mgmt/test/sut/src/server.cpp index 541c5a42f4..2218504df4 100644 --- a/source/dnode/mgmt/test/sut/src/server.cpp +++ b/source/dnode/mgmt/test/sut/src/server.cpp @@ -17,13 +17,11 @@ void* serverLoop(void* param) { TestServer* server = (TestServer*)param; - server->runnning = false; if (dmInit() != 0) { return NULL; } - server->runnning = true; if (dmRun() != 0) { return NULL; } @@ -33,13 +31,18 @@ void* serverLoop(void* param) { } bool TestServer::Start() { + tstrncpy(tsVersionName, "trial", strlen("trial")); + running = false; TdThreadAttr thAttr; taosThreadAttrInit(&thAttr); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadCreate(&threadId, &thAttr, serverLoop, this); taosThreadAttrDestroy(&thAttr); - taosMsleep(10000); - return runnning; + while (!dmReadyForTest()) { + taosMsleep(500); + } + running = true; + return running; } void TestServer::Stop() { diff --git a/source/dnode/mnode/impl/test/func/func.cpp b/source/dnode/mnode/impl/test/func/func.cpp index 64bca96702..ee60556639 100644 --- a/source/dnode/mnode/impl/test/func/func.cpp +++ b/source/dnode/mnode/impl/test/func/func.cpp @@ -49,6 +49,7 @@ TEST_F(MndTestFunc, 01_Show_Func) { } TEST_F(MndTestFunc, 02_Create_Func) { +#ifndef WINDOWS { SCreateFuncReq createReq = {0}; strcpy(createReq.name, ""); @@ -159,9 +160,11 @@ TEST_F(MndTestFunc, 02_Create_Func) { test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); +#endif } TEST_F(MndTestFunc, 03_Retrieve_Func) { +#ifndef WINDOWS { SRetrieveFuncReq retrieveReq = {0}; retrieveReq.numOfFuncs = 1; @@ -376,9 +379,11 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_FUNC_NOT_EXIST); } +#endif } TEST_F(MndTestFunc, 04_Drop_Func) { +#ifndef WINDOWS { SDropFuncReq dropReq = {0}; strcpy(dropReq.name, ""); @@ -441,9 +446,11 @@ TEST_F(MndTestFunc, 04_Drop_Func) { test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); +#endif } TEST_F(MndTestFunc, 05_Actual_code) { +#ifndef WINDOWS { SCreateFuncReq createReq = {0}; strcpy(createReq.name, "udf1"); @@ -507,4 +514,5 @@ TEST_F(MndTestFunc, 05_Actual_code) { } tFreeSRetrieveFuncRsp(&retrieveRsp); } -} \ No newline at end of file +#endif +}