qworkerTests.cpp 35.4 KB
Newer Older
D
dapan1121 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>
#include <iostream>

S
Shengliang Guan 已提交
19 20
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
D
dapan1121 已提交
21 22 23
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
S
Shengliang Guan 已提交
24 25 26 27
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
28
#include <addr_any.h>
S
Shengliang Guan 已提交
29

wafwerar's avatar
wafwerar 已提交
30 31 32
#ifdef WINDOWS
#define TD_USE_WINSOCK
#endif
D
dapan1121 已提交
33 34
#include "os.h"

35
#include "tglobal.h"
H
Haojun Liao 已提交
36 37 38
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
H
Haojun Liao 已提交
39
#include "tdatablock.h"
D
dapan1121 已提交
40
#include "trpc.h"
D
dapan 已提交
41 42
#include "planner.h"
#include "qworker.h"
D
dapan1121 已提交
43
#include "stub.h"
D
dapan1121 已提交
44 45
#include "executor.h"
#include "dataSinkMgt.h"
D
dapan1121 已提交
46 47 48 49


namespace {

D
dapan1121 已提交
50 51 52
#define qwtTestQueryQueueSize 1000000
#define qwtTestFetchQueueSize 1000000

D
dapan1121 已提交
53 54
bool qwtEnableLog = true;

D
dapan1121 已提交
55 56
int32_t qwtTestMaxExecTaskUsec = 2;
int32_t qwtTestReqMaxDelayUsec = 2;
D
dapan1121 已提交
57

wafwerar's avatar
wafwerar 已提交
58
int64_t qwtTestQueryId = 0;
D
dapan1121 已提交
59 60
bool qwtTestEnableSleep = true;
bool qwtTestStop = false;
D
dapan1121 已提交
61
bool qwtTestDeadLoop = false;
D
dapan1121 已提交
62
int32_t qwtTestMTRunSec = 2;
D
dapan1121 已提交
63 64 65
int32_t qwtTestPrintNum = 10000;
uint64_t qwtTestCaseIdx = 0;
uint64_t qwtTestCaseNum = 4;
D
dapan1121 已提交
66 67 68
bool qwtTestCaseFinished = false;
tsem_t qwtTestQuerySem;
tsem_t qwtTestFetchSem;
D
dapan1121 已提交
69 70
int32_t qwtTestQuitThreadNum = 0;

D
dapan1121 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

int32_t qwtTestQueryQueueRIdx = 0;
int32_t qwtTestQueryQueueWIdx = 0;
int32_t qwtTestQueryQueueNum = 0;
SRWLatch qwtTestQueryQueueLock = 0;
struct SRpcMsg *qwtTestQueryQueue[qwtTestQueryQueueSize] = {0};

int32_t qwtTestFetchQueueRIdx = 0;
int32_t qwtTestFetchQueueWIdx = 0;
int32_t qwtTestFetchQueueNum = 0;
SRWLatch qwtTestFetchQueueLock = 0;
struct SRpcMsg *qwtTestFetchQueue[qwtTestFetchQueueSize] = {0};


int32_t qwtTestSinkBlockNum = 0;
int32_t qwtTestSinkMaxBlockNum = 0;
bool qwtTestSinkQueryEnd = false;
SRWLatch qwtTestSinkLock = 0;
D
dapan1121 已提交
89
int32_t qwtTestSinkLastLen = 0;
D
dapan1121 已提交
90 91


D
dapan1121 已提交
92
SSubQueryMsg qwtqueryMsg = {0};
D
dapan1121 已提交
93 94 95 96 97 98
SRpcMsg qwtfetchRpc = {0};
SResFetchReq qwtfetchMsg = {0};
SRpcMsg qwtreadyRpc = {0};
SResReadyReq qwtreadyMsg = {0};
SRpcMsg qwtdropRpc = {0};
STaskDropReq qwtdropMsg = {0};  
D
dapan1121 已提交
99
SSchTasksStatusReq qwtstatusMsg = {0};
D
dapan1121 已提交
100

D
dapan1121 已提交
101 102

void qwtInitLogFile() {
D
dapan1121 已提交
103 104 105
  if (!qwtEnableLog) {
    return;
  }
D
dapan1121 已提交
106 107 108 109 110
  const char    *defaultLogFileNamePrefix = "taosdlog";
  const int32_t  maxLogFileNum = 10;

  tsAsyncLog = 0;
  qDebugFlag = 159;
D
dapan1121 已提交
111
  strcpy(tsLogDir, "/var/log/taos");
D
dapan1121 已提交
112

S
Shengliang Guan 已提交
113
  if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
S
os env  
Shengliang Guan 已提交
114
    printf("failed to open log file in directory:%s\n", tsLogDir);
D
dapan1121 已提交
115 116 117 118 119
  }

}

void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) {
D
dapan1121 已提交
120 121 122
  qwtqueryMsg.queryId = htobe64(atomic_add_fetch_64(&qwtTestQueryId, 1));
  qwtqueryMsg.sId = htobe64(1);
  qwtqueryMsg.taskId = htobe64(1);
123 124
  qwtqueryMsg.phyLen = htonl(100);
  qwtqueryMsg.sqlLen = 0;
D
dapan1121 已提交
125
  queryRpc->msgType = TDMT_VND_QUERY;
D
dapan1121 已提交
126
  queryRpc->pCont = &qwtqueryMsg;
D
dapan1121 已提交
127 128 129 130 131
  queryRpc->contLen = sizeof(SSubQueryMsg) + 100;
}

void qwtBuildReadyReqMsg(SResReadyReq *readyMsg, SRpcMsg *readyRpc) {
  readyMsg->sId = htobe64(1);
D
dapan1121 已提交
132
  readyMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
D
dapan1121 已提交
133
  readyMsg->taskId = htobe64(1);
D
dapan1121 已提交
134
  readyRpc->msgType = TDMT_VND_RES_READY;
D
dapan1121 已提交
135 136 137 138 139 140
  readyRpc->pCont = readyMsg;
  readyRpc->contLen = sizeof(SResReadyReq);
}

void qwtBuildFetchReqMsg(SResFetchReq *fetchMsg, SRpcMsg *fetchRpc) {
  fetchMsg->sId = htobe64(1);
D
dapan1121 已提交
141
  fetchMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
D
dapan1121 已提交
142
  fetchMsg->taskId = htobe64(1);
D
dapan1121 已提交
143
  fetchRpc->msgType = TDMT_VND_FETCH;
D
dapan1121 已提交
144 145 146 147 148 149
  fetchRpc->pCont = fetchMsg;
  fetchRpc->contLen = sizeof(SResFetchReq);
}

void qwtBuildDropReqMsg(STaskDropReq *dropMsg, SRpcMsg *dropRpc) {
  dropMsg->sId = htobe64(1);
D
dapan1121 已提交
150
  dropMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
D
dapan1121 已提交
151
  dropMsg->taskId = htobe64(1);
D
dapan1121 已提交
152
  dropRpc->msgType = TDMT_VND_DROP_TASK;
D
dapan1121 已提交
153 154 155 156 157 158 159 160 161 162
  dropRpc->pCont = dropMsg;
  dropRpc->contLen = sizeof(STaskDropReq);
}

void qwtBuildStatusReqMsg(SSchTasksStatusReq *statusMsg, SRpcMsg *statusRpc) {
  statusMsg->sId = htobe64(1);
  statusRpc->pCont = statusMsg;
  statusRpc->contLen = sizeof(SSchTasksStatusReq);
  statusRpc->msgType = TDMT_VND_TASKS_STATUS;
}
D
dapan1121 已提交
163

