add test case
This commit is contained in:
parent
c52f064670
commit
c54e4aeaad
|
@ -76,8 +76,8 @@ char* idxInt2str(int64_t val, char* dst, int radix) {
|
|||
return dst - 1;
|
||||
}
|
||||
__compar_fn_t idxGetCompar(int8_t type) {
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_NCHAR ||
|
||||
type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
return (__compar_fn_t)strcmp;
|
||||
}
|
||||
return getComparFunc(type, 0);
|
||||
|
@ -108,8 +108,8 @@ static FORCE_INLINE TExeCond tCompareEqual(void* a, void* b, int8_t type) {
|
|||
return tCompare(func, QUERY_TERM, a, b, type);
|
||||
}
|
||||
TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t dtype) {
|
||||
if (dtype == TSDB_DATA_TYPE_BINARY || dtype == TSDB_DATA_TYPE_NCHAR ||
|
||||
dtype == TSDB_DATA_TYPE_VARBINARY || dtype == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (dtype == TSDB_DATA_TYPE_BINARY || dtype == TSDB_DATA_TYPE_NCHAR || dtype == TSDB_DATA_TYPE_VARBINARY ||
|
||||
dtype == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
return tDoCompare(func, cmptype, a, b);
|
||||
}
|
||||
#if 1
|
||||
|
@ -290,6 +290,7 @@ int idxUidCompare(const void* a, const void* b) {
|
|||
uint64_t r = *(uint64_t*)b;
|
||||
return l - r;
|
||||
}
|
||||
#ifdef BUILD_NO_CALL
|
||||
int32_t idxConvertData(void* src, int8_t type, void** dst) {
|
||||
int tlen = -1;
|
||||
switch (type) {
|
||||
|
@ -372,6 +373,8 @@ int32_t idxConvertData(void* src, int8_t type, void** dst) {
|
|||
// indexMayFillNumbericData(*dst, tlen);
|
||||
return tlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) {
|
||||
if (src == NULL) {
|
||||
*dst = strndup(INDEX_DATA_NULL_STR, (int)strlen(INDEX_DATA_NULL_STR));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#define _STREAM_BACKEDN_ROCKSDB_H_
|
||||
|
||||
#include "rocksdb/c.h"
|
||||
//#include "streamInt.h"
|
||||
// #include "streamInt.h"
|
||||
#include "streamState.h"
|
||||
#include "tcommon.h"
|
||||
|
||||
|
@ -244,11 +244,6 @@ int32_t streamBackendDelInUseChkp(void* arg, int64_t chkpId);
|
|||
|
||||
int32_t taskDbBuildSnap(void* arg, SArray* pSnap);
|
||||
|
||||
// int32_t streamDefaultIter_rocksdb(SStreamState* pState, const void* start, const void* end, SArray* result);
|
||||
|
||||
// STaskDbWrapper* taskDbOpen(char* path, char* key, int64_t chkpId);
|
||||
// void taskDbDestroy(void* pDb, bool flush);
|
||||
|
||||
int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId);
|
||||
|
||||
SBkdMgt* bkdMgtCreate(char* path);
|
||||
|
|
|
@ -70,7 +70,7 @@ static void streamMetaEnvInit() {
|
|||
streamTimerInit();
|
||||
}
|
||||
|
||||
void streamMetaInit() { taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit);}
|
||||
void streamMetaInit() { taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); }
|
||||
|
||||
void streamMetaCleanup() {
|
||||
taosCloseRef(streamBackendId);
|
||||
|
@ -1104,14 +1104,14 @@ static int32_t metaHeartbeatToMnodeImpl(SStreamMeta* pMeta) {
|
|||
.inputQUsed = SIZE_IN_MiB(streamQueueGetItemSize((*pTask)->inputq.queue)),
|
||||
};
|
||||
|
||||
entry.inputRate = entry.inputQUsed * 100.0 / (2*STREAM_TASK_QUEUE_CAPACITY_IN_SIZE);
|
||||
entry.inputRate = entry.inputQUsed * 100.0 / (2 * STREAM_TASK_QUEUE_CAPACITY_IN_SIZE);
|
||||
if ((*pTask)->info.taskLevel == TASK_LEVEL__SINK) {
|
||||
entry.sinkQuota = (*pTask)->outputInfo.pTokenBucket->quotaRate;
|
||||
entry.sinkDataSize = SIZE_IN_MiB((*pTask)->execInfo.sink.dataSize);
|
||||
}
|
||||
|
||||
if ((*pTask)->chkInfo.checkpointingId != 0) {
|
||||
entry.checkpointFailed = ((*pTask)->chkInfo.failedId >= (*pTask)->chkInfo.checkpointingId)? 1:0;
|
||||
entry.checkpointFailed = ((*pTask)->chkInfo.failedId >= (*pTask)->chkInfo.checkpointingId) ? 1 : 0;
|
||||
entry.checkpointId = (*pTask)->chkInfo.checkpointingId;
|
||||
entry.chkpointTransId = (*pTask)->chkInfo.transId;
|
||||
|
||||
|
@ -1172,7 +1172,7 @@ static int32_t metaHeartbeatToMnodeImpl(SStreamMeta* pMeta) {
|
|||
stDebug("vgId:%d no tasks and no mnd epset, not send stream hb to mnode", pMeta->vgId);
|
||||
}
|
||||
|
||||
_end:
|
||||
_end:
|
||||
streamMetaClearHbMsg(&hbMsg);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1304,28 +1304,28 @@ void streamMetaResetStartInfo(STaskStartInfo* pStartInfo) {
|
|||
}
|
||||
|
||||
void streamMetaRLock(SStreamMeta* pMeta) {
|
||||
// stTrace("vgId:%d meta-rlock", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-rlock", pMeta->vgId);
|
||||
taosThreadRwlockRdlock(&pMeta->lock);
|
||||
}
|
||||
|
||||
void streamMetaRUnLock(SStreamMeta* pMeta) {
|
||||
// stTrace("vgId:%d meta-runlock", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-runlock", pMeta->vgId);
|
||||
int32_t code = taosThreadRwlockUnlock(&pMeta->lock);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
stError("vgId:%d meta-runlock failed, code:%d", pMeta->vgId, code);
|
||||
} else {
|
||||
// stTrace("vgId:%d meta-runlock completed", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-runlock completed", pMeta->vgId);
|
||||
}
|
||||
}
|
||||
|
||||
void streamMetaWLock(SStreamMeta* pMeta) {
|
||||
// stTrace("vgId:%d meta-wlock", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-wlock", pMeta->vgId);
|
||||
taosThreadRwlockWrlock(&pMeta->lock);
|
||||
// stTrace("vgId:%d meta-wlock completed", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-wlock completed", pMeta->vgId);
|
||||
}
|
||||
|
||||
void streamMetaWUnLock(SStreamMeta* pMeta) {
|
||||
// stTrace("vgId:%d meta-wunlock", pMeta->vgId);
|
||||
// stTrace("vgId:%d meta-wunlock", pMeta->vgId);
|
||||
taosThreadRwlockUnlock(&pMeta->lock);
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ void streamMetaUpdateStageRole(SStreamMeta* pMeta, int64_t stage, bool isLeader)
|
|||
pMeta->sendMsgBeforeClosing = true;
|
||||
}
|
||||
|
||||
pMeta->role = (isLeader)? NODE_ROLE_LEADER:NODE_ROLE_FOLLOWER;
|
||||
pMeta->role = (isLeader) ? NODE_ROLE_LEADER : NODE_ROLE_FOLLOWER;
|
||||
streamMetaWUnLock(pMeta);
|
||||
|
||||
if (isLeader) {
|
||||
|
@ -1531,8 +1531,8 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) {
|
|||
|
||||
bool streamMetaAllTasksReady(const SStreamMeta* pMeta) {
|
||||
int32_t num = taosArrayGetSize(pMeta->pTaskList);
|
||||
for(int32_t i = 0; i < num; ++i) {
|
||||
STaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
STaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
||||
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, pTaskId, sizeof(*pTaskId));
|
||||
if (ppTask == NULL) {
|
||||
continue;
|
||||
|
@ -1633,7 +1633,7 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int3
|
|||
pStartInfo->elapsedTime = (pStartInfo->startTs != 0) ? pStartInfo->readyTs - pStartInfo->startTs : 0;
|
||||
|
||||
stDebug("vgId:%d all %d task(s) check downstream completed, last completed task:0x%x (succ:%d) startTs:%" PRId64
|
||||
", readyTs:%" PRId64 " total elapsed time:%.2fs",
|
||||
", readyTs:%" PRId64 " total elapsed time:%.2fs",
|
||||
pMeta->vgId, numOfTotal, taskId, ready, pStartInfo->startTs, pStartInfo->readyTs,
|
||||
pStartInfo->elapsedTime / 1000.0);
|
||||
|
||||
|
|
|
@ -1,40 +1,82 @@
|
|||
|
||||
MESSAGE(STATUS "build stream unit test")
|
||||
|
||||
# GoogleTest requires at least C++11
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||
|
||||
# bloomFilterTest
|
||||
ADD_EXECUTABLE(streamUpdateTest "tstreamUpdateTest.cpp")
|
||||
|
||||
TARGET_LINK_LIBRARIES(streamUpdateTest
|
||||
PUBLIC os util common gtest gtest_main stream executor index
|
||||
)
|
||||
#TARGET_LINK_LIBRARIES(streamUpdateTest
|
||||
#PUBLIC os util common gtest gtest_main stream executor index
|
||||
#)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
streamUpdateTest
|
||||
#TARGET_INCLUDE_DIRECTORIES(
|
||||
#streamUpdateTest
|
||||
#PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
||||
#PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||
#)
|
||||
|
||||
#ADD_EXECUTABLE(checkpointTest checkpointTest.cpp)
|
||||
#TARGET_LINK_LIBRARIES(
|
||||
#checkpointTest
|
||||
#PUBLIC os common gtest stream executor qcom index transport util
|
||||
#)
|
||||
|
||||
#TARGET_INCLUDE_DIRECTORIES(
|
||||
#checkpointTest
|
||||
#PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||
#)
|
||||
|
||||
#add_executable(backendTest "")
|
||||
|
||||
#target_sources(backendTest
|
||||
#PRIVATE
|
||||
#"backendTest.cpp"
|
||||
#)
|
||||
|
||||
#TARGET_LINK_LIBRARIES(
|
||||
#backendTest
|
||||
#PUBLIC rocksdb
|
||||
#PUBLIC os common gtest stream executor qcom index transport util
|
||||
#)
|
||||
|
||||
#TARGET_INCLUDE_DIRECTORIES(
|
||||
#backendTest
|
||||
#PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
||||
#PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||
#)
|
||||
|
||||
#add_test(
|
||||
#NAME streamUpdateTest
|
||||
#COMMAND streamUpdateTest
|
||||
#)
|
||||
|
||||
#add_test(
|
||||
#NAME checkpointTest
|
||||
#COMMAND checkpointTest
|
||||
#)
|
||||
#add_test(
|
||||
#NAME backendTest
|
||||
#COMMAND backendTest
|
||||
#)
|
||||
|
||||
|
||||
add_executable(backendTest "")
|
||||
|
||||
target_sources(backendTest
|
||||
PRIVATE
|
||||
"backendTest.cpp"
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
backendTest
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(checkpointTest checkpointTest.cpp)
|
||||
TARGET_LINK_LIBRARIES(
|
||||
checkpointTest
|
||||
target_link_libraries(
|
||||
backendTest
|
||||
PUBLIC rocksdb
|
||||
PUBLIC os common gtest stream executor qcom index transport util
|
||||
)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
checkpointTest
|
||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME streamUpdateTest
|
||||
COMMAND streamUpdateTest
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME checkpointTest
|
||||
COMMAND checkpointTest
|
||||
NAME backendTest
|
||||
COMMAND backendTest
|
||||
)
|
|
@ -0,0 +1,38 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include <taoserror.h>
|
||||
#include <tglobal.h>
|
||||
#include <iostream>
|
||||
#include "streamBackendRocksdb.h"
|
||||
|
||||
class BackendEnv : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {}
|
||||
virtual void TearDown() {}
|
||||
};
|
||||
|
||||
void *backendCreate() {
|
||||
const char *streamPath = "/tmp";
|
||||
|
||||
char *absPath = NULL;
|
||||
void *p = NULL;
|
||||
// SBackendWrapper *p = streamBackendInit(streamPath, -1, 2);
|
||||
// p = taskDbOpen((char *)streamPath, (char *)"test", -1);
|
||||
// p = bkdMgtCreate((char *)streamPath);
|
||||
|
||||
ASSERT(p != NULL);
|
||||
return p;
|
||||
}
|
||||
void backendOpen() {
|
||||
void *p = backendCreate();
|
||||
ASSERT(p != NULL);
|
||||
}
|
||||
|
||||
TEST_F(BackendEnv, checkOpen) { backendOpen(); }
|
||||
TEST_F(BackendEnv, backendOpt) {}
|
||||
TEST_F(BackendEnv, backendDestroy) {}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -14,10 +14,7 @@ class StreamStateEnv : public ::testing::Test {
|
|||
streamMetaInit();
|
||||
backend = streamBackendInit(path, 0, 0);
|
||||
}
|
||||
virtual void TearDown() {
|
||||
streamMetaCleanup();
|
||||
// indexClose(index);
|
||||
}
|
||||
virtual void TearDown() { streamMetaCleanup(); }
|
||||
|
||||
const char *path = TD_TMP_DIR_PATH "stream";
|
||||
void *backend;
|
||||
|
@ -50,6 +47,14 @@ bool equalSBF(SScalableBf *left, SScalableBf *right) {
|
|||
}
|
||||
|
||||
TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||
const char *streamPath = "/tmp";
|
||||
|
||||
char *absPath = NULL;
|
||||
void *p = NULL;
|
||||
// SBackendWrapper *p = streamBackendInit(streamPath, -1, 2);
|
||||
// p = taskDbOpen((char *)streamPath, (char *)"test", -1);
|
||||
p = bkdMgtCreate((char *)streamPath);
|
||||
|
||||
// const int64_t interval = 20 * 1000;
|
||||
// const int64_t watermark = 10 * 60 * 1000;
|
||||
// SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||
|
|
Loading…
Reference in New Issue