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;
|
return dst - 1;
|
||||||
}
|
}
|
||||||
__compar_fn_t idxGetCompar(int8_t type) {
|
__compar_fn_t idxGetCompar(int8_t type) {
|
||||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY ||
|
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_NCHAR ||
|
||||||
type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_GEOMETRY) {
|
type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
return (__compar_fn_t)strcmp;
|
return (__compar_fn_t)strcmp;
|
||||||
}
|
}
|
||||||
return getComparFunc(type, 0);
|
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);
|
return tCompare(func, QUERY_TERM, a, b, type);
|
||||||
}
|
}
|
||||||
TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t dtype) {
|
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 ||
|
if (dtype == TSDB_DATA_TYPE_BINARY || dtype == TSDB_DATA_TYPE_NCHAR || dtype == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
dtype == TSDB_DATA_TYPE_VARBINARY || dtype == TSDB_DATA_TYPE_GEOMETRY) {
|
dtype == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
return tDoCompare(func, cmptype, a, b);
|
return tDoCompare(func, cmptype, a, b);
|
||||||
}
|
}
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -290,6 +290,7 @@ int idxUidCompare(const void* a, const void* b) {
|
||||||
uint64_t r = *(uint64_t*)b;
|
uint64_t r = *(uint64_t*)b;
|
||||||
return l - r;
|
return l - r;
|
||||||
}
|
}
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t idxConvertData(void* src, int8_t type, void** dst) {
|
int32_t idxConvertData(void* src, int8_t type, void** dst) {
|
||||||
int tlen = -1;
|
int tlen = -1;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -372,6 +373,8 @@ int32_t idxConvertData(void* src, int8_t type, void** dst) {
|
||||||
// indexMayFillNumbericData(*dst, tlen);
|
// indexMayFillNumbericData(*dst, tlen);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) {
|
int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) {
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
*dst = strndup(INDEX_DATA_NULL_STR, (int)strlen(INDEX_DATA_NULL_STR));
|
*dst = strndup(INDEX_DATA_NULL_STR, (int)strlen(INDEX_DATA_NULL_STR));
|
||||||
|
|
|
@ -244,11 +244,6 @@ int32_t streamBackendDelInUseChkp(void* arg, int64_t chkpId);
|
||||||
|
|
||||||
int32_t taskDbBuildSnap(void* arg, SArray* pSnap);
|
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);
|
int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId);
|
||||||
|
|
||||||
SBkdMgt* bkdMgtCreate(char* path);
|
SBkdMgt* bkdMgtCreate(char* path);
|
||||||
|
|
|
@ -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
|
# bloomFilterTest
|
||||||
ADD_EXECUTABLE(streamUpdateTest "tstreamUpdateTest.cpp")
|
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(streamUpdateTest
|
#TARGET_LINK_LIBRARIES(streamUpdateTest
|
||||||
PUBLIC os util common gtest gtest_main stream executor index
|
#PUBLIC os util common gtest gtest_main stream executor index
|
||||||
|
#)
|
||||||
|
|
||||||
|
#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(
|
target_include_directories(
|
||||||
streamUpdateTest
|
backendTest
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(checkpointTest checkpointTest.cpp)
|
target_link_libraries(
|
||||||
TARGET_LINK_LIBRARIES(
|
backendTest
|
||||||
checkpointTest
|
PUBLIC rocksdb
|
||||||
PUBLIC os common gtest stream executor qcom index transport util
|
PUBLIC os common gtest stream executor qcom index transport util
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
|
||||||
checkpointTest
|
|
||||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME streamUpdateTest
|
NAME backendTest
|
||||||
COMMAND streamUpdateTest
|
COMMAND backendTest
|
||||||
)
|
|
||||||
|
|
||||||
add_test(
|
|
||||||
NAME checkpointTest
|
|
||||||
COMMAND checkpointTest
|
|
||||||
)
|
)
|
|
@ -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();
|
streamMetaInit();
|
||||||
backend = streamBackendInit(path, 0, 0);
|
backend = streamBackendInit(path, 0, 0);
|
||||||
}
|
}
|
||||||
virtual void TearDown() {
|
virtual void TearDown() { streamMetaCleanup(); }
|
||||||
streamMetaCleanup();
|
|
||||||
// indexClose(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *path = TD_TMP_DIR_PATH "stream";
|
const char *path = TD_TMP_DIR_PATH "stream";
|
||||||
void *backend;
|
void *backend;
|
||||||
|
@ -50,6 +47,14 @@ bool equalSBF(SScalableBf *left, SScalableBf *right) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TD_STREAM_UPDATE_TEST, update) {
|
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 interval = 20 * 1000;
|
||||||
// const int64_t watermark = 10 * 60 * 1000;
|
// const int64_t watermark = 10 * 60 * 1000;
|
||||||
// SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
// SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||||
|
|
Loading…
Reference in New Issue