D
dapan 已提交
164
int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
D
dapan 已提交
165
  *subplan = (SSubplan *)0x1;
D
dapan 已提交
166
  return 0;
D
dapan1121 已提交
167 168
}

D
dapan1121 已提交
169 170
int32_t qwtPutReqToFetchQueue(void *node, struct SRpcMsg *pMsg) {
  taosWLockLatch(&qwtTestFetchQueueLock);
wafwerar's avatar
wafwerar 已提交
171
  struct SRpcMsg *newMsg = (struct SRpcMsg *)taosMemoryCalloc(1, sizeof(struct SRpcMsg));
D
dapan1121 已提交
172 173
  memcpy(newMsg, pMsg, sizeof(struct SRpcMsg));  
  qwtTestFetchQueue[qwtTestFetchQueueWIdx++] = newMsg;
D
dapan1121 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
  if (qwtTestFetchQueueWIdx >= qwtTestFetchQueueSize) {
    qwtTestFetchQueueWIdx = 0;
  }
  
  qwtTestFetchQueueNum++;

  if (qwtTestFetchQueueWIdx == qwtTestFetchQueueRIdx) {
    printf("Fetch queue is full");
    assert(0);
  }
  taosWUnLockLatch(&qwtTestFetchQueueLock);
  
  tsem_post(&qwtTestFetchSem);
  
  return 0;
}


D
dapan1121 已提交
192
int32_t qwtPutReqToQueue(void *node, struct SRpcMsg *pMsg) {
D
dapan1121 已提交
193
  taosWLockLatch(&qwtTestQueryQueueLock);
wafwerar's avatar
wafwerar 已提交
194
  struct SRpcMsg *newMsg = (struct SRpcMsg *)taosMemoryCalloc(1, sizeof(struct SRpcMsg));
D
dapan1121 已提交
195 196
  memcpy(newMsg, pMsg, sizeof(struct SRpcMsg));
  qwtTestQueryQueue[qwtTestQueryQueueWIdx++] = newMsg;
D
dapan1121 已提交
197 198 199 200 201 202 203 204 205 206 207 208 209 210
  if (qwtTestQueryQueueWIdx >= qwtTestQueryQueueSize) {
    qwtTestQueryQueueWIdx = 0;
  }
  
  qwtTestQueryQueueNum++;

  if (qwtTestQueryQueueWIdx == qwtTestQueryQueueRIdx) {
    printf("query queue is full");
    assert(0);
  }
  taosWUnLockLatch(&qwtTestQueryQueueLock);
  
  tsem_post(&qwtTestQuerySem);
  
D
dapan1121 已提交
211 212 213
  return 0;
}

D
dapan1121 已提交
214 215 216
void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) {
  
}
D
dapan1121 已提交
217

D
dapan1121 已提交
218

D
dapan1121 已提交
219
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
D
dapan1121 已提交
220 221 222 223 224 225 226

  switch (pRsp->msgType) {
    case TDMT_VND_QUERY_RSP: {
      SQueryTableRsp *rsp = (SQueryTableRsp *)pRsp->pCont;

      if (0 == pRsp->code) {
        qwtBuildReadyReqMsg(&qwtreadyMsg, &qwtreadyRpc);    
D
dapan 已提交
227
        qwtPutReqToFetchQueue((void *)0x1, &qwtreadyRpc);
D
dapan1121 已提交
228 229
      } else {
        qwtBuildDropReqMsg(&qwtdropMsg, &qwtdropRpc);
D
dapan 已提交
230
        qwtPutReqToFetchQueue((void *)0x1, &qwtdropRpc);
D
dapan1121 已提交
231 232
      }
      
D
dapan1121 已提交
233
      rpcFreeCont(rsp);
D
dapan1121 已提交
234 235 236 237 238 239 240
      break;
    }
    case TDMT_VND_RES_READY_RSP: {
      SResReadyRsp *rsp = (SResReadyRsp *)pRsp->pCont;
      
      if (0 == pRsp->code) {
        qwtBuildFetchReqMsg(&qwtfetchMsg, &qwtfetchRpc);
D
dapan 已提交
241
        qwtPutReqToFetchQueue((void *)0x1, &qwtfetchRpc);
D
dapan1121 已提交
242 243
      } else {
        qwtBuildDropReqMsg(&qwtdropMsg, &qwtdropRpc);
D
dapan 已提交
244
        qwtPutReqToFetchQueue((void *)0x1, &qwtdropRpc);
D
dapan1121 已提交
245
      }
D
dapan1121 已提交
246
      rpcFreeCont(rsp);
D
dapan1121 已提交
247 248 249 250 251 252 253
      break;
    }
    case TDMT_VND_FETCH_RSP: {
      SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)pRsp->pCont;
  
      if (0 == pRsp->code && 0 == rsp->completed) {
        qwtBuildFetchReqMsg(&qwtfetchMsg, &qwtfetchRpc);
D
dapan 已提交
254
        qwtPutReqToFetchQueue((void *)0x1, &qwtfetchRpc);
D
dapan1121 已提交
255
        rpcFreeCont(rsp);
D
dapan1121 已提交
256 257 258 259
        return;
      }

      qwtBuildDropReqMsg(&qwtdropMsg, &qwtdropRpc);
D
dapan 已提交
260
      qwtPutReqToFetchQueue((void *)0x1, &qwtdropRpc);
D
dapan1121 已提交
261
      rpcFreeCont(rsp);
D
dapan1121 已提交
262 263 264
      
      break;
    }
D
dapan1121 已提交
265
    case TDMT_VND_DROP_TASK_RSP: {
D
dapan1121 已提交
266
      STaskDropRsp *rsp = (STaskDropRsp *)pRsp->pCont;
D
dapan1121 已提交
267
      rpcFreeCont(rsp);
D
dapan1121 已提交
268 269 270

      qwtTestCaseFinished = true;
      break;
D
dapan1121 已提交
271 272
    }
  }
D
dapan1121 已提交
273

D
dapan1121 已提交
274
  
D
dapan1121 已提交
275 276 277
  return;
}

D
dapan1121 已提交
278
int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) {
D
dapan1121 已提交
279
  qwtTestSinkBlockNum = 0;
wafwerar's avatar
wafwerar 已提交
280
  qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
D
dapan1121 已提交
281
  qwtTestSinkQueryEnd = false;
D
dapan1121 已提交
282
  
wafwerar's avatar
wafwerar 已提交
283 284
  *pTaskInfo = (qTaskInfo_t)((char*)qwtTestCaseIdx+1);
  *handle = (DataSinkHandle)((char*)qwtTestCaseIdx+2);
D
dapan1121 已提交
285 286

  ++qwtTestCaseIdx;
D
dapan1121 已提交
287 288 289 290 291
  
  return 0;
}

