mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
The following commits could not be applied individually due to context differences between the monorepo and the public repo's build files. They have been applied as a cumulative diff to ensure the final state matches the monorepo exactly: - chore: sync CI files with 3.0 branch to eliminate merge conflicts (rd-public/tsdb!271) - revert(refactor): dynamically link taosd taosudf taosmqtt against libtaosnative.so to reduce binary size (revert #183) (rd-public/tsdb!282) - fix(docs): autofix formatting issues across all doc files (rd-public/tsdb!296) - feat: support -DBUILD_SANITIZER=true on windows for debug build (rd-public/tsdb!291) - feat(build): build cache, mirror, and sccache optimizations (rd-public/tsdb!326) - docs: update image for three replica (rd-public/tsdb!324) - enh: shared storage on windows (rd-public/tsdb!333) - fix(cmake): convert ext_libs3 from git clone to URL tarball download (rd-public/tsdb!360) - feat: dual-source deps and comprehensive docs/packaging (cherry-pick to main) (rd-public/tsdb!352) - fix(cmake): guard DOWNLOAD_EXTRACT_TIMESTAMP for CMake < 3.24 and fix duplicate Cargo.lock entry (rd-public/tsdb!369) - fix: test case execution failure in pytest.sh (rd-public/tsdb!338) - enh: built-in compilation support for Python UDF plugins use abi3 (rd-public/tsdb!325)
81 lines
2.4 KiB
C++
81 lines
2.4 KiB
C++
/*
|
|
* 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 <vnodeInt.h>
|
|
|
|
#include <taoserror.h>
|
|
#include <tglobal.h>
|
|
#include <iostream>
|
|
|
|
#include <tmsg.h>
|
|
#include <vnodeInt.h>
|
|
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
|
|
|
SDmNotifyHandle dmNotifyHdl = {}; // zero-init (state = 0)
|
|
|
|
#include "tq.h"
|
|
int main(int argc, char **argv) {
|
|
testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|
|
|
|
void tqWriteOffset() {
|
|
TdFilePtr pFile = taosOpenFile(TQ_OFFSET_NAME, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
|
|
|
STqOffset offset = {};
|
|
offset.val.type = TMQ_OFFSET__LOG;
|
|
offset.val.version = 8923;
|
|
strcpy(offset.subKey, "testtest");
|
|
int32_t bodyLen;
|
|
int32_t code;
|
|
tEncodeSize(tEncodeSTqOffset, &offset, bodyLen, code);
|
|
int32_t totLen = INT_BYTES + bodyLen;
|
|
void* buf = taosMemoryCalloc(1, totLen);
|
|
void* abuf = POINTER_SHIFT(buf, INT_BYTES);
|
|
|
|
*(int32_t*)buf = htonl(bodyLen);
|
|
SEncoder encoder;
|
|
tEncoderInit(&encoder, (uint8_t*)abuf, bodyLen);
|
|
tEncodeSTqOffset(&encoder, &offset);
|
|
taosWriteFile(pFile, buf, totLen);
|
|
|
|
taosMemoryFree(buf);
|
|
|
|
taosCloseFile(&pFile);
|
|
}
|
|
|
|
TEST(testCase, tqOffsetTest) {
|
|
STQ* pTq = (STQ*)taosMemoryCalloc(1, sizeof(STQ));
|
|
pTq->path = taosStrdup("./");
|
|
|
|
pTq->pOffset = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_ENTRY_LOCK);
|
|
taosHashSetFreeFp(pTq->pOffset, (FDelete)tDeleteSTqOffset);
|
|
|
|
tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0, NULL);
|
|
tdbTbOpen("tq.offset.db", -1, -1, NULL, pTq->pMetaDB, &pTq->pOffsetStore, 0);
|
|
|
|
tqWriteOffset();
|
|
tqOffsetRestoreFromFile(pTq, TQ_OFFSET_NAME);
|
|
taosRemoveFile(TQ_OFFSET_NAME);
|
|
tqClose(pTq);
|
|
}
|
|
|
|
#pragma GCC diagnostic pop
|