fix smaTest failed caused by mnode not inited

This commit is contained in:
wangjiaming0909 2024-05-23 10:23:08 +00:00 committed by wangjiaming0909
parent f9834898c6
commit 22aad41810
5 changed files with 27 additions and 7 deletions

View File

@ -44,6 +44,11 @@ int32_t dmRun();
*/
void dmStop();
/**
* for tests
*/
bool dmReadyForTest();
#ifdef __cplusplus
}
#endif

View File

@ -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;
}

View File

@ -20,10 +20,10 @@ class TestServer {
public:
bool Start();
void Stop();
bool runnning;
bool running;
private:
TdThread threadId;
};
#endif /* _TD_TEST_SERVER_H_ */
#endif /* _TD_TEST_SERVER_H_ */

View File

@ -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() {

View File

@ -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);
}
}
#endif
}