int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
D
dapan1121 已提交
292 293 294 295 296 297
  int32_t endExec = 0;
  
  if (NULL == tinfo) {
    *pRes = NULL;
    *useconds = 0;
  } else {
D
dapan1121 已提交
298 299
    if (qwtTestSinkQueryEnd) {
      *pRes = NULL;
wafwerar's avatar
wafwerar 已提交
300
      *useconds = taosRand() % 10;
D
dapan1121 已提交
301 302 303
      return 0;
    }
    
wafwerar's avatar
wafwerar 已提交
304
    endExec = taosRand() % 5;
D
dapan1121 已提交
305
    
D
dapan1121 已提交
306 307
    int32_t runTime = 0;
    if (qwtTestEnableSleep && qwtTestMaxExecTaskUsec > 0) {
wafwerar's avatar
wafwerar 已提交
308
      runTime = taosRand() % qwtTestMaxExecTaskUsec;
D
dapan1121 已提交
309 310 311 312
    }

    if (qwtTestEnableSleep) {
      if (runTime) {
wafwerar's avatar
wafwerar 已提交
313
        taosUsleep(runTime);
D
dapan1121 已提交
314 315
      }
    }
D
dapan1121 已提交
316
      
D
dapan1121 已提交
317
    if (endExec) {
wafwerar's avatar
wafwerar 已提交
318
      *pRes = (SSDataBlock*)taosMemoryCalloc(1, sizeof(SSDataBlock));
D
dapan1121 已提交
319
      (*pRes)->info.rows = taosRand() % 1000 + 1;
D
dapan1121 已提交
320 321
    } else {
      *pRes = NULL;
wafwerar's avatar
wafwerar 已提交
322
      *useconds = taosRand() % 10;
D
dapan1121 已提交
323 324 325
    }
  }
  
D
dapan1121 已提交
326 327 328 329 330 331 332 333 334 335 336 337
  return 0;
}

int32_t qwtKillTask(qTaskInfo_t qinfo) {
  return 0;
}

void qwtDestroyTask(qTaskInfo_t qHandle) {
}


int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue) {
D
dapan1121 已提交
338 339 340 341
  if (NULL == handle || NULL == pInput || NULL == pContinue) {
    assert(0);
  }

wafwerar's avatar
wafwerar 已提交
342
  taosMemoryFree((void *)pInput->pData);
D
dapan1121 已提交
343

D
dapan1121 已提交
344 345 346 347 348 349
  taosWLockLatch(&qwtTestSinkLock);

  qwtTestSinkBlockNum++;

  if (qwtTestSinkBlockNum >= qwtTestSinkMaxBlockNum) {
    *pContinue = false;
D
dapan1121 已提交
350 351
  } else {
    *pContinue = true;
D
dapan1121 已提交
352 353 354
  }
  taosWUnLockLatch(&qwtTestSinkLock);
  
D
dapan1121 已提交
355 356 357 358
  return 0;
}

void qwtEndPut(DataSinkHandle handle, uint64_t useconds) {
D
dapan1121 已提交
359 360 361 362 363
  if (NULL == handle) {
    assert(0);
  }

  qwtTestSinkQueryEnd = true;
D
dapan1121 已提交
364 365 366
}

void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
D
dapan1121 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379 380
  static int32_t in = 0;

  if (in > 0) {
    assert(0);
  }

  atomic_add_fetch_32(&in, 1);
  
  if (NULL == handle) {
    assert(0);
  }

  taosWLockLatch(&qwtTestSinkLock);
  if (qwtTestSinkBlockNum > 0) {
wafwerar's avatar
wafwerar 已提交
381
    *pLen = taosRand() % 100 + 1;
D
dapan1121 已提交
382 383 384 385
    qwtTestSinkBlockNum--;
  } else {
    *pLen = 0;
  }
D
dapan1121 已提交
386
  qwtTestSinkLastLen = *pLen;
D
dapan1121 已提交
387 388 389 390 391
  taosWUnLockLatch(&qwtTestSinkLock);

  *pQueryEnd = qwtTestSinkQueryEnd;

  atomic_sub_fetch_32(&in, 1);
D
dapan1121 已提交
392 393 394
}

int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
D
dapan1121 已提交
395
  taosWLockLatch(&qwtTestSinkLock);
D
dapan1121 已提交
396
  if (qwtTestSinkLastLen > 0) {
wafwerar's avatar
wafwerar 已提交
397
    pOutput->numOfRows = taosRand() % 10 + 1;
D
dapan1121 已提交
398
    pOutput->compressed = 1;
D
dapan1121 已提交
399 400 401 402 403 404 405 406
    pOutput->queryEnd = qwtTestSinkQueryEnd;
    if (qwtTestSinkBlockNum == 0) {
      pOutput->bufStatus = DS_BUF_EMPTY;
    } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) {
      pOutput->bufStatus = DS_BUF_LOW;
    } else {
      pOutput->bufStatus = DS_BUF_FULL;
    }
wafwerar's avatar
wafwerar 已提交
407
    pOutput->useconds = taosRand() % 10 + 1;
D
dapan1121 已提交
408 409 410 411 412
    pOutput->precision = 1;
  } else if (qwtTestSinkLastLen == 0) {
    pOutput->numOfRows = 0;
    pOutput->compressed = 1;
    pOutput->pData = NULL;
D
dapan1121 已提交
413 414 415 416 417 418 419 420
    pOutput->queryEnd = qwtTestSinkQueryEnd;
    if (qwtTestSinkBlockNum == 0) {
      pOutput->bufStatus = DS_BUF_EMPTY;
    } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) {
      pOutput->bufStatus = DS_BUF_LOW;
    } else {
      pOutput->bufStatus = DS_BUF_FULL;
    }
wafwerar's avatar
wafwerar 已提交
421
    pOutput->useconds = taosRand() % 10 + 1;
D
dapan1121 已提交
422 423 424 425 426 427
    pOutput->precision = 1;
  } else {
    assert(0);
  }
  taosWUnLockLatch(&qwtTestSinkLock);
  
D
dapan1121 已提交
428 429 430 431 432 433 434
  return 0;
}

void qwtDestroyDataSinker(DataSinkHandle handle) {

}

D
dapan1121 已提交
435

D
dapan1121 已提交
436

D
dapan 已提交
437
void stubSetStringToPlan() {
D
dapan1121 已提交
438
  static Stub stub;
D
dapan 已提交
439
  stub.set(qStringToSubplan, qwtStringToPlan);
D
dapan1121 已提交
440
  {
wafwerar's avatar
wafwerar 已提交
441 442 443 444 445 446
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("qStringToSubplan", result);
#endif
#ifdef LINUX
D
dapan 已提交
447
    AddrAny any("libplanner.so");
D
dapan1121 已提交
448
    std::map<std::string,void*> result;
D
dapan 已提交
449
    any.get_global_func_addr_dynsym("^qStringToSubplan$", result);
wafwerar's avatar
wafwerar 已提交
450
#endif
D
dapan1121 已提交
451
    for (const auto& f : result) {
D
dapan 已提交
452
      stub.set(f.second, qwtStringToPlan);
D
dapan1121 已提交
453 454 455 456
    }
  }
}

