From b0a4cc81bf373ab0d2588abdb113756f42483bec Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 4 Mar 2022 22:48:15 +0800 Subject: [PATCH] [td-13039] refactor and fix bugs. --- source/libs/executor/test/executorTests.cpp | 20 ++++++++++++------- source/libs/parser/test/mockCatalog.cpp | 6 ++++++ .../libs/parser/test/mockCatalogService.cpp | 17 ++++++++++++++++ source/libs/parser/test/mockCatalogService.h | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index 9ba6afc006..bfa6325211 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -224,7 +224,7 @@ int main(int argc, char** argv) { TEST(testCase, build_executor_tree_Test) { const char* msg = "{\n" - " \"NodeType\": \"47\",\n" + " \"NodeType\": \"48\",\n" " \"Name\": \"PhysiSubplan\",\n" " \"PhysiSubplan\": {\n" " \"Id\": {\n" @@ -233,15 +233,21 @@ TEST(testCase, build_executor_tree_Test) { " \"SubplanId\": \"0\"\n" " },\n" " \"SubplanType\": \"0\",\n" - " \"MsgType\": \"0\",\n" + " \"MsgType\": \"515\",\n" " \"Level\": \"0\",\n" " \"NodeAddr\": {\n" - " \"Id\": \"0\",\n" + " \"Id\": \"1\",\n" " \"InUse\": \"0\",\n" - " \"NumOfEps\": \"0\"\n" + " \"NumOfEps\": \"1\",\n" + " \"Eps\": [\n" + " {\n" + " \"Fqdn\": \"node1\",\n" + " \"Port\": \"6030\"\n" + " }\n" + " ]\n" " },\n" " \"RootNode\": {\n" - " \"NodeType\": \"40\",\n" + " \"NodeType\": \"41\",\n" " \"Name\": \"PhysiProject\",\n" " \"PhysiProject\": {\n" " \"OutputDataBlockDesc\": {\n" @@ -345,7 +351,7 @@ TEST(testCase, build_executor_tree_Test) { " },\n" " \"Children\": [\n" " {\n" - " \"NodeType\": \"37\",\n" + " \"NodeType\": \"38\",\n" " \"Name\": \"PhysiTableScan\",\n" " \"PhysiTableScan\": {\n" " \"OutputDataBlockDesc\": {\n" @@ -825,7 +831,7 @@ TEST(testCase, build_executor_tree_Test) { " }\n" " },\n" " \"DataSink\": {\n" - " \"NodeType\": \"45\",\n" + " \"NodeType\": \"46\",\n" " \"Name\": \"PhysiDispatch\",\n" " \"PhysiDispatch\": {\n" " \"InputDataBlockDesc\": {\n" diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index e626fc68ae..7415e95bdb 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -58,6 +58,10 @@ int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const return mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo); } +int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) { + return mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList); +} + void initMetaDataEnv() { mockCatalogService.reset(new MockCatalogService()); @@ -65,6 +69,8 @@ void initMetaDataEnv() { stub.set(catalogGetHandle, __catalogGetHandle); stub.set(catalogGetTableMeta, __catalogGetTableMeta); stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup); + stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo); + { AddrAny any("libcatalog.so"); std::map result; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 00d64bd12a..a1de7c47a7 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -126,6 +126,19 @@ public: return 0; } + int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const { + SVgroupInfo info = {0}; + info.vgId = 1; + addEpIntoEpSet(&info.epset, "node1", 6030); + + info.hashBegin = 0; + info.hashEnd = 1; + *pVgList = taosArrayInit(4, sizeof(SVgroupInfo)); + + taosArrayPush(*pVgList, &info); + return 0; + } + TableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, int32_t numOfColumns, int32_t numOfTags) { builder_ = TableBuilder::createTableBuilder(tableType, numOfColumns, numOfTags); meta_[db][tbname] = builder_->table(); @@ -313,4 +326,8 @@ int32_t MockCatalogService::catalogGetTableMeta(const SName* pTableName, STableM int32_t MockCatalogService::catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const { return impl_->catalogGetTableHashVgroup(pTableName, vgInfo); +} + +int32_t MockCatalogService::catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const { + return impl_->catalogGetTableDistVgInfo(pTableName, pVgList); } \ No newline at end of file diff --git a/source/libs/parser/test/mockCatalogService.h b/source/libs/parser/test/mockCatalogService.h index b971331635..1f7cd70ac2 100644 --- a/source/libs/parser/test/mockCatalogService.h +++ b/source/libs/parser/test/mockCatalogService.h @@ -59,6 +59,7 @@ public: int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const; int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const; + int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const; private: std::unique_ptr impl_;