TDengine/source/libs/new-stream/test/dataSinkTest.cpp

1064 lines
36 KiB
C++
Raw Normal View History

feat: new stream (#31678) * fix: windows compile issue * test: add vtable cases (#31829) * fix: windows compile issues * test:add test cases * fix: windows compile issue * case: em-4 stream case submit * test: stream4_sub1 found bug2 * test: submit test_scene_meters_bug2.py * add stream parameters example * feat: [TS-6100] Do not translate const value as column. * Feat/ts 6100 3.0 zlv (#31747) * modify asan exampel * modify asan exampel * add example * add example * modify case example --------- Co-authored-by: zelv01 <1101510017@qq.com> * feat(stream): fix memory leak * modify sliding example * test: update test case. * feat(stream): fix conflicts * fix: add offset case 10a 10s 10m 10h 10d * feat(stream): fix conflicts * chore(stream): rename case name #TS-6100 * add case * modify example * fix: windows compile issues * fix: data null check * feat: [TS-6100] Forbid where when using %%trows (#31827) * feat: [TS-6100] Forbid where when using %%trows * test: update cases * feat: [TS-6100] Fix leaks. --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * test: reproduce bugs * test: update test case. * test: update test case. * feat: [TS-6100] Fix leaks. * test: add cases * Feat/ts 6100 3.0.pw10 (#31841) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * test: reproduce bugs * fix: add sliding interval combine case * test: add cases * test: add recalc test. * test: reproduce bugs * case : add vt ts is null check * modify case * bug: submit test_idmp_meters_bug3.py * test: add test for recalc. * test: add cases * fix: error code check * test: add cases * fix(stream): scan wal with schema in that version * add case * test: add cases * test: update test case. * fix: windows compile issues * add case * test: add cases (#31845) * modify case * fix: reset interpPrev * test: add test_idmp_meters bug4 and bug3 * add case * fix(stream): opti wal interface * fix: remove test_idmp_meters_bug5.py * test: add cases * fix(stream): fix ts data fetch for virtual tables * cancel asan case * test: update test case. * test: update test case. * add case * test: add cases * test: add cases * test: add case test_idmp_meters_bug5.py * test: update test case. * fix(stream): tmq error * test: add cases * feat: [TS-6100] Restore deleted code in mndSma.c since they are still in use. * fix(stream): optimize val scan logic * test: add test_recalc_expired_time.py to ci. * test: update test case. * test: update test case. * feat: [TS-6100] Fix fill range check * fix(stream): optimize val scan logic * add case * test: modify for partition by %%1 * test: add fun case stream4_sub7 * fix(stream): optimize val scan logic * add case * feat: [TS-6100] Rename OPTIONS to STREAM_OPTIONS. * test: add test for recalc. * test: use stream_options. * fix: some cases error. * test: remove recalc from ci. * fix: ci case issues (#31880) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): fix compilation error * fix(stream): optimize val scan logic * test:add test cases * test: modify case * fix: external agg error * test(stream): tobacco scene testing #TD-36514 * test: add stream cases (#31885) * fix: windows compile issue * fix: calc timerange * fix: windows compile issue * modify case * fix(stream): compile error * test: remove one debug test case file * test: modify * test: add test cases * test: reproduce bugs * test: reproduce bugs * feat: [TS-6100] Placeholder function should only appera in SELECT and… (#31868) * feat: [TS-6100] Placeholder function should only appera in SELECT and WHERE and FROM. * test: update case --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * add example * add example * modify case example * modify case * test:alter sql * test: add stream5 case * fix(stream): get schema error with version * test: add delete recalc test py. * test: remove bug cases * test: stream5 case test passed * test: add state cases (#31893) * fix(stream): compile error * test: modify case * test: add cases * test: add test. * test: update test case. * chore(test): fix case err * test: update test case. * fix: align data get * fix(stream): fix row index of datablock written into data cache * fix: put align data * test: update test case. * test: add test cases for virtual table * chore(test): fix case err #TD-36514 * add case * test: add test for water mark. * test: add meters bug6 for stream5 * test: add cases (#31903) * test: add test for recalc. * feat: [TS-6100] %%trows can only be used when event type is window close. * test: add precision of database for ms/us/ns * modify case * add case * add case * test: add test to ci. * modify case * fix: ci case issues (#31904) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues * fix: ci case issues * fix: drop dnode issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): ci error * test: update test case. * feat: [TS-6100] Disable some failed UT. * feat: [TS-6100] Fix virtual table * test: add bug 5. * test: add test delete recalc to ci. * test: add bug 6. * test(stream): tobacco scene #TD-36514 * fix: reqCids,reqCols memory leak in SSTriggerRealtimeContext Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> * test: add case stream6 * fix(stream): implement some pending features in trigger task * modify case * modify case * fix: case issues * modify case * test: add recalc for warter mark. * fix(stream): fix count window trigger of virtual tables * fix(stream): memory leak * test: fix run err. * test: add stream6 bug7 * fix: adjust format * test(stream): tobacco scene testing #TD-36514 * test: change bug7 with update window1 and 2 * test: add test bug 7. * case: restore write 3 window * fix: windows compile issue * fix: notify * test: add cases * modify case * test: update test case. * test(stream): toobacco scene testing #TD-36514 --------- Co-authored-by: Simon Guan <slguan@taosdata.com> Co-authored-by: plum-lihui <huili@taosdata.com> Co-authored-by: Alex Duan <417921451@qq.com> Co-authored-by: zelv01 <1101510017@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: xiangyang guo <66111494+happyguoxy@users.noreply.github.com> Co-authored-by: wangmm0220 <wangmm0220@gmail.com> Co-authored-by: Haojun Liao <hjliao@taosdata.com> Co-authored-by: zyyang90 <zyyang@taosdata.com> Co-authored-by: Alex Duan <51781608+DuanKuanJun@users.noreply.github.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Simon Guan <guanshengliang@qq.com> Co-authored-by: huohong <sallyhuo@taosdata.com> Co-authored-by: Li Hui <52318143+plum-lihui@users.noreply.github.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: xiao-77 <berylbao@taosdata.com> Co-authored-by: Zhixiao Bao <62235797+xiao-77@users.noreply.github.com> Co-authored-by: happyguoxy <happy_guoxy@163.com> Co-authored-by: Tony Zhang <34825804+Tony2h@users.noreply.github.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com>
2025-07-16 06:42:16 +00:00
/*
* 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 <stdint.h>
#include <unistd.h>
#include <thread>
#include <queue>
#include <mutex>
#include <condition_variable>
#include <vector>
#include <random>
#include "dataSink.h"
#include "osSleep.h"
#include "tdatablock.h"
// Macro to initialize DataSink at the beginning of each test
#define INIT_DATA_SINK() do { \
int32_t initCode = initStreamDataSink(); \
ASSERT_EQ(initCode, 0); \
} while(0)
// Macro to cleanup DataSink at the end of each test
#define CLEANUP_DATA_SINK() do { \
destroyDataSinkMgr(); \
} while(0)
const int64_t baseTestTime1 = 1745142096000;
const int64_t baseTestTime2 = 1745142097000;
int32_t gTestMode = 1;
SSDataBlock* createTestBlock(int64_t basetime, int64_t timeOffset) {
SSDataBlock* b = NULL;
int32_t code = createDataBlock(&b);
int64_t timeStart = basetime + timeOffset;
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_TIMESTAMP, 8, 1);
blockDataAppendColInfo(b, &infoData);
SColumnInfoData infoData1 = createColumnInfoData(TSDB_DATA_TYPE_BINARY, 40, 2);
blockDataAppendColInfo(b, &infoData1);
blockDataEnsureCapacity(b, 100);
const char* str = "the value of: %d";
char buf[128] = {0};
char varbuf[128] = {0};
int64_t ts = basetime;
for (int32_t i = 0; i < 100; ++i) {
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
ts = timeStart + i;
if (i & 0x01) {
int32_t len = sprintf(buf, str, timeOffset + i);
STR_TO_VARSTR(varbuf, buf)
colDataSetVal(p0, i, (const char*)&ts, false);
colDataSetVal(p1, i, (const char*)varbuf, false);
memset(varbuf, 0, sizeof(varbuf));
memset(buf, 0, sizeof(buf));
} else {
colDataSetVal(p0, i, (const char*)&ts, false);
colDataSetVal(p1, i, (const char*)varbuf, true);
}
b->info.rows++;
}
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
//printf("binary column length:%d\n", *(int32_t*)p1->pData);
char* pData = colDataGetData(p1, 2);
//printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
pData = colDataGetData(p1, 3);
//printf("the third row: %s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
return b;
}
bool compareBlock(SSDataBlock* b1, SSDataBlock* b2) {
if (b1->info.rows != b2->info.rows) {
printf("compareBlock: rows not equal, b1:%" PRId64 ", b2:%" PRId64 "\n", b1->info.rows, b2->info.rows);
return false;
}
for (int32_t i = 0; i < b1->info.rows; ++i) {
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b1->pDataBlock, 0);
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b2->pDataBlock, 0);
if (*(int32_t*)colDataGetData(p0, i) != *(int32_t*)colDataGetData(p1, i)) {
printf("compareBlock: timestamp not equal at row %d, b1:%" PRId64 ", b2:%" PRId64 "\n", i,
*(int64_t*)colDataGetData(p0, i), *(int64_t*)colDataGetData(p1, i));
return false;
}
}
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b1->pDataBlock, 1);
SColumnInfoData* p2 = (SColumnInfoData*)taosArrayGet(b2->pDataBlock, 1);
char* pData = colDataGetData(p1, 3);
//printf("b1 the third row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
pData = colDataGetData(p1, 3);
//printf("b2 the third row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
return true;
}
bool compareBlockRow(SSDataBlock* b1, SSDataBlock* b2, int32_t row1, int32_t row2) {
for (int32_t i = 0; i < b1->pDataBlock->size; ++i) {
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b1->pDataBlock, i);
SColumnInfoData* p2 = (SColumnInfoData*)taosArrayGet(b2->pDataBlock, i);
if (i == 0) {
if (*(int64_t*)colDataGetData(p1, row1) != *(int64_t*)colDataGetData(p2, row2)) {
printf("compareBlockRow: timestamp not equal at row %d, b1:%" PRId64 ", b2:%" PRId64 "\n", row1,
*(int64_t*)colDataGetData(p1, row1), *(int64_t*)colDataGetData(p2, row2));
return false;
}
continue;
} else {
if (colDataIsNull(p1, b1->info.rows, row1, NULL) != colDataIsNull(p2, b2->info.rows, row2, NULL)) {
printf("compareBlockRow: null status not equal at row %d, b1:%d, b2:%d\n", row1,
colDataIsNull(p1, b1->info.rows, row1, NULL), colDataIsNull(p2, b2->info.rows, row2, NULL));
return false;
}
if (colDataIsNull(p1, b1->info.rows, row1, NULL) == true) {
continue;
}
if (IS_VAR_DATA_TYPE(p1->info.type)) {
char* pData = colDataGetData(p1, row1);
char* pData2 = colDataGetData(p2, row2);
if (varDataLen(pData) != varDataLen(pData2)) {
printf("compareBlockRow: var data length not equal at row %d, b1:%d, b2:%d\n", row1, varDataLen(pData),
varDataLen(pData2));
return false;
}
if (memcmp(varDataVal(pData), varDataVal(pData2), varDataLen(pData)) != 0) {
printf("compareBlockRow: var data not equal at row %d, b1:%s, b2:%s\n", row1, (char*)varDataVal(pData),
(char*)varDataVal(pData2));
return false;
}
} else {
if (*(int32_t*)colDataGetData(p1, row1) != *(int32_t*)colDataGetData(p2, row2)) {
printf("compareBlockRow: data not equal at row %d, b1:%d, b2:%d\n", row1,
*(int32_t*)colDataGetData(p1, row1), *(int32_t*)colDataGetData(p2, row2));
return false;
}
}
}
}
return true;
}
TEST(dataSinkTest, fileInit) {
int32_t code = initStreamDataSink();
ASSERT_EQ(code, 0);
destroyDataSinkMgr();
}
TEST(dataSinkTest, test_name) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = 1;
TSKEY wstart = 0;
TSKEY wend = 100;
void* pCache = NULL;
int32_t code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 1);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
blockDataDestroy(pBlock);
}
TEST(dataSinkTest, putStreamDataCacheTest) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_IMMEDIATE;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache = NULL;
// Test invalid parameters
int32_t code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 1);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 1, 0);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 1);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = moveStreamDataCache(NULL, groupID, wstart, wend, pBlock);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = getStreamDataCache(pCache, groupID, wend, wstart, NULL);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
// Test valid parameters
code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
void* pIter = NULL;
// Test invalid parameters
code = getStreamDataCache(pCache, groupID, wend, wstart, &pIter);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = getStreamDataCache(NULL, groupID, wstart, wend, &pIter);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = getStreamDataCache(pCache, groupID, wstart, wend, NULL);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
// Test valid parameters
code = getStreamDataCache(pCache, groupID, wstart, wend, &pIter);
ASSERT_EQ(code, 0);
code = getNextStreamDataCache(&pIter, NULL);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
bool equal = compareBlock(pBlock, pBlock1);
ASSERT_EQ(equal, true);
blockDataDestroy(pBlock1);
blockDataDestroy(pBlock);
pBlock = createTestBlock(baseTestTime1, 100);
streamId = 1;
taskId = 1;
groupID = 2;
cleanMode = DATA_CLEAN_IMMEDIATE;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
pCache = NULL;
code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
pIter = NULL;
code = getStreamDataCache(pCache, groupID, wstart, wend, &pIter);
ASSERT_EQ(code, 0);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
equal = compareBlock(pBlock, pBlock1);
ASSERT_EQ(equal, true);
blockDataDestroy(pBlock1);
blockDataDestroy(pBlock);
pBlock = createTestBlock(baseTestTime1, 0);
streamId = 2;
taskId = 1;
groupID = 2;
cleanMode = DATA_CLEAN_IMMEDIATE;
wstart = baseTestTime1 + 0;
wend = baseTestTime1 + 100;
pCache = NULL;
code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
pIter = NULL;
code = getStreamDataCache(pCache, groupID, wstart, wend, &pIter);
ASSERT_EQ(code, 0);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
equal = compareBlock(pBlock, pBlock1);
ASSERT_EQ(equal, true);
blockDataDestroy(pBlock1);
destroyDataSinkMgr();
blockDataDestroy(pBlock);
}
TEST(dataSinkTest, getSlidingStreamData) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
// Test invalid parameters, cleanMode is DATA_CLEAN_EXPIRED, cannot call moveStreamDataCache
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock);
ASSERT_EQ(code, TSDB_CODE_STREAM_INTERNAL_ERROR);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
blockDataDestroy(pBlock);
pBlock = createTestBlock(baseTestTime1, 100);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
void* pIter = NULL;
blockDataDestroy(pBlock);
pBlock = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 50, baseTestTime1 + 150, &pIter);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
blockDataDestroy(pBlock1);
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 51);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
pBlock = createTestBlock(baseTestTime1, 200);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 200;
wend = baseTestTime1 + 300;
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
pIter = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 150, baseTestTime1 + 249, &pIter);
ASSERT_EQ(code, 0);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
ASSERT_EQ(compareBlockRow(pBlock, pBlock1, 0, 0), true);
ASSERT_EQ(compareBlockRow(pBlock, pBlock1, 1, 1), true);
blockDataDestroy(pBlock);
blockDataDestroy(pBlock1);
destroyDataSinkMgr();
}
TEST(dataSinkTest, moveStreamData) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 3;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_IMMEDIATE;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock);
ASSERT_EQ(code, 0);
void* pIter = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1, baseTestTime1 + 100, &pIter);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter, nullptr);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
ASSERT_EQ(pBlock1, pBlock);
blockDataDestroy(pBlock);
code = getStreamDataCache(pCache, groupID, baseTestTime1, baseTestTime1 + 100, &pIter);
ASSERT_EQ(code, 0);
ASSERT_EQ(pIter, nullptr);
pBlock1 = NULL;
destroyDataSinkMgr();
}
TEST(dataSinkTest, cancelStreamDataCacheIterateTest) {
INIT_DATA_SINK();
int64_t streamId = 3;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_IMMEDIATE;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock1 = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock1, nullptr);
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock1);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock2 = createTestBlock(baseTestTime1, 100);
ASSERT_NE(pBlock2, nullptr);
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock2);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock3 = createTestBlock(baseTestTime1, 200);
ASSERT_NE(pBlock2, nullptr);
wstart = baseTestTime1 + 200;
wend = baseTestTime1 + 300;
code = moveStreamDataCache(pCache, groupID, wstart, wend, pBlock2);
ASSERT_EQ(code, 0);
void* pIter = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1, baseTestTime1 + 99, &pIter);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter, nullptr);
SSDataBlock* pBlock = NULL;
code = getNextStreamDataCache(&pIter, &pBlock);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock, nullptr);
ASSERT_NE(pIter, nullptr);
ASSERT_EQ(pBlock1, pBlock);
blockDataDestroy(pBlock);
pBlock = NULL;
code = getNextStreamDataCache(&pIter, &pBlock);
ASSERT_EQ(code, 0);
ASSERT_EQ(pBlock, nullptr);
ASSERT_EQ(pIter, nullptr);
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 100, baseTestTime1 + 199, &pIter);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter, nullptr);
code = getNextStreamDataCache(&pIter, &pBlock);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock, nullptr);
ASSERT_NE(pIter, nullptr);
ASSERT_EQ(pBlock2, pBlock);
blockDataDestroy(pBlock);
pBlock = NULL;
code = getNextStreamDataCache(&pIter, &pBlock);
ASSERT_EQ(code, 0);
ASSERT_EQ(pBlock, nullptr);
ASSERT_EQ(pIter, nullptr);
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 200, baseTestTime1 + 299, &pIter);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter, nullptr);
cancelStreamDataCacheIterate(&pIter);
blockDataDestroy(pBlock3); // pBlock3 has not moveout, destroyDataSinkMgr should destory it, but now has not finished.
destroyDataSinkMgr();
}
TEST(dataSinkTest, putStreamDataRows) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 29);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 30, 79);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 80, 99);
ASSERT_EQ(code, 0);
blockDataDestroy(pBlock);
pBlock = createTestBlock(baseTestTime1, 100);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 49);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 50, 99);
ASSERT_EQ(code, 0);
void* pIter = NULL;
blockDataDestroy(pBlock);
pBlock = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 50, baseTestTime1 + 150, &pIter);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 30);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 20);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 1);
blockDataDestroy(pBlock1);
destroyDataSinkMgr();
}
TEST(dataSinkTest, allWriteToFileTest) {
INIT_DATA_SINK();
setDataSinkMaxMemSize(0);
SSDataBlock* pBlock11 = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock11, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache1 = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache1);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 0, 29);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 30, 79);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 80, 99);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock21 = createTestBlock(baseTestTime2, 0);
ASSERT_NE(pBlock21, nullptr);
int64_t streamId2 = 1;
int64_t taskId2 = 1;
int64_t groupID2 = 2;
int32_t cleanMode2 = DATA_CLEAN_EXPIRED;
TSKEY wstart2 = baseTestTime2 + 0;
TSKEY wend2 = baseTestTime2 + 100;
void* pCache2 = NULL;
code = initStreamDataCache(streamId2, taskId2, 0, cleanMode2, 0, &pCache2);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 0, 29);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 30, 79);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 80, 99);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock12 = createTestBlock(baseTestTime1, 100);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock12, 0, 49);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock12, 50, 99);
ASSERT_EQ(code, 0);
void* pIter1 = NULL;
int64_t notExistGroupID = groupID + 100;
code = getStreamDataCache(pCache1, notExistGroupID, baseTestTime1 + 50, baseTestTime1 + 150, &pIter1);
ASSERT_EQ(code, 0);
ASSERT_EQ(pIter1, nullptr);
code = getStreamDataCache(pCache1, groupID, baseTestTime1 + 50, baseTestTime1 + 149, &pIter1);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter1, nullptr);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter1, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 30);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 0, 50), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 1, 51), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 2, 52), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 29, 79), true);
blockDataDestroy(pBlock1);
void* pIter2 = NULL;
code = getStreamDataCache(pCache2, groupID2, baseTestTime2 + 50, baseTestTime2 + 150, &pIter2);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter2, nullptr);
SSDataBlock* pBlock2 = NULL;
code = getNextStreamDataCache(&pIter2, &pBlock2);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock2, nullptr);
ASSERT_NE(pIter2, nullptr);
int rows2 = pBlock2->info.rows;
ASSERT_EQ(rows2, 30);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 0, 50), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 1, 51), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 2, 52), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 29, 79), true);
blockDataDestroy(pBlock2);
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 20);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 0, 80), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 1, 81), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 2, 82), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 19, 99), true);
ASSERT_NE(pIter1, nullptr);
blockDataDestroy(pBlock1);
code = getNextStreamDataCache(&pIter2, &pBlock2);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock2, nullptr);
ASSERT_EQ(pIter2, nullptr);
rows = pBlock2->info.rows;
ASSERT_EQ(rows, 20);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 0, 80), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 1, 81), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 2, 82), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 19, 99), true);
blockDataDestroy(pBlock2);
blockDataDestroy(pBlock21);
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter1, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 0, 0), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 1, 1), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 2, 2), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 49, 49), true);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_EQ(pBlock1, nullptr);
ASSERT_EQ(pIter1, nullptr);
blockDataDestroy(pBlock11);
blockDataDestroy(pBlock12);
destroyDataSinkMgr();
}
TEST(dataSinkTest, allWriteMultiStreamToFileTest) {
INIT_DATA_SINK();
setDataSinkMaxMemSize(0);
SSDataBlock* pBlock11 = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock11, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache1 = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache1);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 0, 29);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 30, 79);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock11, 80, 99);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock21 = createTestBlock(baseTestTime2, 0);
ASSERT_NE(pBlock21, nullptr);
int64_t streamId2 = 2;
int64_t taskId2 = 1;
int64_t groupID2 = 2;
int32_t cleanMode2 = DATA_CLEAN_EXPIRED;
TSKEY wstart2 = baseTestTime2 + 0;
TSKEY wend2 = baseTestTime2 + 100;
void* pCache2 = NULL;
code = initStreamDataCache(streamId2, taskId2, 0, cleanMode2, 0, &pCache2);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 0, 29);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 30, 79);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache2, groupID2, wstart2, wend2, pBlock21, 80, 99);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock12 = createTestBlock(baseTestTime1, 100);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock12, 0, 49);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache1, groupID, wstart, wend, pBlock12, 50, 99);
ASSERT_EQ(code, 0);
void* pIter1 = NULL;
int64_t notExistGroupID = groupID + 100;
code = getStreamDataCache(pCache1, notExistGroupID, baseTestTime1 + 50, baseTestTime1 + 150, &pIter1);
ASSERT_EQ(code, 0);
ASSERT_EQ(pIter1, nullptr);
code = getStreamDataCache(pCache1, groupID, baseTestTime1 + 50, baseTestTime1 + 149, &pIter1);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter1, nullptr);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter1, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 30);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 0, 50), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 1, 51), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 2, 52), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 29, 79), true);
blockDataDestroy(pBlock1);
void* pIter2 = NULL;
code = getStreamDataCache(pCache2, groupID2, baseTestTime2 + 50, baseTestTime2 + 150, &pIter2);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter2, nullptr);
SSDataBlock* pBlock2 = NULL;
code = getNextStreamDataCache(&pIter2, &pBlock2);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock2, nullptr);
ASSERT_NE(pIter2, nullptr);
int rows2 = pBlock2->info.rows;
ASSERT_EQ(rows2, 30);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 0, 50), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 1, 51), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 2, 52), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 29, 79), true);
blockDataDestroy(pBlock2);
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 20);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 0, 80), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 1, 81), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 2, 82), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock11, 19, 99), true);
ASSERT_NE(pIter1, nullptr);
blockDataDestroy(pBlock1);
code = getNextStreamDataCache(&pIter2, &pBlock2);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock2, nullptr);
ASSERT_EQ(pIter2, nullptr);
rows = pBlock2->info.rows;
ASSERT_EQ(rows, 20);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 0, 80), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 1, 81), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 2, 82), true);
ASSERT_EQ(compareBlockRow(pBlock2, pBlock21, 19, 99), true);
blockDataDestroy(pBlock2);
blockDataDestroy(pBlock21);
destroyStreamDataCache(pCache2);
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_NE(pIter1, nullptr);
rows = pBlock1->info.rows;
ASSERT_EQ(rows, 50);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 0, 0), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 1, 1), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 2, 2), true);
ASSERT_EQ(compareBlockRow(pBlock1, pBlock12, 49, 49), true);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
code = getNextStreamDataCache(&pIter1, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_EQ(pBlock1, nullptr);
ASSERT_EQ(pIter1, nullptr);
blockDataDestroy(pBlock11);
blockDataDestroy(pBlock12);
destroyStreamDataCache(pCache1);
destroyDataSinkMgr();
}
TEST(dataSinkTest, testWriteFileSize) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
setDataSinkMaxMemSize(DS_MEM_SIZE_RESERVED + 1024 * 1024);
int64_t streamId = 3;
void* pCache = NULL;
int64_t taskId = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_NE(pBlock, nullptr);
for (int32_t i = 0; i < 100000; i++) {
int64_t groupID = i;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
}
for (int32_t i = 0; i < 100000; i++) {
int64_t groupID = i;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 99;
void* pIter = NULL;
code = getStreamDataCache(pCache, groupID, wstart, wend, &pIter);
ASSERT_EQ(code, 0);
ASSERT_NE(pIter, nullptr);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 100);
bool equal = compareBlock(pBlock, pBlock1);
ASSERT_EQ(equal, true);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
if (pIter != nullptr) {
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_EQ(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
}
}
blockDataDestroy(pBlock);
destroyStreamDataCache(pCache);
}
TEST(dataSinkTest, multiThreadGet) {
INIT_DATA_SINK();
const int producerCount = 1;
const int consumerCount = 16;
const int taskPerProducer = 10000;
struct Task {
int64_t groupID;
TSKEY wstart;
TSKEY wend;
SSDataBlock* pBlock;
};
// Each queue has its own mutex and condition_variabl
std::vector<std::queue<Task>> taskQueues(consumerCount);
std::vector<std::mutex> queueMutexes(consumerCount);
std::vector<std::condition_variable> queueCVs(consumerCount);
std::vector<bool> doneFlags(consumerCount, false);
int32_t groups[100] = {0};
// Initialize data cache
setDataSinkMaxMemSize(DS_MEM_SIZE_RESERVED + 1024 * 1024);
int64_t streamId = 100;
int64_t taskId = 100;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int64_t> dist(0, 99);
// Producer thread
auto producer = [&](int tid) {
for (int i = 0; i < taskPerProducer; ++i) {
int64_t groupId = dist(gen);
TSKEY wstart = baseTestTime1 + groups[groupId] * 100;
TSKEY wend = baseTestTime1 + (++groups[groupId]) * 100;
SSDataBlock* pBlock = createTestBlock(wstart, 0);
code = putStreamDataCache(pCache, groupId, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
// Assign to different queues according to groupId
int queueIdx = groupId % consumerCount;
{
std::lock_guard<std::mutex> lock(queueMutexes[queueIdx]);
taskQueues[queueIdx].push(Task{groupId, wstart, wend, pBlock});
}
queueCVs[queueIdx].notify_one();
}
};
// Consumer thread
auto consumer = [&](int idx) {
while (true) {
Task task;
{
std::unique_lock<std::mutex> lock(queueMutexes[idx]);
queueCVs[idx].wait(lock, [&] { return !taskQueues[idx].empty() || doneFlags[idx]; });
if (taskQueues[idx].empty() && doneFlags[idx]) break;
if (taskQueues[idx].empty()) continue;
task = taskQueues[idx].front();
taskQueues[idx].pop();
}
// Consume task: get data and check
void* pIter = NULL;
int32_t code2 = getStreamDataCache(pCache, task.groupID, task.wstart, task.wend - 1, &pIter);
ASSERT_EQ(code2, 0);
ASSERT_NE(pIter, nullptr);
SSDataBlock* pBlock1 = NULL;
code2 = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code2, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pBlock1->info.rows, 100);
bool equal = compareBlock(task.pBlock, pBlock1);
ASSERT_EQ(equal, true);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
if (pIter != nullptr) {
code2 = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code2, 0);
ASSERT_EQ(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
}
blockDataDestroy(task.pBlock);
if (gTestMode == 1) {
taosMsleep(10); // This is done to create a backlog of data
}
}
};
// Start producer threads
std::vector<std::thread> producers;
for (int i = 0; i < producerCount; ++i) {
producers.emplace_back(producer, i);
}
// Start consumer threads
std::vector<std::thread> consumers;
for (int i = 0; i < consumerCount; ++i) {
consumers.emplace_back(consumer, i);
}
// Wait for producers to finish
for (auto& t : producers) t.join();
// Notify all consumers that this producer has finished
for (int i = 0; i < consumerCount; ++i) {
std::lock_guard<std::mutex> lock(queueMutexes[i]);
doneFlags[i] = true;
queueCVs[i].notify_all();
}
// Wait for consumers to finish
for (auto& t : consumers) t.join();
destroyStreamDataCache(pCache);
}
feat(stream): optimize stream logic (#33027) * fix: remove debug log * fix: remove assert * fix: delete unused code * enh: [TD-37251] Support expr in state window. * feat(stream): support expr in state window trigger * enh: [TD-37251] Fix SCL_IS_CONST_CALC condition. * fix(stream): set ver in wal * fix: print code * fix: increase runner replica num * fix: trigger mem error * fix: sliding _tnext_ts value * fix(stream): disable tagFilterCache in stream reader trigger * fix: crash * Revert "fix(stream): fix history calc finish check" This reverts commit f93d17f1d27f011639d22cb0880637dbeb7e5532. * Revert "fix(stream): fix calc request allocation in trigger" This reverts commit c5410f6da09835303d32967f4b6d02a7e47cd589. * fix(stream): fix calc request allocation in trigger * enh: [TD-37251] External window support more placeholder. * fix(stream): modify size of return from 1000000->4096 * enh: [TD-37251] Modify error msg when stream query do not have from clause. * fix(stream): add log for group not found * fix(stream): do not return gid=0 in walMetaData interface * enh: [TD-37251] Fix missing ts column in vtable query. * fix: test case build failed * fix: invalid read issue * fix(stream): add vtable logic * fix(stream): encode error in wal * fix(stream): add vtable logic * fix(stream): add log * fix: diff funcition crash * Revert "Merge branch 'enh/TD-37251-3.0-dropoutput' into enh/TD-37251-3.0" This reverts commit e93cbd6fd42261527df046c70e0ece7568af187b, reversing changes made to dc3230591d4428c817703f52574aa01d5f10e5fe. * Revert "Merge branch 'enh/TD-37251-3.0-vtable' into enh/TD-37251-3.0" This reverts commit dc3230591d4428c817703f52574aa01d5f10e5fe, reversing changes made to 085e086782896db22acd292816e53497cbecb726. * fix(stream): fix block data len is too large if data type is vchar * fix: drop output table * feat: runner delete output table * process pDropBlock in trigger task. * fix(stream): opti log level * fix(stream): build block for drop table * fix(stream): set gid for normal table * fix(stream): set gid for normal table * feat: Support delete output. * fix(stream): rows error * fix(stream): memory leak * enh: [TD-37251] Fix external window wrong ts column. * fix(stream): fix calc time check in batch mode * fix: merge aligned external window issue * Revert "fix(stream): fix calc time check in batch mode" This reverts commit d895b7f5776cf77c2ce290cdeedca86c206da6ce. * fix(stream): add test case * fix(stream): add insert drop table logic * fix: external window end issue * fix(stream): add test case * fix(stream): fix trigger pull data * fix(stream): fix history calc request * enh: drop table on snode * fix(stream): adjust hash index if data is filtered in wal * fix(stream): rollback * enh: add merge aligned extwin window row idx * fix: drop output table * fix: compile issue * enh: [TD-37251] Add flag to identify interval window is overlapped * fix: overlap * fix(stream): set gid=-1 for initialized * fix(stream): modify log level * fix: trigger slow issue * fix(stream): add basic test for obj pool * fix(stream): fix metadata clear in trigger * fix(stream): fix idle runner allocation in trigger * fix: handle agg output on externalWin * fix: test case * fix(stream): adjust log * fix: reset pCtx pOutput * fix: memory leak * fix: search first win for tsCol * fix(stream): add test case for schema change * fix: mem leak * fix: mem leak * Reapply "Merge branch 'enh/TD-37251-3.0-vtable' into enh/TD-37251-3.0" This reverts commit b508e66958eb95117b1d086a964b87b5ac59a19e. * fix(stream): fix virtual table data pull * fix(stream): fix set table request * fix(stream): process empty uidlist * fix(stream): fix set table request * fix(stream): fix data new request in trigger * fix(stream): tablelist error for vtable * fix(stream): block ver is null * fix(stream): remove version limition for wal * fix(stream): block rows error * fix(stream): fix pending calc param in batch mode * fix(stream): auto create table * fix(stream): fix stream vtable data merge * fix: _tcurrentts * fix(stream): destroy hash * fix(stream): fix trigger status * fix(stream): colId error in vtable * fix(stream): update nrows of vtable data block * fix(stream): fix trigger status * fix(stream): enable low latency calc for period trigger * fix: test case file path * fix: test case file path * fix: string to node in reader * enh: add test log * fix(stream): increase wait time of non-low-latency mode * fix(stream): fix column capacity in scalar calculation * fix(stream): fix column capacity in trigger expr calculation * fix: get origTableInfos * fix(stream): fix calc data pull in trigger * fix(stream): fix calc data cache write in trigger * enh: [TD-37251] Add flag to identify interval wind * fix: external window memory usage issue * fix(stream): fix epxr result column in trigger * fix(stream): add metaCache for calc plan * fix(stream): fix stream obj list clear * fix(stream): rollback * enh: [TD-37251] Add flag to identify interval wind * fix: mem free * fix(stream): add metaCache for calc plan * fix(stream): fix calc data cache write in trigger * fix(stream): fix calc data cache write in trigger * enh: optimize external result block memory * fix(stream): modify logic of judge table for create table * fix(stream): fix event window check in trigger * fix(stream): fix count window check in trigger * fix(stream): colSize=0 while encoding block because pDataCol->hasNull is false in secode time & reload table list if create table * enh: optimize stream memory * fix(stream): trigger tag error * fix: add log * fix(stream): fix calc data write in trigger * fix: drop output table * fix(stream): fix max delay in trigger * fix: drop output table * fix(stream): fix max delay in trigger * fix(build): handle return value of function * fix(stream): read gid error if it is child table in stream * fix(stream): fix calc param of history calculation * fix(stream): fix recalc of delete data * fix(stream): fix calc data of period trigger * fix(stream): fix cache read check * fix(stream): filter error in calc plan * fix: reset externla window expr * fix(stream): fix calc parm of max delay * fix: time range and case issues * fix(stream): fix crash in trigger * fix: case issues * fix: fix window node mem leak. * fix(stream): fix meta data clear in trigger * fix(stream): table schema is old in TsdbDataRequest for vtable * fix: fix slingding window place holder check condition. * Revert "fix: fix slingding window place holder check condition." This reverts commit ad864a1dc113961b409e32e2ac7d1feb534b74d6. * fix(stream): null pointer error * fix: case issue * fix(stream): calc data error for vtable * fix(stream): fix data sorter in trigger * fix(stream): add log for delete data * fix(stream): fix start version of realtime calculation * fix(stream): fix cache data merger of vtable * fix: case issues * fix(ci): upgrade stream cases in test_cols_function * fix(stream): gid not found if change tag value * fix: fix slingding window place holder check condition. * fix(stream): fix virt table info request in trigger * fix(stream): set gid = uid if stream table type != SUPER table * fix: clean cache data by group * fix: add block info and case issues * fix: fix heap-buffer-overflow. * fix(stream): fix state window with extend param * fix: fix access null pointer. * fix: case issues * fix: case issue * fix(stream): fix ignore_nodata_trigger option for period trigger * fix(stream): fix pseudo col fetch for calc data * fix: Extend checking time to avoid timeout. * fix: case issues * fix(stream): fix group col fetch for virtual tables * fix(stream): tag is NULL for non vtable * fix(stream): fix sliding check of virtual table * test(stream): check stream status after create all streams * fix: add log * fix(stream): fix wal meta truncate when ignore disorder * fix(stream): gid not found for child table * fix: fix place holder condition pushdown error. * fix(stream): suid not equal when delete data for child table * fix: id issue * fix(stream): disable recalc for count trigger * fix: cast result rowSize error in project * fix(stream): add log for tsdb meta * fix(stream): fix gid in tsdb meta request * fix(stream): fix wend of unclosed windows * fix(stream): fix ignore_nodata_trigger option for period trigger * fix: case issues * fix(stream): fix calc data pull for empty interval window * fix: fix ext window condition. * fix(ci): smaBasic performance check affectd by debug level log * fix(stream): add suid when set table list for vtable * fix: forbid using prefilter when using %%trows an trigger table is virtual table. * fix: forbid prefilter %%trows cases. * fix(stream): sort cid in tsdbVirtalDataReq * fix: forbid prefilter %%trows cases. * fix(stream): add log for virtual table tsdb data * fix(stream): get delete msg for vtable * fix: winRowIndex * Revert "fix: winRowIndex" This reverts commit e08b41cf960bb9ca031b9ea20b4495cbbd4e3ed0. * fix(stream): fix data merge in trigger * test(stream): fix case ans * fix(stream): fix empty calc data pull for period trigger * fix(stream): col index error for tsdbVirtalDataReq * fix(stream): pTableList is NULL for vtable * test(stream): fix case ans * fix(stream): fix notification in trigger * fix(stream): memory leak * fix(stream): fix virtual data pull in trigger * test(stream): fix case ans * fix(stream): col index error for tsdbVirtalDataReq * fix(stream): pTableList is NULL for vtable * test(stream): fix case ans * fix(stream): fix notification in trigger * fix(stream): memory leak * fix(stream): fix virtual data pull in trigger * test(stream): fix case ans * fix: case issue * fix: crash issue * fix: forbid prefilter %%trows cases. * fix(stream): session case * fix(stream): fix data pull for virtual tables * fix(stream): add log * fix(stream): fix calc req send in batch mode * fix: fix stream UT * fix(stream): tablelist is null for non vtable * fix: mem leak * fix(stream): fix compile error in trigger * fix: return code issue --------- Co-authored-by: dapan1121 <wpan@taosdata.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com>
2025-09-25 07:48:14 +00:00
TEST(dataSinkTest, cleanSlidingStreamData) {
INIT_DATA_SINK();
SSDataBlock* pBlock = createTestBlock(baseTestTime1, 0);
ASSERT_NE(pBlock, nullptr);
int64_t streamId = 1;
int64_t taskId = 1;
int64_t groupID = 1;
int32_t cleanMode = DATA_CLEAN_EXPIRED;
TSKEY wstart = baseTestTime1 + 0;
TSKEY wend = baseTestTime1 + 100;
void* pCache = NULL;
int32_t code = initStreamDataCache(streamId, taskId, 0, cleanMode, 0, &pCache);
ASSERT_EQ(code, 0);
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
blockDataDestroy(pBlock);
code = cleanStreamDataCache(pCache, groupID);
ASSERT_EQ(code, 0);
pBlock = createTestBlock(baseTestTime1, 100);
cleanMode = DATA_CLEAN_EXPIRED;
wstart = baseTestTime1 + 100;
wend = baseTestTime1 + 200;
code = putStreamDataCache(pCache, groupID, wstart, wend, pBlock, 0, 99);
ASSERT_EQ(code, 0);
void* pIter = NULL;
blockDataDestroy(pBlock);
pBlock = NULL;
code = getStreamDataCache(pCache, groupID, baseTestTime1 + 50, baseTestTime1 + 150, &pIter);
ASSERT_EQ(code, 0);
SSDataBlock* pBlock1 = NULL;
code = getNextStreamDataCache(&pIter, &pBlock1);
ASSERT_EQ(code, 0);
ASSERT_NE(pBlock1, nullptr);
ASSERT_EQ(pIter, nullptr);
int rows = pBlock1->info.rows;
ASSERT_EQ(rows, 51);
blockDataDestroy(pBlock1);
pBlock1 = NULL;
destroyDataSinkMgr();
}
feat: new stream (#31678) * fix: windows compile issue * test: add vtable cases (#31829) * fix: windows compile issues * test:add test cases * fix: windows compile issue * case: em-4 stream case submit * test: stream4_sub1 found bug2 * test: submit test_scene_meters_bug2.py * add stream parameters example * feat: [TS-6100] Do not translate const value as column. * Feat/ts 6100 3.0 zlv (#31747) * modify asan exampel * modify asan exampel * add example * add example * modify case example --------- Co-authored-by: zelv01 <1101510017@qq.com> * feat(stream): fix memory leak * modify sliding example * test: update test case. * feat(stream): fix conflicts * fix: add offset case 10a 10s 10m 10h 10d * feat(stream): fix conflicts * chore(stream): rename case name #TS-6100 * add case * modify example * fix: windows compile issues * fix: data null check * feat: [TS-6100] Forbid where when using %%trows (#31827) * feat: [TS-6100] Forbid where when using %%trows * test: update cases * feat: [TS-6100] Fix leaks. --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * test: reproduce bugs * test: update test case. * test: update test case. * feat: [TS-6100] Fix leaks. * test: add cases * Feat/ts 6100 3.0.pw10 (#31841) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * test: reproduce bugs * fix: add sliding interval combine case * test: add cases * test: add recalc test. * test: reproduce bugs * case : add vt ts is null check * modify case * bug: submit test_idmp_meters_bug3.py * test: add test for recalc. * test: add cases * fix: error code check * test: add cases * fix(stream): scan wal with schema in that version * add case * test: add cases * test: update test case. * fix: windows compile issues * add case * test: add cases (#31845) * modify case * fix: reset interpPrev * test: add test_idmp_meters bug4 and bug3 * add case * fix(stream): opti wal interface * fix: remove test_idmp_meters_bug5.py * test: add cases * fix(stream): fix ts data fetch for virtual tables * cancel asan case * test: update test case. * test: update test case. * add case * test: add cases * test: add cases * test: add case test_idmp_meters_bug5.py * test: update test case. * fix(stream): tmq error * test: add cases * feat: [TS-6100] Restore deleted code in mndSma.c since they are still in use. * fix(stream): optimize val scan logic * test: add test_recalc_expired_time.py to ci. * test: update test case. * test: update test case. * feat: [TS-6100] Fix fill range check * fix(stream): optimize val scan logic * add case * test: modify for partition by %%1 * test: add fun case stream4_sub7 * fix(stream): optimize val scan logic * add case * feat: [TS-6100] Rename OPTIONS to STREAM_OPTIONS. * test: add test for recalc. * test: use stream_options. * fix: some cases error. * test: remove recalc from ci. * fix: ci case issues (#31880) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): fix compilation error * fix(stream): optimize val scan logic * test:add test cases * test: modify case * fix: external agg error * test(stream): tobacco scene testing #TD-36514 * test: add stream cases (#31885) * fix: windows compile issue * fix: calc timerange * fix: windows compile issue * modify case * fix(stream): compile error * test: remove one debug test case file * test: modify * test: add test cases * test: reproduce bugs * test: reproduce bugs * feat: [TS-6100] Placeholder function should only appera in SELECT and… (#31868) * feat: [TS-6100] Placeholder function should only appera in SELECT and WHERE and FROM. * test: update case --------- Co-authored-by: Simon Guan <guanshengliang@qq.com> * add example * add example * modify case example * modify case * test:alter sql * test: add stream5 case * fix(stream): get schema error with version * test: add delete recalc test py. * test: remove bug cases * test: stream5 case test passed * test: add state cases (#31893) * fix(stream): compile error * test: modify case * test: add cases * test: add test. * test: update test case. * chore(test): fix case err * test: update test case. * fix: align data get * fix(stream): fix row index of datablock written into data cache * fix: put align data * test: update test case. * test: add test cases for virtual table * chore(test): fix case err #TD-36514 * add case * test: add test for water mark. * test: add meters bug6 for stream5 * test: add cases (#31903) * test: add test for recalc. * feat: [TS-6100] %%trows can only be used when event type is window close. * test: add precision of database for ms/us/ns * modify case * add case * add case * test: add test to ci. * modify case * fix: ci case issues (#31904) * enh: add operator reset func * fix: merge join reset issue * fix: memory issues * fix: add debug assert * fix: memory issues * fix: memory leak * fix: memory issues * fix taos log miss * fix: case issue * fix: case issue * fix: case issues * fix: drop dnode issue * fix: memory issues * fix: memory issues * fix: memory leak issues * fix: recalculate time range issue * fix: add debug log * fix: memory issues * fix: enable case asan * Update streamlist_for_ci.task * fix: case asan issue * fix: stream name issue * fix: external window compile issues * fix: deploy memory issue * fix: ahandle issue * fix: ahandle issue * fix: ahandle issue * fix: virtual table reader list issue * fix: log info * fix: msg error * fix: virtual table addr list issue * fix: memory issues * fix: memory leak issue * fix: memory issues * fix: memory free issues * fix: memory issues * fix: snode deploy issue * fix: mnode reader issue * fix: memory issues * fix: add debug test * enh: add ignore nodata trigger * fix: memory leaks * fix: configuration issue * fix: memory issue * fix: external window issue * fix: external window issues * fix: external window placeholder issue * fix: placeholder function init issues * fix: memory leak issue * fix: add debug log * fix: compile issues * fix: double free issue * fix: runner addr update issue * fix: msg rsp issue * fix: external window reset issue * fix: configuration issue * fix: deploy msg issue * fix: compile issue * fix: external window idx issue * fix: ci issues * fix: ci case issues * fix: drop dnode issue --------- Co-authored-by: huohong <sallyhuo@taosdata.com> * fix(stream): ci error * test: update test case. * feat: [TS-6100] Disable some failed UT. * feat: [TS-6100] Fix virtual table * test: add bug 5. * test: add test delete recalc to ci. * test: add bug 6. * test(stream): tobacco scene #TD-36514 * fix: reqCids,reqCols memory leak in SSTriggerRealtimeContext Co-authored-by: Tony Zhang <tonyzhang@taosdata.com> * test: add case stream6 * fix(stream): implement some pending features in trigger task * modify case * modify case * fix: case issues * modify case * test: add recalc for warter mark. * fix(stream): fix count window trigger of virtual tables * fix(stream): memory leak * test: fix run err. * test: add stream6 bug7 * fix: adjust format * test(stream): tobacco scene testing #TD-36514 * test: change bug7 with update window1 and 2 * test: add test bug 7. * case: restore write 3 window * fix: windows compile issue * fix: notify * test: add cases * modify case * test: update test case. * test(stream): toobacco scene testing #TD-36514 --------- Co-authored-by: Simon Guan <slguan@taosdata.com> Co-authored-by: plum-lihui <huili@taosdata.com> Co-authored-by: Alex Duan <417921451@qq.com> Co-authored-by: zelv01 <1101510017@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: xiangyang guo <66111494+happyguoxy@users.noreply.github.com> Co-authored-by: wangmm0220 <wangmm0220@gmail.com> Co-authored-by: Haojun Liao <hjliao@taosdata.com> Co-authored-by: zyyang90 <zyyang@taosdata.com> Co-authored-by: Alex Duan <51781608+DuanKuanJun@users.noreply.github.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Simon Guan <guanshengliang@qq.com> Co-authored-by: huohong <sallyhuo@taosdata.com> Co-authored-by: Li Hui <52318143+plum-lihui@users.noreply.github.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: xiao-77 <berylbao@taosdata.com> Co-authored-by: Zhixiao Bao <62235797+xiao-77@users.noreply.github.com> Co-authored-by: happyguoxy <happy_guoxy@163.com> Co-authored-by: Tony Zhang <34825804+Tony2h@users.noreply.github.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com>
2025-07-16 06:42:16 +00:00
int main(int argc, char** argv) {
taos_init();
::testing::InitGoogleTest(&argc, argv);
if (argc > 1) {
::testing::GTEST_FLAG(filter) = argv[1];
} else {
::testing::GTEST_FLAG(filter) = "*";
}
int ret = RUN_ALL_TESTS();
gTestMode = 0; // Reset test mode to 0 for the next run
::testing::GTEST_FLAG(filter) = "dataSinkTest.multiThreadGet";
int ret2 = RUN_ALL_TESTS();
taos_cleanup();
return ret || ret2;
}