D
dapan1121 已提交
457 458 459 460
void stubSetExecTask() {
  static Stub stub;
  stub.set(qExecTask, qwtExecTask);
  {
wafwerar's avatar
wafwerar 已提交
461 462 463 464 465 466
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("qExecTask", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
467 468 469
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^qExecTask$", result);
wafwerar's avatar
wafwerar 已提交
470
#endif
D
dapan1121 已提交
471 472 473 474 475 476 477 478 479 480 481 482
    for (const auto& f : result) {
      stub.set(f.second, qwtExecTask);
    }
  }
}



void stubSetCreateExecTask() {
  static Stub stub;
  stub.set(qCreateExecTask, qwtCreateExecTask);
  {
wafwerar's avatar
wafwerar 已提交
483 484 485 486 487 488
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("qCreateExecTask", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
489 490 491
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^qCreateExecTask$", result);
wafwerar's avatar
wafwerar 已提交
492
#endif
D
dapan1121 已提交
493 494 495 496 497 498 499 500 501 502
    for (const auto& f : result) {
      stub.set(f.second, qwtCreateExecTask);
    }
  }
}

void stubSetAsyncKillTask() {
  static Stub stub;
  stub.set(qAsyncKillTask, qwtKillTask);
  {
wafwerar's avatar
wafwerar 已提交
503 504 505 506 507 508
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("qAsyncKillTask", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
509 510 511
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^qAsyncKillTask$", result);
wafwerar's avatar
wafwerar 已提交
512
#endif
D
dapan1121 已提交
513 514 515 516 517 518 519 520 521 522
    for (const auto& f : result) {
      stub.set(f.second, qwtKillTask);
    }
  }
}

void stubSetDestroyTask() {
  static Stub stub;
  stub.set(qDestroyTask, qwtDestroyTask);
  {
wafwerar's avatar
wafwerar 已提交
523 524 525 526 527 528
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("qDestroyTask", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
529 530 531
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^qDestroyTask$", result);
wafwerar's avatar
wafwerar 已提交
532
#endif
D
dapan1121 已提交
533 534 535 536 537 538 539 540 541 542 543
    for (const auto& f : result) {
      stub.set(f.second, qwtDestroyTask);
    }
  }
}


void stubSetDestroyDataSinker() {
  static Stub stub;
  stub.set(dsDestroyDataSinker, qwtDestroyDataSinker);
  {
wafwerar's avatar
wafwerar 已提交
544 545 546 547 548 549
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("dsDestroyDataSinker", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
550 551 552
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result);
wafwerar's avatar
wafwerar 已提交
553
#endif
D
dapan1121 已提交
554 555 556 557 558 559 560 561 562 563
    for (const auto& f : result) {
      stub.set(f.second, qwtDestroyDataSinker);
    }
  }
}

void stubSetGetDataLength() {
  static Stub stub;
  stub.set(dsGetDataLength, qwtGetDataLength);
  {
wafwerar's avatar
wafwerar 已提交
564 565 566 567 568 569
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("dsGetDataLength", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
570 571 572
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^dsGetDataLength$", result);
wafwerar's avatar
wafwerar 已提交
573
#endif
D
dapan1121 已提交
574 575 576 577 578 579 580 581 582 583
    for (const auto& f : result) {
      stub.set(f.second, qwtGetDataLength);
    }
  }
}

void stubSetEndPut() {
  static Stub stub;
  stub.set(dsEndPut, qwtEndPut);
  {
wafwerar's avatar
wafwerar 已提交
584 585 586 587 588 589
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("dsEndPut", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
590 591 592
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^dsEndPut$", result);
wafwerar's avatar
wafwerar 已提交
593
#endif
D
dapan1121 已提交
594 595 596 597 598 599 600 601 602 603
    for (const auto& f : result) {
      stub.set(f.second, qwtEndPut);
    }
  }
}

void stubSetPutDataBlock() {
  static Stub stub;
  stub.set(dsPutDataBlock, qwtPutDataBlock);
  {
wafwerar's avatar
wafwerar 已提交
604 605 606 607 608 609
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("dsPutDataBlock", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
610 611 612
    AddrAny any("libexecutor.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^dsPutDataBlock$", result);
wafwerar's avatar
wafwerar 已提交
613
#endif
D
dapan1121 已提交
614 615 616 617 618 619
    for (const auto& f : result) {
      stub.set(f.second, qwtPutDataBlock);
    }
  }
}

D
dapan1121 已提交
620 621 622 623
void stubSetRpcSendResponse() {
  static Stub stub;
  stub.set(rpcSendResponse, qwtRpcSendResponse);
  {
wafwerar's avatar
wafwerar 已提交
624 625 626 627 628 629
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("rpcSendResponse", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
630
    AddrAny any("libtransport.so");
D
dapan1121 已提交
631 632
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^rpcSendResponse$", result);
wafwerar's avatar
wafwerar 已提交
633
#endif
D
dapan1121 已提交
634 635 636 637 638 639
    for (const auto& f : result) {
      stub.set(f.second, qwtRpcSendResponse);
    }
  }
}

D
dapan1121 已提交
640 641 642 643
void stubSetGetDataBlock() {
  static Stub stub;
  stub.set(dsGetDataBlock, qwtGetDataBlock);
  {
wafwerar's avatar
wafwerar 已提交
644 645 646 647 648 649
#ifdef WINDOWS
    AddrAny any;
    std::map<std::string,void*> result;
    any.get_func_addr("dsGetDataBlock", result);
#endif
#ifdef LINUX
D
dapan1121 已提交
650 651 652
    AddrAny any("libtransport.so");
    std::map<std::string,void*> result;
    any.get_global_func_addr_dynsym("^dsGetDataBlock$", result);
wafwerar's avatar
wafwerar 已提交
653
#endif
D
dapan1121 已提交
654 655 656 657 658 659 660
    for (const auto& f : result) {
      stub.set(f.second, qwtGetDataBlock);
    }
  }
}


D
dapan1121 已提交
661 662 663 664 665 666 667
void *queryThread(void *param) {
  SRpcMsg queryRpc = {0};
  int32_t code = 0;
  uint32_t n = 0;
  void *mockPointer = (void *)0x1;    
  void *mgmt = param;

D
dapan1121 已提交
668 669 670 671
  while (!qwtTestStop) {
    qwtBuildQueryReqMsg(&queryRpc);
    qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);    
    if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
672
      taosUsleep(taosRand()%5);
D
dapan1121 已提交
673 674
    }
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
675 676 677 678 679 680 681 682 683 684 685 686 687
      printf("query:%d\n", n);
    }
  }

  return NULL;
}

void *readyThread(void *param) {
  SRpcMsg readyRpc = {0};
  int32_t code = 0;
  uint32_t n = 0;  
  void *mockPointer = (void *)0x1;    
  void *mgmt = param;
S
Shengliang Guan 已提交
688
  SResReadyReq readyMsg = {0};
D
dapan1121 已提交
689

D
dapan1121 已提交
690 691
  while (!qwtTestStop) {
    qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
D
dapan1121 已提交
692
    code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
D
dapan1121 已提交
693
    if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
694
      taosUsleep(taosRand()%5);
D
dapan1121 已提交
695 696
    }
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
697 698 699 700 701 702 703 704 705 706 707 708 709
      printf("ready:%d\n", n);
    }    
  }

  return NULL;
}

void *fetchThread(void *param) {
  SRpcMsg fetchRpc = {0};
  int32_t code = 0;
  uint32_t n = 0;  
  void *mockPointer = (void *)0x1;    
  void *mgmt = param;
S
Shengliang Guan 已提交
710
  SResFetchReq fetchMsg = {0};
D
dapan1121 已提交
711

D
dapan1121 已提交
712 713
  while (!qwtTestStop) {
    qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
D
dapan1121 已提交
714
    code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
D
dapan1121 已提交
715
    if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
716
      taosUsleep(taosRand()%5);
D
dapan1121 已提交
717 718
    }
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
719 720 721 722 723 724 725 726 727 728 729 730 731
      printf("fetch:%d\n", n);
    }    
  }

  return NULL;
}

void *dropThread(void *param) {
  SRpcMsg dropRpc = {0};
  int32_t code = 0;
  uint32_t n = 0;  
  void *mockPointer = (void *)0x1;    
  void *mgmt = param;
S
Shengliang Guan 已提交
732
  STaskDropReq dropMsg = {0};  
D
dapan1121 已提交
733

D
dapan1121 已提交
734 735
  while (!qwtTestStop) {
    qwtBuildDropReqMsg(&dropMsg, &dropRpc);
D
dapan1121 已提交
736
    code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
D
dapan1121 已提交
737
    if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
738
      taosUsleep(taosRand()%5);
D
dapan1121 已提交
739 740
    }
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
741 742 743 744 745 746 747 748 749 750 751 752 753
      printf("drop:%d\n", n);
    }    
  }

  return NULL;
}

