提交 34b08b7b 编写于 作者: S Shengliang Guan

fix: improve test coverage

上级 1d93dcb3
......@@ -161,10 +161,6 @@ typedef struct {
SMonLogs log;
} SMonMmInfo;
int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo);
int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo);
void tFreeSMonMmInfo(SMonMmInfo *pInfo);
typedef struct {
SArray *datadirs; // array of SMonDiskDesc
} SMonDiskInfo;
......@@ -176,56 +172,31 @@ typedef struct {
SMonLogs log;
} SMonVmInfo;
int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo);
int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo);
void tFreeSMonVmInfo(SMonVmInfo *pInfo);
typedef struct {
SMonSysInfo sys;
SMonLogs log;
SQnodeLoad load;
} SMonQmInfo;
int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo);
int32_t tDeserializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo);
void tFreeSMonQmInfo(SMonQmInfo *pInfo);
typedef struct {
SMonSysInfo sys;
SMonLogs log;
} SMonSmInfo;
int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo);
int32_t tDeserializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo);
void tFreeSMonSmInfo(SMonSmInfo *pInfo);
typedef struct {
SMonSysInfo sys;
SMonLogs log;
} SMonBmInfo;
int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo);
int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo);
void tFreeSMonBmInfo(SMonBmInfo *pInfo);
typedef struct {
SArray *pVloads; // SVnodeLoad
} SMonVloadInfo;
int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo);
int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo);
void tFreeSMonVloadInfo(SMonVloadInfo *pInfo);
typedef struct {
int8_t isMnode;
SMnodeLoad load;
} SMonMloadInfo;
int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo);
int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo);
int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo);
int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo);
typedef struct {
const char *server;
uint16_t port;
......@@ -245,6 +216,12 @@ void monSetSmInfo(SMonSmInfo *pInfo);
void monSetBmInfo(SMonBmInfo *pInfo);
void monSendReport();
void tFreeSMonMmInfo(SMonMmInfo *pInfo);
void tFreeSMonVmInfo(SMonVmInfo *pInfo);
void tFreeSMonQmInfo(SMonQmInfo *pInfo);
void tFreeSMonSmInfo(SMonSmInfo *pInfo);
void tFreeSMonBmInfo(SMonBmInfo *pInfo);
#ifdef __cplusplus
}
#endif
......
......@@ -450,17 +450,10 @@ static void monGenDiskJson(SMonInfo *pMonitor) {
}
static const char *monLogLevelStr(ELogLevel level) {
switch (level) {
case DEBUG_ERROR:
return "error";
case DEBUG_INFO:
return "info";
case DEBUG_DEBUG:
return "debug";
case DEBUG_TRACE:
return "trace";
default:
return "undefine";
if (level == DEBUG_ERROR) {
return "error";
} else {
return "info";
}
}
......
此差异已折叠。
......@@ -298,9 +298,6 @@ int32_t taosGetQitem(STaosQall *qall, void **ppItem) {
return num;
}
void taosResetQitems(STaosQall *qall) { qall->current = qall->start; }
int32_t taosQallItemSize(STaosQall *qall) { return qall->numOfItems; }
STaosQset *taosOpenQset() {
STaosQset *qset = taosMemoryCalloc(sizeof(STaosQset), 1);
if (qset == NULL) {
......@@ -405,8 +402,6 @@ void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) {
uDebug("queue:%p is removed from qset:%p", queue, qset);
}
int32_t taosGetQueueNumber(STaosQset *qset) { return qset->numOfQueues; }
int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) {
STaosQnode *pNode = NULL;
int32_t code = 0;
......@@ -497,6 +492,12 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *
return code;
}
int32_t taosQallItemSize(STaosQall *qall) { return qall->numOfItems; }
#if 0
int32_t taosGetQueueNumber(STaosQset *qset) { return qset->numOfQueues; }
void taosResetQitems(STaosQall *qall) { qall->current = qall->start; }
void taosResetQsetThread(STaosQset *qset, void *pItem) {
if (pItem == NULL) return;
STaosQnode *pNode = (STaosQnode *)((char *)pItem - sizeof(STaosQnode));
......@@ -507,3 +508,5 @@ void taosResetQsetThread(STaosQset *qset, void *pItem) {
}
taosThreadMutexUnlock(&qset->mutex);
}
#endif
......@@ -28,10 +28,7 @@ int32_t tQWorkerInit(SQWorkerPool *pool) {
return -1;
}
if (taosThreadMutexInit(&pool->mutex, NULL)) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
(void)taosThreadMutexInit(&pool->mutex, NULL);
for (int32_t i = 0; i < pool->max; ++i) {
SQWorker *worker = pool->workers + i;
......@@ -97,14 +94,10 @@ static void *tQWorkerThreadFp(SQWorker *worker) {
}
STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) {
taosThreadMutexLock(&pool->mutex);
STaosQueue *queue = taosOpenQueue();
if (queue == NULL) {
taosThreadMutexUnlock(&pool->mutex);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
if (queue == NULL) return NULL;
taosThreadMutexLock(&pool->mutex);
taosSetQueueFp(queue, fp, NULL);
taosAddIntoQset(pool->qset, queue, ahandle);
......@@ -118,7 +111,6 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) {
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tQWorkerThreadFp, worker) != 0) {
uError("worker:%s:%d failed to create thread to process since %s", pool->name, worker->id, strerror(errno));
taosCloseQueue(queue);
terrno = TSDB_CODE_OUT_OF_MEMORY;
queue = NULL;
......@@ -150,10 +142,7 @@ int32_t tWWorkerInit(SWWorkerPool *pool) {
return -1;
}
if (taosThreadMutexInit(&pool->mutex, NULL) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
(void)taosThreadMutexInit(&pool->mutex, NULL);
for (int32_t i = 0; i < pool->max; ++i) {
SWWorker *worker = pool->workers + i;
......@@ -225,48 +214,27 @@ static void *tWWorkerThreadFp(SWWorker *worker) {
STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) {
taosThreadMutexLock(&pool->mutex);
SWWorker *worker = pool->workers + pool->nextId;
int32_t code = -1;
STaosQueue *queue = taosOpenQueue();
if (queue == NULL) {
taosThreadMutexUnlock(&pool->mutex);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
if (queue == NULL) goto _OVER;
taosSetQueueFp(queue, NULL, fp);
if (worker->qset == NULL) {
worker->qset = taosOpenQset();
if (worker->qset == NULL) {
taosCloseQueue(queue);
taosThreadMutexUnlock(&pool->mutex);
return NULL;
}
if (worker->qset == NULL) goto _OVER;
taosAddIntoQset(worker->qset, queue, ahandle);
worker->qall = taosAllocateQall();
if (worker->qall == NULL) {
taosCloseQset(worker->qset);
taosCloseQueue(queue);
taosThreadMutexUnlock(&pool->mutex);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
if (worker->qall == NULL) goto _OVER;
TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tWWorkerThreadFp, worker) != 0) goto _OVER;
if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tWWorkerThreadFp, worker) != 0) {
uError("worker:%s:%d failed to create thread to process since %s", pool->name, worker->id, strerror(errno));
taosFreeQall(worker->qall);
taosCloseQset(worker->qset);
taosCloseQueue(queue);
terrno = TSDB_CODE_OUT_OF_MEMORY;
queue = NULL;
} else {
uDebug("worker:%s:%d is launched, max:%d", pool->name, worker->id, pool->max);
pool->nextId = (pool->nextId + 1) % pool->max;
}
uDebug("worker:%s:%d is launched, max:%d", pool->name, worker->id, pool->max);
pool->nextId = (pool->nextId + 1) % pool->max;
taosThreadAttrDestroy(&thAttr);
pool->num++;
......@@ -276,10 +244,19 @@ STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) {
pool->nextId = (pool->nextId + 1) % pool->max;
}
taosThreadMutexUnlock(&pool->mutex);
uDebug("worker:%s, queue:%p is allocated, ahandle:%p", pool->name, queue, ahandle);
return queue;
_OVER:
taosThreadMutexUnlock(&pool->mutex);
if (code == -1) {
if (queue != NULL) taosCloseQueue(queue);
if (worker->qset != NULL) taosCloseQset(worker->qset);
if (worker->qall != NULL) taosFreeQall(worker->qall);
return NULL;
} else {
return queue;
}
}
void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue) {
......@@ -292,15 +269,11 @@ int32_t tSingleWorkerInit(SSingleWorker *pWorker, const SSingleWorkerCfg *pCfg)
pPool->name = pCfg->name;
pPool->min = pCfg->min;
pPool->max = pCfg->max;
if (tQWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (tQWorkerInit(pPool) != 0) return -1;
pWorker->queue = tQWorkerAllocQueue(pPool, pCfg->param, pCfg->fp);
if (pWorker->queue == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (pWorker->queue == NULL) return -1;
pWorker->name = pCfg->name;
return 0;
}
......@@ -320,15 +293,11 @@ int32_t tMultiWorkerInit(SMultiWorker *pWorker, const SMultiWorkerCfg *pCfg) {
SWWorkerPool *pPool = &pWorker->pool;
pPool->name = pCfg->name;
pPool->max = pCfg->max;
if (tWWorkerInit(pPool) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (tWWorkerInit(pPool) != 0) return -1;
pWorker->queue = tWWorkerAllocQueue(pPool, pCfg->param, pCfg->fp);
if (pWorker->queue == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
if (pWorker->queue == NULL) return -1;
pWorker->name = pCfg->name;
return 0;
}
......
......@@ -294,6 +294,10 @@ class TDTestCase:
vgroups = "30"
sql = "create database db3 vgroups " + vgroups
tdSql.query(sql)
sql = "create table db3.stb (ts timestamp, f int) tags (t int)"
tdSql.query(sql)
sql = "create table db3.tb using db3.stb tags (1)"
tdSql.query(sql)
# create http server: bing ip/port , and request processor
if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册