void *statusThread(void *param) {
  SRpcMsg statusRpc = {0};
  int32_t code = 0;
  uint32_t n = 0;  
  void *mockPointer = (void *)0x1;    
  void *mgmt = param;
S
Shengliang Guan 已提交
754
  SSchTasksStatusReq statusMsg = {0};
D
dapan1121 已提交
755

D
dapan1121 已提交
756 757
  while (!qwtTestStop) {
    qwtBuildStatusReqMsg(&statusMsg, &statusRpc);
D
dapan1121 已提交
758
    code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
D
dapan1121 已提交
759
    if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
760
      taosUsleep(taosRand()%5);
D
dapan1121 已提交
761 762
    }
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
763 764 765 766 767 768 769 770
      printf("status:%d\n", n);
    }    
  }

  return NULL;
}


D
dapan1121 已提交
771
void *qwtclientThread(void *param) {
D
dapan1121 已提交
772 773 774
  int32_t code = 0;
  uint32_t n = 0;
  void *mgmt = param;
D
dapan1121 已提交
775 776 777
  void *mockPointer = (void *)0x1;    
  SRpcMsg queryRpc = {0};

wafwerar's avatar
wafwerar 已提交
778
  taosSsleep(1);
D
dapan1121 已提交
779 780

  while (!qwtTestStop) {
D
dapan1121 已提交
781 782
    qwtTestCaseFinished = false;
    
D
dapan1121 已提交
783
    qwtBuildQueryReqMsg(&queryRpc);
D
dapan 已提交
784
    qwtPutReqToQueue((void *)0x1, &queryRpc);
D
dapan1121 已提交
785 786

    while (!qwtTestCaseFinished) {
wafwerar's avatar
wafwerar 已提交
787
      taosUsleep(1);
D
dapan1121 已提交
788 789 790
    }
    
    
D
dapan1121 已提交
791
    if (++n % qwtTestPrintNum == 0) {
D
dapan1121 已提交
792
      printf("case run:%d\n", n);
D
dapan1121 已提交
793 794 795
    }
  }

D
dapan1121 已提交
796 797
  atomic_add_fetch_32(&qwtTestQuitThreadNum, 1);

D
dapan1121 已提交
798 799
  return NULL;
}
D
dapan1121 已提交
800

D
dapan1121 已提交
801
void *queryQueueThread(void *param) {
D
dapan1121 已提交
802 803 804 805
  void *mockPointer = (void *)0x1;   
  SRpcMsg *queryRpc = NULL;
  void *mgmt = param;

D
dapan1121 已提交
806
  while (true) {
D
dapan1121 已提交
807 808
    tsem_wait(&qwtTestQuerySem);

D
dapan1121 已提交
809
    if (qwtTestStop && qwtTestQueryQueueNum <= 0 && qwtTestCaseFinished) {
D
dapan1121 已提交
810 811 812
      break;
    }

D
dapan1121 已提交
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
    taosWLockLatch(&qwtTestQueryQueueLock);
    if (qwtTestQueryQueueNum <= 0 || qwtTestQueryQueueRIdx == qwtTestQueryQueueWIdx) {
      printf("query queue is empty\n");
      assert(0);
    }
    
    queryRpc = qwtTestQueryQueue[qwtTestQueryQueueRIdx++];
    
    if (qwtTestQueryQueueRIdx >= qwtTestQueryQueueSize) {
      qwtTestQueryQueueRIdx = 0;
    }
    
    qwtTestQueryQueueNum--;
    taosWUnLockLatch(&qwtTestQueryQueueLock);

D
dapan1121 已提交
828 829

    if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
wafwerar's avatar
wafwerar 已提交
830
      int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
D
dapan1121 已提交
831 832

      if (delay) {
wafwerar's avatar
wafwerar 已提交
833
        taosUsleep(delay);
D
dapan1121 已提交
834 835 836
      }
    }
    
D
dapan1121 已提交
837
    if (TDMT_VND_QUERY == queryRpc->msgType) {
D
dapan 已提交
838
      qWorkerProcessQueryMsg(mockPointer, mgmt, queryRpc);
D
dapan1121 已提交
839
    } else if (TDMT_VND_QUERY_CONTINUE == queryRpc->msgType) {
D
dapan 已提交
840
      qWorkerProcessCQueryMsg(mockPointer, mgmt, queryRpc);
D
dapan1121 已提交
841 842 843 844
    } else {
      printf("unknown msg in query queue, type:%d\n", queryRpc->msgType);
      assert(0);
    }
D
dapan1121 已提交
845

wafwerar's avatar
wafwerar 已提交
846
    taosMemoryFree(queryRpc);
D
dapan1121 已提交
847

D
dapan1121 已提交
848
    if (qwtTestStop && qwtTestQueryQueueNum <= 0 && qwtTestCaseFinished) {
D
dapan1121 已提交
849 850
      break;
    }
D
dapan1121 已提交
851
  }
D
dapan1121 已提交
852

D
dapan1121 已提交
853 854
  atomic_add_fetch_32(&qwtTestQuitThreadNum, 1);

D
dapan 已提交
855
  return NULL;
D
dapan1121 已提交
856 857 858
}

void *fetchQueueThread(void *param) {
D
dapan1121 已提交
859 860 861 862
  void *mockPointer = (void *)0x1;   
  SRpcMsg *fetchRpc = NULL;
  void *mgmt = param;

D
dapan1121 已提交
863
  while (true) {
D
dapan1121 已提交
864 865
    tsem_wait(&qwtTestFetchSem);

D
dapan1121 已提交
866 867 868 869
    if (qwtTestStop && qwtTestFetchQueueNum <= 0 && qwtTestCaseFinished) {
      break;
    }    

D
dapan1121 已提交
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
    taosWLockLatch(&qwtTestFetchQueueLock);
    if (qwtTestFetchQueueNum <= 0 || qwtTestFetchQueueRIdx == qwtTestFetchQueueWIdx) {
      printf("Fetch queue is empty\n");
      assert(0);
    }
    
    fetchRpc = qwtTestFetchQueue[qwtTestFetchQueueRIdx++];
    
    if (qwtTestFetchQueueRIdx >= qwtTestFetchQueueSize) {
      qwtTestFetchQueueRIdx = 0;
    }
    
    qwtTestFetchQueueNum--;
    taosWUnLockLatch(&qwtTestFetchQueueLock);

D
dapan1121 已提交
885
    if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
wafwerar's avatar
wafwerar 已提交
886
      int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
D
dapan1121 已提交
887 888

      if (delay) {
wafwerar's avatar
wafwerar 已提交
889
        taosUsleep(delay);
D
dapan1121 已提交
890 891 892
      }
    }

D
dapan1121 已提交
893 894 895
    switch (fetchRpc->msgType) {
      case TDMT_VND_FETCH:
        qWorkerProcessFetchMsg(mockPointer, mgmt, fetchRpc);
D
dapan1121 已提交
896
        break;
D
dapan1121 已提交
897 898
      case TDMT_VND_RES_READY:
        qWorkerProcessReadyMsg(mockPointer, mgmt, fetchRpc);
D
dapan1121 已提交
899
        break;
D
dapan1121 已提交
900 901
      case TDMT_VND_TASKS_STATUS:
        qWorkerProcessStatusMsg(mockPointer, mgmt, fetchRpc);
D
dapan1121 已提交
902
        break;
D
dapan1121 已提交
903 904
      case TDMT_VND_CANCEL_TASK:
        qWorkerProcessCancelMsg(mockPointer, mgmt, fetchRpc);
D
dapan1121 已提交
905
        break;
D
dapan1121 已提交
906 907
      case TDMT_VND_DROP_TASK:
        qWorkerProcessDropMsg(mockPointer, mgmt, fetchRpc);
D
dapan1121 已提交
908
        break;
D
dapan1121 已提交
909 910 911
      default:
        printf("unknown msg type:%d in fetch queue", fetchRpc->msgType);
        assert(0);
D
dapan1121 已提交
912
        break;
D
dapan1121 已提交
913
    }
D
dapan1121 已提交
914

wafwerar's avatar
wafwerar 已提交
915
    taosMemoryFree(fetchRpc);
D
dapan1121 已提交
916

D
dapan1121 已提交
917
    if (qwtTestStop && qwtTestFetchQueueNum <= 0 && qwtTestCaseFinished) {
D
dapan1121 已提交
918 919
      break;
    }    
D
dapan1121 已提交
920
  }
D
dapan1121 已提交
921

D
dapan1121 已提交
922 923
  atomic_add_fetch_32(&qwtTestQuitThreadNum, 1);

D
dapan 已提交
924
  return NULL;
D
dapan1121 已提交
925 926
}

D
dapan1121 已提交
927

D
dapan1121 已提交
928 929 930 931

}


D
dapan1121 已提交
932
TEST(seqTest, normalCase) {
D
dapan 已提交
933 934 935 936 937 938 939
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;
  SRpcMsg queryRpc = {0};
  SRpcMsg readyRpc = {0};
  SRpcMsg fetchRpc = {0};
  SRpcMsg dropRpc = {0};
D
dapan1121 已提交
940
  SRpcMsg statusRpc = {0};
D
dapan1121 已提交
941 942

  qwtInitLogFile();
D
dapan 已提交
943

D
dapan1121 已提交
944 945 946 947
  qwtBuildQueryReqMsg(&queryRpc);
  qwtBuildReadyReqMsg(&qwtreadyMsg, &readyRpc);
  qwtBuildFetchReqMsg(&qwtfetchMsg, &fetchRpc);
  qwtBuildDropReqMsg(&qwtdropMsg, &dropRpc);
D
dapan1121 已提交
948
  
D
dapan 已提交
949
  stubSetStringToPlan();
D
dapan1121 已提交
950
  stubSetRpcSendResponse();
D
dapan1121 已提交
951 952 953 954 955 956 957 958 959
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();
D
dapan 已提交
960
  
X
Xiaoyu Wang 已提交
961 962 963 964
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan 已提交
965 966 967 968 969
  ASSERT_EQ(code, 0);

  code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
  ASSERT_EQ(code, 0);

D
dapan 已提交
970 971
  //code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
  //ASSERT_EQ(code, 0);
D
dapan 已提交
972 973 974 975

  code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
  ASSERT_EQ(code, 0);

D
dapan1121 已提交
976 977 978
  code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
  ASSERT_EQ(code, 0);

D
dapan1121 已提交
979
  qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
D
dapan1121 已提交
980 981 982 983 984 985 986 987 988 989 990 991 992
  code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
  ASSERT_EQ(code, 0);

  qWorkerDestroy(&mgmt);
}

TEST(seqTest, cancelFirst) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;
  SRpcMsg queryRpc = {0};
  SRpcMsg dropRpc = {0};
  SRpcMsg statusRpc = {0};
D
dapan1121 已提交
993 994

  qwtInitLogFile();
D
dapan1121 已提交
995
  
D
dapan1121 已提交
996 997 998
  qwtBuildQueryReqMsg(&queryRpc);
  qwtBuildDropReqMsg(&qwtdropMsg, &dropRpc);
  qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
D
dapan1121 已提交
999 1000 1001 1002

  stubSetStringToPlan();
  stubSetRpcSendResponse();
  
X
Xiaoyu Wang 已提交
1003 1004 1005 1006
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1007 1008
  ASSERT_EQ(code, 0);

D
dapan1121 已提交
1009
  qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
D
dapan1121 已提交
1010 1011 1012
  code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
  ASSERT_EQ(code, 0);

D
dapan 已提交
1013 1014
  code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
  ASSERT_EQ(code, 0);
D
dapan1121 已提交
1015

D
dapan1121 已提交
1016
  qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
D
dapan1121 已提交
1017 1018 1019 1020
  code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
  ASSERT_EQ(code, 0);

  code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
D
dapan1121 已提交
1021
  ASSERT_TRUE(0 != code);
D
dapan1121 已提交
1022

D
dapan1121 已提交
1023
  qwtBuildStatusReqMsg(&qwtstatusMsg, &statusRpc);
D
dapan1121 已提交
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038
  code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
  ASSERT_EQ(code, 0);

  qWorkerDestroy(&mgmt);
}

TEST(seqTest, randCase) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;
  SRpcMsg queryRpc = {0};
  SRpcMsg readyRpc = {0};
  SRpcMsg fetchRpc = {0};
  SRpcMsg dropRpc = {0};
  SRpcMsg statusRpc = {0};
S
Shengliang Guan 已提交
1039 1040 1041 1042
  SResReadyReq readyMsg = {0};
  SResFetchReq fetchMsg = {0};
  STaskDropReq dropMsg = {0};  
  SSchTasksStatusReq statusMsg = {0};
D
dapan1121 已提交
1043 1044

  qwtInitLogFile();
D
dapan1121 已提交
1045 1046 1047
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
D
dapan1121 已提交
1048
  stubSetCreateExecTask();
D
dapan1121 已提交
1049

wafwerar's avatar
wafwerar 已提交
1050
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1051
  
X
Xiaoyu Wang 已提交
1052 1053 1054 1055
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1056 1057 1058 1059 1060
  ASSERT_EQ(code, 0);

  int32_t t = 0;
  int32_t maxr = 10001;
  while (true) {
wafwerar's avatar
wafwerar 已提交
1061
    int32_t r = taosRand() % maxr;
D
dapan1121 已提交
1062 1063
    
    if (r >= 0 && r < maxr/5) {
D
dapan1121 已提交
1064 1065
      printf("Query,%d\n", t++);      
      qwtBuildQueryReqMsg(&queryRpc);
D
dapan1121 已提交
1066 1067
      code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
    } else if (r >= maxr/5 && r < maxr * 2/5) {
D
dapan 已提交
1068 1069 1070 1071 1072 1073
      //printf("Ready,%d\n", t++);
      //qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
      //code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
      //if (qwtTestEnableSleep) {
      //  taosUsleep(1);
      //}
D
dapan1121 已提交
1074 1075
    } else if (r >= maxr * 2/5 && r < maxr* 3/5) {
      printf("Fetch,%d\n", t++);
D
dapan1121 已提交
1076
      qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
D
dapan1121 已提交
1077
      code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
D
dapan1121 已提交
1078
      if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
1079
        taosUsleep(1);
D
dapan1121 已提交
1080
      }
D
dapan1121 已提交
1081 1082
    } else if (r >= maxr * 3/5 && r < maxr * 4/5) {
      printf("Drop,%d\n", t++);
D
dapan1121 已提交
1083
      qwtBuildDropReqMsg(&dropMsg, &dropRpc);
D
dapan1121 已提交
1084
      code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
D
dapan1121 已提交
1085
      if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
1086
        taosUsleep(1);
D
dapan1121 已提交
1087
      }
D
dapan1121 已提交
1088 1089
    } else if (r >= maxr * 4/5 && r < maxr-1) {
      printf("Status,%d\n", t++);
D
dapan1121 已提交
1090
      qwtBuildStatusReqMsg(&statusMsg, &statusRpc);
D
dapan1121 已提交
1091 1092
      code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
      ASSERT_EQ(code, 0);
D
dapan1121 已提交
1093
      if (qwtTestEnableSleep) {
wafwerar's avatar
wafwerar 已提交
1094
        taosUsleep(1);
D
dapan1121 已提交
1095
      }      
D
dapan1121 已提交
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
    } else {
      printf("QUIT RAND NOW");
      break;
    }
  }

  qWorkerDestroy(&mgmt);
}

TEST(seqTest, multithreadRand) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;
D
dapan1121 已提交
1109 1110

  qwtInitLogFile();
D
dapan1121 已提交
1111 1112 1113
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
D
dapan1121 已提交
1114 1115 1116 1117 1118 1119 1120 1121 1122
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();
D
dapan1121 已提交
1123

wafwerar's avatar
wafwerar 已提交
1124
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1125
  
X
Xiaoyu Wang 已提交
1126 1127 1128 1129
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1130 1131
  ASSERT_EQ(code, 0);

wafwerar's avatar
wafwerar 已提交
1132 1133
  TdThreadAttr thattr;
  taosThreadAttrInit(&thattr);
D
dapan1121 已提交
1134

X
Xiaoyu Wang 已提交
1135
  TdThread t1,t2,t3,t4,t5,t6;
wafwerar's avatar
wafwerar 已提交
1136
  taosThreadCreate(&(t1), &thattr, queryThread, mgmt);
1137
  //taosThreadCreate(&(t2), &thattr, readyThread, NULL);
wafwerar's avatar
wafwerar 已提交
1138 1139 1140
  taosThreadCreate(&(t3), &thattr, fetchThread, NULL);
  taosThreadCreate(&(t4), &thattr, dropThread, NULL);
  taosThreadCreate(&(t5), &thattr, statusThread, NULL);
X
Xiaoyu Wang 已提交
1141
  taosThreadCreate(&(t6), &thattr, fetchQueueThread, mgmt);
D
dapan1121 已提交
1142

D
dapan1121 已提交
1143 1144
  while (true) {
    if (qwtTestDeadLoop) {
wafwerar's avatar
wafwerar 已提交
1145
      taosSsleep(1);
D
dapan1121 已提交
1146
    } else {
wafwerar's avatar
wafwerar 已提交
1147
      taosSsleep(qwtTestMTRunSec);
D
dapan1121 已提交
1148 1149 1150 1151 1152
      break;
    }
  }
  
  qwtTestStop = true;
wafwerar's avatar
wafwerar 已提交
1153
  taosSsleep(3);
D
dapan1121 已提交
1154 1155 1156 1157 1158 1159 1160 1161 1162

  qwtTestQueryQueueNum = 0;
  qwtTestQueryQueueRIdx = 0;
  qwtTestQueryQueueWIdx = 0;
  qwtTestQueryQueueLock = 0;
  qwtTestFetchQueueNum = 0;
  qwtTestFetchQueueRIdx = 0;
  qwtTestFetchQueueWIdx = 0;
  qwtTestFetchQueueLock = 0;
D
dapan1121 已提交
1163 1164 1165 1166
  
  qWorkerDestroy(&mgmt);
}

D
dapan1121 已提交
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
TEST(rcTest, shortExecshortDelay) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;

  qwtInitLogFile();
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();

wafwerar's avatar
wafwerar 已提交
1186
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1187 1188 1189
  qwtTestStop = false;
  qwtTestQuitThreadNum = 0;

S
Shengliang Guan 已提交
1190 1191 1192 1193
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1194 1195 1196 1197 1198 1199 1200 1201
  ASSERT_EQ(code, 0);

  qwtTestMaxExecTaskUsec = 0;
  qwtTestReqMaxDelayUsec = 0;

  tsem_init(&qwtTestQuerySem, 0, 0);
  tsem_init(&qwtTestFetchSem, 0, 0);

wafwerar's avatar
wafwerar 已提交
1202 1203
  TdThreadAttr thattr;
  taosThreadAttrInit(&thattr);
D
dapan1121 已提交
1204

wafwerar's avatar
wafwerar 已提交
1205 1206 1207 1208
  TdThread t1,t2,t3,t4,t5;
  taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
  taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
  taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
D
dapan1121 已提交
1209 1210 1211

  while (true) {
    if (qwtTestDeadLoop) {
wafwerar's avatar
wafwerar 已提交
1212
      taosSsleep(1);
D
dapan1121 已提交
1213
    } else {
wafwerar's avatar
wafwerar 已提交
1214
      taosSsleep(qwtTestMTRunSec);
D
dapan1121 已提交
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225
      break;
    }
  }
  
  qwtTestStop = true;

  while (true) {
    if (qwtTestQuitThreadNum == 3) {
      break;
    }
    
wafwerar's avatar
wafwerar 已提交
1226
    taosSsleep(1);
D
dapan1121 已提交
1227 1228 1229 1230 1231 1232

    if (qwtTestCaseFinished) {
      if (qwtTestQuitThreadNum < 3) { 
        tsem_post(&qwtTestQuerySem);
        tsem_post(&qwtTestFetchSem);

wafwerar's avatar
wafwerar 已提交
1233
        taosUsleep(10);
D
dapan1121 已提交
1234 1235
      }
    }
D
dapan1121 已提交
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
    
  }

  qwtTestQueryQueueNum = 0;
  qwtTestQueryQueueRIdx = 0;
  qwtTestQueryQueueWIdx = 0;
  qwtTestQueryQueueLock = 0;
  qwtTestFetchQueueNum = 0;
  qwtTestFetchQueueRIdx = 0;
  qwtTestFetchQueueWIdx = 0;
  qwtTestFetchQueueLock = 0;
  
  qWorkerDestroy(&mgmt);  
}

TEST(rcTest, longExecshortDelay) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;

  qwtInitLogFile();
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();

wafwerar's avatar
wafwerar 已提交
1270
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1271 1272 1273
  qwtTestStop = false;
  qwtTestQuitThreadNum = 0;

S
Shengliang Guan 已提交
1274 1275 1276 1277
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1278 1279 1280 1281 1282 1283 1284 1285
  ASSERT_EQ(code, 0);

  qwtTestMaxExecTaskUsec = 1000000;
  qwtTestReqMaxDelayUsec = 0;

  tsem_init(&qwtTestQuerySem, 0, 0);
  tsem_init(&qwtTestFetchSem, 0, 0);

wafwerar's avatar
wafwerar 已提交
1286 1287
  TdThreadAttr thattr;
  taosThreadAttrInit(&thattr);
D
dapan1121 已提交
1288

wafwerar's avatar
wafwerar 已提交
1289 1290 1291 1292
  TdThread t1,t2,t3,t4,t5;
  taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
  taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
  taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
D
dapan1121 已提交
1293 1294 1295

  while (true) {
    if (qwtTestDeadLoop) {
wafwerar's avatar
wafwerar 已提交
1296
      taosSsleep(1);
D
dapan1121 已提交
1297
    } else {
wafwerar's avatar
wafwerar 已提交
1298
      taosSsleep(qwtTestMTRunSec);
D
dapan1121 已提交
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
      break;
    }
  }
  
  qwtTestStop = true;

 
  while (true) {
    if (qwtTestQuitThreadNum == 3) {
      break;
    }
    
wafwerar's avatar
wafwerar 已提交
1311
    taosSsleep(1);
D
dapan1121 已提交
1312 1313 1314 1315 1316 1317

    if (qwtTestCaseFinished) {
      if (qwtTestQuitThreadNum < 3) { 
        tsem_post(&qwtTestQuerySem);
        tsem_post(&qwtTestFetchSem);
        
wafwerar's avatar
wafwerar 已提交
1318
        taosUsleep(10);
D
dapan1121 已提交
1319 1320
      }
    }
D
dapan1121 已提交
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
    
  }

  qwtTestQueryQueueNum = 0;
  qwtTestQueryQueueRIdx = 0;
  qwtTestQueryQueueWIdx = 0;
  qwtTestQueryQueueLock = 0;
  qwtTestFetchQueueNum = 0;
  qwtTestFetchQueueRIdx = 0;
  qwtTestFetchQueueWIdx = 0;
  qwtTestFetchQueueLock = 0;
  
  qWorkerDestroy(&mgmt);
}


TEST(rcTest, shortExeclongDelay) {
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;

  qwtInitLogFile();
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();

wafwerar's avatar
wafwerar 已提交
1356
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1357 1358 1359
  qwtTestStop = false;
  qwtTestQuitThreadNum = 0;

S
Shengliang Guan 已提交
1360 1361 1362 1363
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1364 1365 1366 1367 1368 1369 1370 1371
  ASSERT_EQ(code, 0);

  qwtTestMaxExecTaskUsec = 0;
  qwtTestReqMaxDelayUsec = 1000000;

  tsem_init(&qwtTestQuerySem, 0, 0);
  tsem_init(&qwtTestFetchSem, 0, 0);

wafwerar's avatar
wafwerar 已提交
1372 1373
  TdThreadAttr thattr;
  taosThreadAttrInit(&thattr);
D
dapan1121 已提交
1374

wafwerar's avatar
wafwerar 已提交
1375 1376 1377 1378
  TdThread t1,t2,t3,t4,t5;
  taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
  taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
  taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
D
dapan1121 已提交
1379 1380 1381

  while (true) {
    if (qwtTestDeadLoop) {
wafwerar's avatar
wafwerar 已提交
1382
      taosSsleep(1);
D
dapan1121 已提交
1383
    } else {
wafwerar's avatar
wafwerar 已提交
1384
      taosSsleep(qwtTestMTRunSec);
D
dapan1121 已提交
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
      break;
    }
  }
  
  qwtTestStop = true;


  while (true) {
    if (qwtTestQuitThreadNum == 3) {
      break;
    }
    
wafwerar's avatar
wafwerar 已提交
1397
    taosSsleep(1);
D
dapan1121 已提交
1398 1399 1400 1401 1402 1403

    if (qwtTestCaseFinished) {
      if (qwtTestQuitThreadNum < 3) { 
        tsem_post(&qwtTestQuerySem);
        tsem_post(&qwtTestFetchSem);
        
wafwerar's avatar
wafwerar 已提交
1404
        taosUsleep(10);
D
dapan1121 已提交
1405 1406
      }
    }
D
dapan1121 已提交
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423
    
  }

  qwtTestQueryQueueNum = 0;
  qwtTestQueryQueueRIdx = 0;
  qwtTestQueryQueueWIdx = 0;
  qwtTestQueryQueueLock = 0;
  qwtTestFetchQueueNum = 0;
  qwtTestFetchQueueRIdx = 0;
  qwtTestFetchQueueWIdx = 0;
  qwtTestFetchQueueLock = 0;
  
  qWorkerDestroy(&mgmt);
}


TEST(rcTest, dropTest) {
D
dapan1121 已提交
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441
  void *mgmt = NULL;
  int32_t code = 0;
  void *mockPointer = (void *)0x1;

  qwtInitLogFile();
  
  stubSetStringToPlan();
  stubSetRpcSendResponse();
  stubSetExecTask();
  stubSetCreateExecTask();
  stubSetAsyncKillTask();
  stubSetDestroyTask();
  stubSetDestroyDataSinker();
  stubSetGetDataLength();
  stubSetEndPut();
  stubSetPutDataBlock();
  stubSetGetDataBlock();

wafwerar's avatar
wafwerar 已提交
1442
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1443
  
X
Xiaoyu Wang 已提交
1444 1445 1446 1447
  SMsgCb msgCb = {0};
  msgCb.pWrapper = (struct SMgmtWrapper *)mockPointer;
  msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)qwtPutReqToQueue;
  code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, &msgCb);
D
dapan1121 已提交
1448 1449
  ASSERT_EQ(code, 0);

D
dapan1121 已提交
1450 1451 1452
  tsem_init(&qwtTestQuerySem, 0, 0);
  tsem_init(&qwtTestFetchSem, 0, 0);

wafwerar's avatar
wafwerar 已提交
1453 1454
  TdThreadAttr thattr;
  taosThreadAttrInit(&thattr);
D
dapan1121 已提交
1455

wafwerar's avatar
wafwerar 已提交
1456
  TdThread t1,t2,t3,t4,t5;
X
Xiaoyu Wang 已提交
1457
  taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt);
wafwerar's avatar
wafwerar 已提交
1458 1459
  taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt);
  taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt);
D
dapan1121 已提交
1460 1461 1462

  while (true) {
    if (qwtTestDeadLoop) {
wafwerar's avatar
wafwerar 已提交
1463
      taosSsleep(1);
D
dapan1121 已提交
1464
    } else {
wafwerar's avatar
wafwerar 已提交
1465
      taosSsleep(qwtTestMTRunSec);
D
dapan1121 已提交
1466 1467 1468 1469 1470
      break;
    }
  }
  
  qwtTestStop = true;
wafwerar's avatar
wafwerar 已提交
1471
  taosSsleep(3);
D
dapan1121 已提交
1472
  
D
dapan1121 已提交
1473
  qWorkerDestroy(&mgmt);
D
dapan 已提交
1474 1475
}

D
dapan1121 已提交
1476

D
dapan1121 已提交
1477
int main(int argc, char** argv) {
wafwerar's avatar
wafwerar 已提交
1478
  taosSeedRand(taosGetTimestampSec());
D
dapan1121 已提交
1479 1480 1481 1482
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

D
dapan1121 已提交
1483
#pragma GCC diagnostic pop