diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8cb1d710028be170a1249b7cf4b2baccaa7ec1..681559a37bee3ad4e4ac92e43785c8dfedd2f996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ if(${BUILD_TEST}) enable_testing() endif(${BUILD_TEST}) add_subdirectory(source) +add_subdirectory(tools) # docs add_subdirectory(docs) diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h index f8652bec9a25c4933fe0a4d24ee4dea2a724470f..5d12780a3b44c0246de60931911cd0bd79c1e574 100644 --- a/include/common/taosmsg.h +++ b/include/common/taosmsg.h @@ -783,12 +783,8 @@ typedef struct { } SAuthVnodeMsg; typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; -} SStbInfoMsg; - -typedef struct { - SMsgHead msgHead; - char tableFname[TSDB_TABLE_FNAME_LEN]; + int32_t vgId; + char tableFname[TSDB_TABLE_FNAME_LEN]; } STableInfoMsg; typedef struct { @@ -799,10 +795,6 @@ typedef struct { char tableNames[]; } SMultiTableInfoMsg; -typedef struct SSTableVgroupMsg { - int32_t numOfTables; -} SSTableVgroupMsg, SSTableVgroupRspMsg; - typedef struct SVgroupInfo { int32_t vgId; uint32_t hashBegin; @@ -812,12 +804,6 @@ typedef struct SVgroupInfo { SEpAddrMsg epAddr[TSDB_MAX_REPLICA]; } SVgroupInfo; -typedef struct SVgroupListRspMsg { - int32_t vgroupNum; - int32_t vgroupVersion; - SVgroupInfo vgroupInfo[]; -} SVgroupListRspMsg; - typedef struct { int32_t vgId; int8_t numOfEps; @@ -839,8 +825,8 @@ typedef struct { int8_t update; int32_t sversion; int32_t tversion; - uint64_t tuid; uint64_t suid; + uint64_t tuid; int32_t vgId; SSchema pSchema[]; } STableMetaMsg; diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index a7d418d45e5dd2093188a5340ab241619623b3c8..28d9a0451346b930115d1e3d4da3ad9e7ee077ee 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -34,6 +34,13 @@ enum OPERATOR_TYPE_E { OP_TotalNum }; +enum DATASINK_TYPE_E { + DSINK_Unknown, + DSINK_Dispatch, + DSINK_Insert, + DSINK_TotalNum +}; + struct SEpSet; struct SQueryStmtInfo; @@ -49,6 +56,22 @@ typedef struct SQueryNodeBasicInfo { const char *name; // operator name } SQueryNodeBasicInfo; +typedef struct SDataSink { + SQueryNodeBasicInfo info; + SDataBlockSchema schema; +} SDataSink; + +typedef struct SDataDispatcher { + SDataSink sink; + // todo +} SDataDispatcher; + +typedef struct SDataInserter { + SDataSink sink; + uint64_t uid; // unique id of the table + // todo data field +} SDataInserter; + typedef struct SPhyNode { SQueryNodeBasicInfo info; SArray *pTargets; // target list to be computed or scanned at this node @@ -113,15 +136,16 @@ typedef struct SQueryDag { */ int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, struct SQueryDag** pDag); -int32_t qSetSuplanExecutionNode(SArray* subplans, SArray* nodes); +int32_t qSetSuplanExecutionNode(SSubplan* subplan, SArray* nodes); int32_t qExplainQuery(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, char** str); - /** * Convert to subplan to string for the scheduler to send to the executor */ -int32_t qSubPlanToString(struct SSubplan *pPhyNode, char** str); +int32_t qSubPlanToString(const SSubplan* subplan, char** str); + +int32_t qStringToSubplan(const char* str, SSubplan** subplan); /** * Destroy the physical plan. diff --git a/include/libs/planner/plannerOp.h b/include/libs/planner/plannerOp.h index 9f51969dc1d00028a3fcf6a508966d7e787bdcb5..41d6e028cf026aca203737567028a20e7a511c57 100644 --- a/include/libs/planner/plannerOp.h +++ b/include/libs/planner/plannerOp.h @@ -14,13 +14,13 @@ */ #if defined(INCLUDE_AS_ENUM) // enum define mode - #undef OP_ENUM_MACRO - #define OP_ENUM_MACRO(op) OP_##op, + #undef OP_ENUM_MACRO + #define OP_ENUM_MACRO(op) OP_##op, #elif defined(INCLUDE_AS_NAME) // comment define mode - #undef OP_ENUM_MACRO - #define OP_ENUM_MACRO(op) #op, + #undef OP_ENUM_MACRO + #define OP_ENUM_MACRO(op) #op, #else - #error To use this include file, first define either INCLUDE_AS_ENUM or INCLUDE_AS_NAME + #error To use this include file, first define either INCLUDE_AS_ENUM or INCLUDE_AS_NAME #endif OP_ENUM_MACRO(TableScan) diff --git a/include/libs/query/query.h b/include/libs/query/query.h index d92f7d449728bc0626aa7ff7ef5a23244d7af8f8..f8c7d787ba1c44b23e9354b6c03e7296234959c0 100644 --- a/include/libs/query/query.h +++ b/include/libs/query/query.h @@ -24,8 +24,6 @@ extern "C" { #include "thash.h" #include "tlog.h" -typedef SVgroupListRspMsg SVgroupListInfo; - typedef struct STableComInfo { uint8_t numOfTags; // the number of tags in schema uint8_t precision; // the number of precision diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index d73e388c20713fcadd0497de3ce21dc982a0e8d9..40c85520d4349fbd9ea39f84c2eabd6d78eab17b 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -67,6 +67,8 @@ int32_t scheduleFetchRows(void *pJob, void *data); */ int32_t scheduleCancelJob(void *pJob); +void scheduleFreeJob(void *pJob); + #ifdef __cplusplus } #endif diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 689d2676d1de5a2758ac3f80eb28e960ce8e441c..74263667ea0274f9d52e25d837d2125b0334827b 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -206,44 +206,28 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392) // mnode-stable -#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_IGEXIST TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_COLS_NUM TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_TAGS_NUM TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_COL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_COL_ID TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_COL_BYTES TAOS_DEF_ERROR_CODE(0, 0x0360) -#define TSDB_CODE_MND_STB_INVALID_COL_NAME TAOS_DEF_ERROR_CODE(0, 0x0360) - - -#define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) //"Table name too long") -#define TSDB_CODE_MND_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0362) //"Table does not exist") -#define TSDB_CODE_MND_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0363) //"Invalid table type in tsdb") -#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x0364) //"Too many tags") -#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x0365) //"Too many columns") -#define TSDB_CODE_MND_TOO_MANY_TIMESERIES TAOS_DEF_ERROR_CODE(0, 0x0366) //"Too many time series") -#define TSDB_CODE_MND_NOT_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x0367) //"Not super table") // operation only available for super table -#define TSDB_CODE_MND_COL_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x0368) //"Tag name too long") -#define TSDB_CODE_MND_TAG_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0369) //"Tag already exists") -#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036A) //"Tag does not exist") -#define TSDB_CODE_MND_FIELD_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x036B) //"Field already exists") -#define TSDB_CODE_MND_FIELD_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036C) //"Field does not exist") -#define TSDB_CODE_MND_INVALID_STABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x036D) //"Super table does not exist") -#define TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG TAOS_DEF_ERROR_CODE(0, 0x036E) //"Invalid create table message") -#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F) //"Exceed max row bytes") - -#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0370) -#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371) -#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x0372) -#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0373) -#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0374) -#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0375) -#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0376) - -#define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) //"invalid tag length") -#define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) //"invalid column length") - +#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0) +#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A1) +#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03A2) +#define TSDB_CODE_MND_INVALID_STB TAOS_DEF_ERROR_CODE(0, 0x03A3) +#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A4) +#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A5) +#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A6) +#define TSDB_CODE_MND_TAG_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A7) +#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A8) +#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9) +#define TSDB_CODE_MND_COLUMN_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA) +#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB) +#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC) + +// mnode-func +#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0) +#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C1) +#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x03C2) +#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x03C3) +#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x03C4) +#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x03C5) +#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x03C6) // dnode #define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400) @@ -506,6 +490,11 @@ int32_t* taosGetErrno(); #define TSDB_CODE_CTG_MEM_ERROR TAOS_DEF_ERROR_CODE(0, 0x2403) //catalog memory error #define TSDB_CODE_CTG_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2404) //catalog system error +//scheduler +#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501) //scheduler status error + + + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/impl/src/dndTransport.c b/source/dnode/mgmt/impl/src/dndTransport.c index 1db92644aee88ed8c8a3a7721ada85cefcd23022..3402d3ff68f398329109d73813d8538b2347f1f0 100644 --- a/source/dnode/mgmt/impl/src/dndTransport.c +++ b/source/dnode/mgmt/impl/src/dndTransport.c @@ -38,7 +38,7 @@ static void dndInitMsgFp(STransMgmt *pMgmt) { pMgmt->msgFp[TSDB_MSG_TYPE_DROP_TABLE] = dndProcessVnodeWriteMsg; pMgmt->msgFp[TSDB_MSG_TYPE_ALTER_TABLE] = dndProcessVnodeWriteMsg; pMgmt->msgFp[TSDB_MSG_TYPE_UPDATE_TAG_VAL] = dndProcessVnodeWriteMsg; - pMgmt->msgFp[TSDB_MSG_TYPE_TABLE_META] = dndProcessVnodeQueryMsg; + pMgmt->msgFp[TSDB_MSG_TYPE_TABLE_META] = dndProcessMnodeReadMsg; pMgmt->msgFp[TSDB_MSG_TYPE_TABLES_META] = dndProcessVnodeQueryMsg; pMgmt->msgFp[TSDB_MSG_TYPE_MQ_QUERY] = dndProcessVnodeQueryMsg; pMgmt->msgFp[TSDB_MSG_TYPE_MQ_CONSUME] = dndProcessVnodeQueryMsg; diff --git a/source/dnode/mgmt/impl/test/CMakeLists.txt b/source/dnode/mgmt/impl/test/CMakeLists.txt index 86186f77de7d05a635bbca7a2090025a9098dec3..8c6d146fb63ba70e66faf4e9118f59d9850778ed 100644 --- a/source/dnode/mgmt/impl/test/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/CMakeLists.txt @@ -1,15 +1,16 @@ +enable_testing() add_subdirectory(acct) # add_subdirectory(auth) # add_subdirectory(balance) -# add_subdirectory(cluster) +add_subdirectory(cluster) add_subdirectory(db) add_subdirectory(dnode) # add_subdirectory(func) # add_subdirectory(mnode) # add_subdirectory(profile) # add_subdirectory(show) -# add_subdirectory(stb) +add_subdirectory(stb) # add_subdirectory(sync) # add_subdirectory(telem) # add_subdirectory(trans) diff --git a/source/dnode/mgmt/impl/test/acct/CMakeLists.txt b/source/dnode/mgmt/impl/test/acct/CMakeLists.txt index a548c2adc2d32a4a525acd1ab9bcbf23dcf4ce05..8b160fc446b2f501e8f2ece4e76e1dbc27a77a74 100644 --- a/source/dnode/mgmt/impl/test/acct/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/acct/CMakeLists.txt @@ -21,8 +21,6 @@ target_include_directories(dnode_test_acct "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( NAME dnode_test_acct COMMAND dnode_test_acct diff --git a/source/dnode/mgmt/impl/test/acct/acct.cpp b/source/dnode/mgmt/impl/test/acct/acct.cpp index 6de8c70ba9e02f517550edc8f5f967f343e820e6..e2b819da2828dc4f7d4d0a915edf76c1bc29a06c 100644 --- a/source/dnode/mgmt/impl/test/acct/acct.cpp +++ b/source/dnode/mgmt/impl/test/acct/acct.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file acct.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module acct-msg tests * @version 0.1 diff --git a/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt b/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt index b513f290e4f1dfa5fba08d057643ee50d2eb232f..e97ef7688140bc4d85a7d1a734b21a6b586c1297 100644 --- a/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt @@ -1,29 +1,27 @@ -add_executable(dndTestCluster "") +add_executable(dnode_test_cluster "") -target_sources(dndTestCluster +target_sources(dnode_test_cluster PRIVATE "cluster.cpp" "../sut/deploy.cpp" ) target_link_libraries( - dndTestCluster + dnode_test_cluster PUBLIC dnode PUBLIC util PUBLIC os PUBLIC gtest_main ) -target_include_directories(dndTestCluster +target_include_directories(dnode_test_cluster PUBLIC "${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt" "${CMAKE_CURRENT_SOURCE_DIR}/../../inc" "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( - NAME dndTestCluster - COMMAND dndTestCluster + NAME dnode_test_cluster + COMMAND dnode_test_cluster ) diff --git a/source/dnode/mgmt/impl/test/cluster/cluster.cpp b/source/dnode/mgmt/impl/test/cluster/cluster.cpp index 4e1dbf8911962e509fb2a698e5be2bafe600fec4..0aca2fde4badaa17b6fa70186ed9ad157c588678 100644 --- a/source/dnode/mgmt/impl/test/cluster/cluster.cpp +++ b/source/dnode/mgmt/impl/test/cluster/cluster.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file cluster.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module cluster-msg tests * @version 0.1 @@ -13,154 +13,158 @@ class DndTestCluster : public ::testing::Test { protected: - void SetUp() override {} - void TearDown() override {} + static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) { + SServer* pServer = createServer(path, fqdn, port, firstEp); + ASSERT(pServer); + return pServer; + } static void SetUpTestSuite() { - const char* user = "root"; - const char* pass = "taosdata"; - const char* path = "/tmp/dndTestCluster"; - const char* fqdn = "localhost"; - uint16_t port = 9521; + initLog("/tmp/tdlog"); - pServer = createServer(path, fqdn, port); - ASSERT(pServer); - pClient = createClient(user, pass, fqdn, port); + const char* fqdn = "localhost"; + const char* firstEp = "localhost:9030"; + pServer = CreateServer("/tmp/dnode_test_cluster", fqdn, 9030, firstEp); + pClient = createClient("root", "taosdata", fqdn, 9030); + taosMsleep(1100); } static void TearDownTestSuite() { stopServer(pServer); dropClient(pClient); + pServer = NULL; + pClient = NULL; } static SServer* pServer; static SClient* pClient; static int32_t connId; -}; -SServer* DndTestCluster::pServer; -SClient* DndTestCluster::pClient; -int32_t DndTestCluster::connId; + public: + void SetUp() override {} + void TearDown() override {} -TEST_F(DndTestCluster, ShowCluster) { - ASSERT_NE(pClient, nullptr); - int32_t showId = 0; - - { - SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); - pReq->type = TSDB_MGMT_TABLE_CLUSTER; - strcpy(pReq->db, ""); - - SRpcMsg rpcMsg = {0}; - rpcMsg.pCont = pReq; - rpcMsg.contLen = sizeof(SShowMsg); - rpcMsg.msgType = TSDB_MSG_TYPE_SHOW; - - sendMsg(pClient, &rpcMsg); - SRpcMsg* pMsg = pClient->pRsp; - ASSERT_NE(pMsg, nullptr); - - SShowRsp* pRsp = (SShowRsp*)pMsg->pCont; - ASSERT_NE(pRsp, nullptr); - pRsp->showId = htonl(pRsp->showId); - STableMetaMsg* pMeta = &pRsp->tableMeta; - pMeta->contLen = htonl(pMeta->contLen); - pMeta->numOfColumns = htons(pMeta->numOfColumns); - pMeta->sversion = htons(pMeta->sversion); - pMeta->tversion = htons(pMeta->tversion); - pMeta->tid = htonl(pMeta->tid); - pMeta->uid = htobe64(pMeta->uid); + void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns, const char* db) { + SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); + pShow->type = showType; + if (db != NULL) { + strcpy(pShow->db, db); + } + SRpcMsg showRpcMsg = {0}; + showRpcMsg.pCont = pShow; + showRpcMsg.contLen = sizeof(SShowMsg); + showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW; + + sendMsg(pClient, &showRpcMsg); + ASSERT_NE(pClient->pRsp, nullptr); + ASSERT_EQ(pClient->pRsp->code, 0); + ASSERT_NE(pClient->pRsp->pCont, nullptr); + + SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont; + ASSERT_NE(pShowRsp, nullptr); + pShowRsp->showId = htonl(pShowRsp->showId); + pMeta = &pShowRsp->tableMeta; + pMeta->numOfTags = htonl(pMeta->numOfTags); + pMeta->numOfColumns = htonl(pMeta->numOfColumns); + pMeta->sversion = htonl(pMeta->sversion); + pMeta->tversion = htonl(pMeta->tversion); + pMeta->tuid = htobe64(pMeta->tuid); pMeta->suid = htobe64(pMeta->suid); - showId = pRsp->showId; + showId = pShowRsp->showId; - EXPECT_NE(pRsp->showId, 0); - EXPECT_EQ(pMeta->contLen, 0); - EXPECT_STREQ(pMeta->tbFname, "show cluster"); + EXPECT_NE(pShowRsp->showId, 0); + EXPECT_STREQ(pMeta->tbFname, showName); EXPECT_EQ(pMeta->numOfTags, 0); + EXPECT_EQ(pMeta->numOfColumns, columns); EXPECT_EQ(pMeta->precision, 0); EXPECT_EQ(pMeta->tableType, 0); - EXPECT_EQ(pMeta->numOfColumns, 3); + EXPECT_EQ(pMeta->update, 0); EXPECT_EQ(pMeta->sversion, 0); EXPECT_EQ(pMeta->tversion, 0); - EXPECT_EQ(pMeta->tid, 0); - EXPECT_EQ(pMeta->uid, 0); - EXPECT_STREQ(pMeta->sTableName, ""); + EXPECT_EQ(pMeta->tuid, 0); EXPECT_EQ(pMeta->suid, 0); + } - SSchema* pSchema = NULL; - pSchema = &pMeta->pSchema[0]; - pSchema->bytes = htons(pSchema->bytes); - EXPECT_EQ(pSchema->colId, 0); - EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT); - EXPECT_EQ(pSchema->bytes, 4); - EXPECT_STREQ(pSchema->name, "id"); - - pSchema = &pMeta->pSchema[1]; - pSchema->bytes = htons(pSchema->bytes); + void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) { + SSchema* pSchema = &pMeta->pSchema[index]; + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); - EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY); - EXPECT_EQ(pSchema->bytes, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE); - EXPECT_STREQ(pSchema->name, "name"); + EXPECT_EQ(pSchema->type, type); + EXPECT_EQ(pSchema->bytes, bytes); + EXPECT_STREQ(pSchema->name, name); + } - pSchema = &pMeta->pSchema[2]; - pSchema->bytes = htons(pSchema->bytes); - EXPECT_EQ(pSchema->colId, 0); - EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); - EXPECT_EQ(pSchema->bytes, 8); - EXPECT_STREQ(pSchema->name, "create_time"); + void SendThenCheckShowRetrieveMsg(int32_t rows) { + SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg)); + pRetrieve->showId = htonl(showId); + pRetrieve->free = 0; + + SRpcMsg retrieveRpcMsg = {0}; + retrieveRpcMsg.pCont = pRetrieve; + retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg); + retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE; + + sendMsg(pClient, &retrieveRpcMsg); + + ASSERT_NE(pClient->pRsp, nullptr); + ASSERT_EQ(pClient->pRsp->code, 0); + ASSERT_NE(pClient->pRsp->pCont, nullptr); + + pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont; + ASSERT_NE(pRetrieveRsp, nullptr); + pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); + pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); + pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); + + EXPECT_EQ(pRetrieveRsp->numOfRows, rows); + EXPECT_EQ(pRetrieveRsp->useconds, 0); + // EXPECT_EQ(pRetrieveRsp->completed, completed); + EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); + EXPECT_EQ(pRetrieveRsp->compressed, 0); + EXPECT_EQ(pRetrieveRsp->compLen, 0); + + pData = pRetrieveRsp->data; + pos = 0; } - { - SRetrieveTableMsg* pReq = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg)); - pReq->showId = htonl(showId); - pReq->free = 0; - - SRpcMsg rpcMsg = {0}; - rpcMsg.pCont = pReq; - rpcMsg.contLen = sizeof(SRetrieveTableMsg); - rpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE; - - sendMsg(pClient, &rpcMsg); - SRpcMsg* pMsg = pClient->pRsp; - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); - - SRetrieveTableRsp* pRsp = (SRetrieveTableRsp*)pMsg->pCont; - ASSERT_NE(pRsp, nullptr); - pRsp->numOfRows = htonl(pRsp->numOfRows); - pRsp->offset = htobe64(pRsp->offset); - pRsp->useconds = htobe64(pRsp->useconds); - pRsp->compLen = htonl(pRsp->compLen); - - EXPECT_EQ(pRsp->numOfRows, 1); - EXPECT_EQ(pRsp->offset, 0); - EXPECT_EQ(pRsp->useconds, 0); - EXPECT_EQ(pRsp->completed, 1); - EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI); - EXPECT_EQ(pRsp->compressed, 0); - EXPECT_EQ(pRsp->reserved, 0); - EXPECT_EQ(pRsp->compLen, 0); - - char* pData = pRsp->data; - int32_t pos = 0; - - int32_t id = *((int32_t*)(pData + pos)); + void CheckInt32() { + int32_t data = *((int32_t*)(pData + pos)); pos += sizeof(int32_t); + EXPECT_GT(data, 0); + } - int32_t nameLen = varDataLen(pData + pos); + void CheckTimestamp() { + int64_t data = *((int64_t*)(pData + pos)); + pos += sizeof(int64_t); + EXPECT_GT(data, 0); + } + + void CheckBinary(int32_t len) { pos += sizeof(VarDataLenT); + char* data = (char*)(pData + pos); + pos += len; + } - char* name = (char*)(pData + pos); - pos += TSDB_CLUSTER_ID_LEN; + int32_t showId; + STableMetaMsg* pMeta; + SRetrieveTableRsp* pRetrieveRsp; + char* pData; + int32_t pos; +}; - int64_t create_time = *((int64_t*)(pData + pos)); - pos += sizeof(int64_t); +SServer* DndTestCluster::pServer; +SClient* DndTestCluster::pClient; +int32_t DndTestCluster::connId; - EXPECT_NE(id, 0); - EXPECT_EQ(nameLen, 36); - EXPECT_STRNE(name, ""); - EXPECT_GT(create_time, 0); - printf("--- id:%d nameLen:%d name:%s time:%" PRId64 " --- \n", id, nameLen, name, create_time); - } +TEST_F(DndTestCluster, 01_ShowCluster) { + SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, "show cluster", 3, NULL); + CheckSchema(0, TSDB_DATA_TYPE_INT, 4, "id"); + CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); + CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + + SendThenCheckShowRetrieveMsg(1); + CheckInt32(); + CheckBinary(TSDB_CLUSTER_ID_LEN); + CheckTimestamp(); } \ No newline at end of file diff --git a/source/dnode/mgmt/impl/test/db/CMakeLists.txt b/source/dnode/mgmt/impl/test/db/CMakeLists.txt index b778e3854f56325682b01334ba78ae23b22e0eae..db96e2bad32eff4e99e6a3c68421608f655f18ec 100644 --- a/source/dnode/mgmt/impl/test/db/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/db/CMakeLists.txt @@ -21,8 +21,6 @@ target_include_directories(dnode_test_db "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( NAME dnode_test_db COMMAND dnode_test_db diff --git a/source/dnode/mgmt/impl/test/db/db.cpp b/source/dnode/mgmt/impl/test/db/db.cpp index 6821dec0a6c83e75412ddd3cacdb105481ccbc69..de1a606c862351e694319081202b4a0d2ba6d357 100644 --- a/source/dnode/mgmt/impl/test/db/db.cpp +++ b/source/dnode/mgmt/impl/test/db/db.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file db.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module db-msg tests * @version 0.1 @@ -88,7 +88,7 @@ class DndTestDb : public ::testing::Test { void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) { SSchema* pSchema = &pMeta->pSchema[index]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, type); EXPECT_EQ(pSchema->bytes, bytes); @@ -114,17 +114,14 @@ class DndTestDb : public ::testing::Test { pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont; ASSERT_NE(pRetrieveRsp, nullptr); pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); - pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset); pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); EXPECT_EQ(pRetrieveRsp->numOfRows, rows); - EXPECT_EQ(pRetrieveRsp->offset, 0); EXPECT_EQ(pRetrieveRsp->useconds, 0); // EXPECT_EQ(pRetrieveRsp->completed, completed); EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); EXPECT_EQ(pRetrieveRsp->compressed, 0); - EXPECT_EQ(pRetrieveRsp->reserved, 0); EXPECT_EQ(pRetrieveRsp->compLen, 0); pData = pRetrieveRsp->data; @@ -182,13 +179,13 @@ int32_t DndTestDb::connId; TEST_F(DndTestDb, 01_ShowDb) { SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL); CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); - CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time"); + CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups"); CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "replica"); CheckSchema(4, TSDB_DATA_TYPE_SMALLINT, 2, "quorum"); CheckSchema(5, TSDB_DATA_TYPE_SMALLINT, 2, "days"); CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2"); - CheckSchema(7, TSDB_DATA_TYPE_INT, 4, "cache(MB)"); + CheckSchema(7, TSDB_DATA_TYPE_INT, 4, "cache"); CheckSchema(8, TSDB_DATA_TYPE_INT, 4, "blocks"); CheckSchema(9, TSDB_DATA_TYPE_INT, 4, "minrows"); CheckSchema(10, TSDB_DATA_TYPE_INT, 4, "maxrows"); diff --git a/source/dnode/mgmt/impl/test/dnode/CMakeLists.txt b/source/dnode/mgmt/impl/test/dnode/CMakeLists.txt index ebe2f3c5eb8b20122349f3f83278dce6f65b8bff..48b74a4eff8c0e07f115c8cb4cfcd04448413319 100644 --- a/source/dnode/mgmt/impl/test/dnode/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/dnode/CMakeLists.txt @@ -21,8 +21,6 @@ target_include_directories(dnode_test_dnode "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( NAME dnode_test_dnode COMMAND dnode_test_dnode diff --git a/source/dnode/mgmt/impl/test/dnode/dnode.cpp b/source/dnode/mgmt/impl/test/dnode/dnode.cpp index f382f385d785889f5fd76c14e86277e2db9261f0..1fa91f26cb6edb13aa9588ef26d0f4136d0621c9 100644 --- a/source/dnode/mgmt/impl/test/dnode/dnode.cpp +++ b/source/dnode/mgmt/impl/test/dnode/dnode.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file dnode.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module dnode-msg tests * @version 0.1 @@ -81,8 +81,8 @@ class DndTestDnode : public ::testing::Test { pMeta->numOfTags = htonl(pMeta->numOfTags); pMeta->numOfColumns = htonl(pMeta->numOfColumns); pMeta->sversion = htonl(pMeta->sversion); - pMeta->tversion = htons(pMeta->tversion); - pMeta->tuid = htonl(pMeta->tuid); + pMeta->tversion = htonl(pMeta->tversion); + pMeta->tuid = htobe64(pMeta->tuid); pMeta->suid = htobe64(pMeta->suid); showId = pShowRsp->showId; @@ -102,7 +102,7 @@ class DndTestDnode : public ::testing::Test { void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) { SSchema* pSchema = &pMeta->pSchema[index]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, type); EXPECT_EQ(pSchema->bytes, bytes); @@ -128,17 +128,14 @@ class DndTestDnode : public ::testing::Test { pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont; ASSERT_NE(pRetrieveRsp, nullptr); pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); - pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset); pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); EXPECT_EQ(pRetrieveRsp->numOfRows, rows); - EXPECT_EQ(pRetrieveRsp->offset, 0); EXPECT_EQ(pRetrieveRsp->useconds, 0); // EXPECT_EQ(pRetrieveRsp->completed, completed); EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); EXPECT_EQ(pRetrieveRsp->compressed, 0); - EXPECT_EQ(pRetrieveRsp->reserved, 0); EXPECT_EQ(pRetrieveRsp->compLen, 0); pData = pRetrieveRsp->data; @@ -187,12 +184,12 @@ SClient* DndTestDnode::pClient; TEST_F(DndTestDnode, 01_ShowDnode) { SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7); CheckSchema(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "end point"); + CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes"); - CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "max vnodes"); + CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "max_vnodes"); CheckSchema(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status"); - CheckSchema(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time"); - CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline reason"); + CheckSchema(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason"); SendThenCheckShowRetrieveMsg(1); CheckInt16(1); diff --git a/source/dnode/mgmt/impl/test/profile/CMakeLists.txt b/source/dnode/mgmt/impl/test/profile/CMakeLists.txt index 2e99a2e53d983b0ea894ddbfcf0188c144650e90..d8e4eae0426037ecf20a7888a18360ccdd023391 100644 --- a/source/dnode/mgmt/impl/test/profile/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/profile/CMakeLists.txt @@ -21,8 +21,6 @@ target_include_directories(dndTestProfile "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( NAME dndTestProfile COMMAND dndTestProfile diff --git a/source/dnode/mgmt/impl/test/profile/profile.cpp b/source/dnode/mgmt/impl/test/profile/profile.cpp index e2dbeb1a5b819803d8900f91f34d636e9ab658d6..f1e4704777b1794ce8ff3bc183eeb34551b3db53 100644 --- a/source/dnode/mgmt/impl/test/profile/profile.cpp +++ b/source/dnode/mgmt/impl/test/profile/profile.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file profile.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module profile-msg tests * @version 0.1 @@ -216,17 +216,14 @@ TEST_F(DndTestProfile, SConnectMsg_03) { SRetrieveTableRsp* pRsp = (SRetrieveTableRsp*)pMsg->pCont; ASSERT_NE(pRsp, nullptr); pRsp->numOfRows = htonl(pRsp->numOfRows); - pRsp->offset = htobe64(pRsp->offset); pRsp->useconds = htobe64(pRsp->useconds); pRsp->compLen = htonl(pRsp->compLen); EXPECT_EQ(pRsp->numOfRows, 1); - EXPECT_EQ(pRsp->offset, 0); EXPECT_EQ(pRsp->useconds, 0); EXPECT_EQ(pRsp->completed, 1); EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI); EXPECT_EQ(pRsp->compressed, 0); - EXPECT_EQ(pRsp->reserved, 0); EXPECT_EQ(pRsp->compLen, 0); } } @@ -497,7 +494,7 @@ TEST_F(DndTestProfile, SKillQueryMsg_03) { EXPECT_STREQ(pSchema->name, "queryId"); pSchema = &pMeta->pSchema[1]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT); EXPECT_EQ(pSchema->bytes, 4); diff --git a/source/dnode/mgmt/impl/test/show/CMakeLists.txt b/source/dnode/mgmt/impl/test/show/CMakeLists.txt index 5f1596ce95b6c3815be65d7f2822bfac62e60aef..b3dc3297a8a8926707fc3d409555e0cdefff9c70 100644 --- a/source/dnode/mgmt/impl/test/show/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/show/CMakeLists.txt @@ -1,29 +1,27 @@ -add_executable(dndTestShow "") +add_executable(dnode_test_show "") -target_sources(dndTestShow +target_sources(dnode_test_show PRIVATE "show.cpp" "../sut/deploy.cpp" ) target_link_libraries( - dndTestShow + dnode_test_show PUBLIC dnode PUBLIC util PUBLIC os PUBLIC gtest_main ) -target_include_directories(dndTestShow +target_include_directories(dnode_test_show PUBLIC "${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt" "${CMAKE_CURRENT_SOURCE_DIR}/../../inc" "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( - NAME dndTestShow - COMMAND dndTestShow + NAME dnode_test_show + COMMAND dnode_test_show ) diff --git a/source/dnode/mgmt/impl/test/show/show.cpp b/source/dnode/mgmt/impl/test/show/show.cpp index 06e8d42ad4087ca9e517ebd4076508ec00265b9b..f0c20f71e572640a190c724bab5cf9cf343dab7f 100644 --- a/source/dnode/mgmt/impl/test/show/show.cpp +++ b/source/dnode/mgmt/impl/test/show/show.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file show.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module show-msg tests * @version 0.1 @@ -151,49 +151,49 @@ TEST_F(DndTestShow, SShowMsg_04) { SSchema* pSchema = NULL; pSchema = &pMeta->pSchema[0]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT); EXPECT_EQ(pSchema->bytes, 4); EXPECT_STREQ(pSchema->name, "connId"); pSchema = &pMeta->pSchema[1]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY); EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE); EXPECT_STREQ(pSchema->name, "user"); pSchema = &pMeta->pSchema[2]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY); EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE); EXPECT_STREQ(pSchema->name, "program"); pSchema = &pMeta->pSchema[3]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT); EXPECT_EQ(pSchema->bytes, 4); EXPECT_STREQ(pSchema->name, "pid"); pSchema = &pMeta->pSchema[4]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY); EXPECT_EQ(pSchema->bytes, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE); EXPECT_STREQ(pSchema->name, "ip:port"); pSchema = &pMeta->pSchema[5]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); EXPECT_EQ(pSchema->bytes, 8); EXPECT_STREQ(pSchema->name, "login_time"); pSchema = &pMeta->pSchema[6]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); EXPECT_EQ(pSchema->bytes, 8); diff --git a/source/dnode/mgmt/impl/test/stb/CMakeLists.txt b/source/dnode/mgmt/impl/test/stb/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..524e3e5c7ee5fdb65830c7cdcb32e5cfa985606b --- /dev/null +++ b/source/dnode/mgmt/impl/test/stb/CMakeLists.txt @@ -0,0 +1,27 @@ +add_executable(dnode_test_stb "") + +target_sources(dnode_test_stb + PRIVATE + "stb.cpp" + "../sut/deploy.cpp" +) + +target_link_libraries( + dnode_test_stb + PUBLIC dnode + PUBLIC util + PUBLIC os + PUBLIC gtest_main +) + +target_include_directories(dnode_test_stb + PUBLIC + "${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt" + "${CMAKE_CURRENT_SOURCE_DIR}/../../inc" + "${CMAKE_CURRENT_SOURCE_DIR}/../sut" +) + +add_test( + NAME dnode_test_stb + COMMAND dnode_test_stb +) diff --git a/source/dnode/mgmt/impl/test/stb/stb.cpp b/source/dnode/mgmt/impl/test/stb/stb.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee8c86bcea3b5764ca3158deabbced027b70d4ee --- /dev/null +++ b/source/dnode/mgmt/impl/test/stb/stb.cpp @@ -0,0 +1,374 @@ +/** + * @file stb.cpp + * @author slguan (slguan@taosdata.com) + * @brief DNODE module db-msg tests + * @version 0.1 + * @date 2021-12-17 + * + * @copyright Copyright (c) 2021 + * + */ + +#include "deploy.h" + +class DndTestStb : public ::testing::Test { + protected: + static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) { + SServer* pServer = createServer(path, fqdn, port, firstEp); + ASSERT(pServer); + return pServer; + } + + static void SetUpTestSuite() { + initLog("/tmp/tdlog"); + + const char* fqdn = "localhost"; + const char* firstEp = "localhost:9101"; + pServer = CreateServer("/tmp/dnode_test_stb", fqdn, 9101, firstEp); + pClient = createClient("root", "taosdata", fqdn, 9101); + taosMsleep(1100); + } + + static void TearDownTestSuite() { + stopServer(pServer); + dropClient(pClient); + pServer = NULL; + pClient = NULL; + } + + static SServer* pServer; + static SClient* pClient; + static int32_t connId; + + public: + void SetUp() override {} + void TearDown() override {} + + void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns, const char* db) { + SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); + pShow->type = showType; + if (db != NULL) { + strcpy(pShow->db, db); + } + SRpcMsg showRpcMsg = {0}; + showRpcMsg.pCont = pShow; + showRpcMsg.contLen = sizeof(SShowMsg); + showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW; + + sendMsg(pClient, &showRpcMsg); + ASSERT_NE(pClient->pRsp, nullptr); + ASSERT_EQ(pClient->pRsp->code, 0); + ASSERT_NE(pClient->pRsp->pCont, nullptr); + + SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont; + ASSERT_NE(pShowRsp, nullptr); + pShowRsp->showId = htonl(pShowRsp->showId); + pMeta = &pShowRsp->tableMeta; + pMeta->numOfTags = htonl(pMeta->numOfTags); + pMeta->numOfColumns = htonl(pMeta->numOfColumns); + pMeta->sversion = htonl(pMeta->sversion); + pMeta->tversion = htonl(pMeta->tversion); + pMeta->tuid = htobe64(pMeta->tuid); + pMeta->suid = htobe64(pMeta->suid); + + showId = pShowRsp->showId; + + EXPECT_NE(pShowRsp->showId, 0); + EXPECT_STREQ(pMeta->tbFname, showName); + EXPECT_EQ(pMeta->numOfTags, 0); + EXPECT_EQ(pMeta->numOfColumns, columns); + EXPECT_EQ(pMeta->precision, 0); + EXPECT_EQ(pMeta->tableType, 0); + EXPECT_EQ(pMeta->update, 0); + EXPECT_EQ(pMeta->sversion, 0); + EXPECT_EQ(pMeta->tversion, 0); + EXPECT_EQ(pMeta->tuid, 0); + EXPECT_EQ(pMeta->suid, 0); + } + + void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) { + SSchema* pSchema = &pMeta->pSchema[index]; + pSchema->bytes = htonl(pSchema->bytes); + EXPECT_EQ(pSchema->colId, 0); + EXPECT_EQ(pSchema->type, type); + EXPECT_EQ(pSchema->bytes, bytes); + EXPECT_STREQ(pSchema->name, name); + } + + void SendThenCheckShowRetrieveMsg(int32_t rows) { + SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg)); + pRetrieve->showId = htonl(showId); + pRetrieve->free = 0; + + SRpcMsg retrieveRpcMsg = {0}; + retrieveRpcMsg.pCont = pRetrieve; + retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg); + retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE; + + sendMsg(pClient, &retrieveRpcMsg); + + ASSERT_NE(pClient->pRsp, nullptr); + ASSERT_EQ(pClient->pRsp->code, 0); + ASSERT_NE(pClient->pRsp->pCont, nullptr); + + pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont; + ASSERT_NE(pRetrieveRsp, nullptr); + pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); + pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); + pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); + + EXPECT_EQ(pRetrieveRsp->numOfRows, rows); + EXPECT_EQ(pRetrieveRsp->useconds, 0); + // EXPECT_EQ(pRetrieveRsp->completed, completed); + EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); + EXPECT_EQ(pRetrieveRsp->compressed, 0); + EXPECT_EQ(pRetrieveRsp->compLen, 0); + + pData = pRetrieveRsp->data; + pos = 0; + } + + void CheckInt8(int8_t val) { + int8_t data = *((int8_t*)(pData + pos)); + pos += sizeof(int8_t); + EXPECT_EQ(data, val); + } + + void CheckInt16(int16_t val) { + int16_t data = *((int16_t*)(pData + pos)); + pos += sizeof(int16_t); + EXPECT_EQ(data, val); + } + + void CheckInt32(int32_t val) { + int32_t data = *((int32_t*)(pData + pos)); + pos += sizeof(int32_t); + EXPECT_EQ(data, val); + } + + void CheckInt64(int64_t val) { + int64_t data = *((int64_t*)(pData + pos)); + pos += sizeof(int64_t); + EXPECT_EQ(data, val); + } + + void CheckTimestamp() { + int64_t data = *((int64_t*)(pData + pos)); + pos += sizeof(int64_t); + EXPECT_GT(data, 0); + } + + void CheckBinary(const char* val, int32_t len) { + pos += sizeof(VarDataLenT); + char* data = (char*)(pData + pos); + pos += len; + EXPECT_STREQ(data, val); + } + + int32_t showId; + STableMetaMsg* pMeta; + SRetrieveTableRsp* pRetrieveRsp; + char* pData; + int32_t pos; +}; + +SServer* DndTestStb::pServer; +SClient* DndTestStb::pClient; +int32_t DndTestStb::connId; + +TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { + { + SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(sizeof(SCreateDbMsg)); + strcpy(pReq->db, "1.d1"); + pReq->numOfVgroups = htonl(2); + pReq->cacheBlockSize = htonl(16); + pReq->totalBlocks = htonl(10); + pReq->daysPerFile = htonl(10); + pReq->daysToKeep0 = htonl(3650); + pReq->daysToKeep1 = htonl(3650); + pReq->daysToKeep2 = htonl(3650); + pReq->minRowsPerFileBlock = htonl(100); + pReq->maxRowsPerFileBlock = htonl(4096); + pReq->commitTime = htonl(3600); + pReq->fsyncPeriod = htonl(3000); + pReq->walLevel = 1; + pReq->precision = 0; + pReq->compression = 2; + pReq->replications = 1; + pReq->quorum = 1; + pReq->update = 0; + pReq->cacheLastRow = 0; + pReq->ignoreExist = 1; + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = sizeof(SCreateDbMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_DB; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + } + + { + int32_t cols = 2; + int32_t tags = 3; + int32_t size = (tags + cols) * sizeof(SSchema) + sizeof(SCreateStbMsg); + + SCreateStbMsg* pReq = (SCreateStbMsg*)rpcMallocCont(size); + strcpy(pReq->name, "1.d1.stb"); + pReq->numOfTags = htonl(tags); + pReq->numOfColumns = htonl(cols); + + { + SSchema* pSchema = &pReq->pSchema[0]; + pSchema->colId = htonl(0); + pSchema->bytes = htonl(8); + pSchema->type = TSDB_DATA_TYPE_TIMESTAMP; + strcpy(pSchema->name, "ts"); + } + + { + SSchema* pSchema = &pReq->pSchema[1]; + pSchema->colId = htonl(1); + pSchema->bytes = htonl(4); + pSchema->type = TSDB_DATA_TYPE_INT; + strcpy(pSchema->name, "col1"); + } + + { + SSchema* pSchema = &pReq->pSchema[2]; + pSchema->colId = htonl(2); + pSchema->bytes = htonl(2); + pSchema->type = TSDB_DATA_TYPE_TINYINT; + strcpy(pSchema->name, "tag1"); + } + + { + SSchema* pSchema = &pReq->pSchema[3]; + pSchema->colId = htonl(3); + pSchema->bytes = htonl(8); + pSchema->type = TSDB_DATA_TYPE_BIGINT; + strcpy(pSchema->name, "tag2"); + } + + { + SSchema* pSchema = &pReq->pSchema[4]; + pSchema->colId = htonl(4); + pSchema->bytes = htonl(16); + pSchema->type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema->name, "tag3"); + } + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = size; + rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_STB; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + } + + SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1"); + CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); + CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + CheckSchema(2, TSDB_DATA_TYPE_INT, 4, "columns"); + CheckSchema(3, TSDB_DATA_TYPE_INT, 4, "tags"); + + SendThenCheckShowRetrieveMsg(1); + CheckBinary("stb", TSDB_TABLE_NAME_LEN); + CheckTimestamp(); + CheckInt32(2); + CheckInt32(3); + + // ----- meta ------ + { + STableInfoMsg* pReq = (STableInfoMsg*)rpcMallocCont(sizeof(STableInfoMsg)); + strcpy(pReq->tableFname, "1.d1.stb"); + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = sizeof(STableInfoMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_TABLE_META; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + + STableMetaMsg* pRsp = (STableMetaMsg*)pMsg->pCont; + pRsp->numOfTags = htonl(pRsp->numOfTags); + pRsp->numOfColumns = htonl(pRsp->numOfColumns); + pRsp->sversion = htonl(pRsp->sversion); + pRsp->tversion = htonl(pRsp->tversion); + pRsp->suid = htobe64(pRsp->suid); + pRsp->tuid = htobe64(pRsp->tuid); + pRsp->vgId = htobe64(pRsp->vgId); + for (int32_t i = 0; i < pRsp->numOfTags + pRsp->numOfColumns; ++i) { + SSchema* pSchema = &pRsp->pSchema[i]; + pSchema->colId = htonl(pSchema->colId); + pSchema->bytes = htonl(pSchema->bytes); + } + + EXPECT_STREQ(pRsp->tbFname, ""); + EXPECT_STREQ(pRsp->stbFname, "1.d1.stb"); + EXPECT_EQ(pRsp->numOfColumns, 2); + EXPECT_EQ(pRsp->numOfTags, 3); + EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI); + EXPECT_EQ(pRsp->tableType, TSDB_SUPER_TABLE); + EXPECT_EQ(pRsp->update, 0); + EXPECT_EQ(pRsp->sversion, 1); + EXPECT_EQ(pRsp->tversion, 0); + EXPECT_GT(pRsp->suid, 0); + EXPECT_EQ(pRsp->tuid, 0); + EXPECT_EQ(pRsp->vgId, 0); + + { + SSchema* pSchema = &pRsp->pSchema[0]; + EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); + EXPECT_EQ(pSchema->colId, 0); + EXPECT_EQ(pSchema->bytes, 8); + EXPECT_STREQ(pSchema->name, "ts"); + } + } + + // restart + stopServer(pServer); + pServer = NULL; + + uInfo("start all server"); + + const char* fqdn = "localhost"; + const char* firstEp = "localhost:9101"; + pServer = startServer("/tmp/dnode_test_stb", fqdn, 9101, firstEp); + + uInfo("all server is running"); + + SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1"); + SendThenCheckShowRetrieveMsg(1); + CheckBinary("stb", TSDB_TABLE_NAME_LEN); + CheckTimestamp(); + CheckInt32(2); + CheckInt32(3); + + { + SDropStbMsg* pReq = (SDropStbMsg*)rpcMallocCont(sizeof(SDropStbMsg)); + strcpy(pReq->name, "1.d1.stb"); + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = sizeof(SDropStbMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_DROP_STB; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + } + + SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1"); + SendThenCheckShowRetrieveMsg(0); +} diff --git a/source/dnode/mgmt/impl/test/user/CMakeLists.txt b/source/dnode/mgmt/impl/test/user/CMakeLists.txt index ca8f2ec6db61700893d2381e5c129cff1b6b5dad..0d3215a4d0445ab99c8180b31716b12841e21c34 100644 --- a/source/dnode/mgmt/impl/test/user/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/user/CMakeLists.txt @@ -21,8 +21,6 @@ target_include_directories(dnode_test_user "${CMAKE_CURRENT_SOURCE_DIR}/../sut" ) -enable_testing() - add_test( NAME dnode_test_user COMMAND dnode_test_user diff --git a/source/dnode/mgmt/impl/test/user/user.cpp b/source/dnode/mgmt/impl/test/user/user.cpp index 74e8e0db44d340360eb20688b11811b57cea6e99..32309b106e8f6aef905fb8fd8fb5c72e6d28ecda 100644 --- a/source/dnode/mgmt/impl/test/user/user.cpp +++ b/source/dnode/mgmt/impl/test/user/user.cpp @@ -1,5 +1,5 @@ /** - * @file vnodeApiTests.cpp + * @file user.cpp * @author slguan (slguan@taosdata.com) * @brief DNODE module user-msg tests * @version 0.1 @@ -87,7 +87,7 @@ class DndTestUser : public ::testing::Test { void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) { SSchema* pSchema = &pMeta->pSchema[index]; - pSchema->bytes = htons(pSchema->bytes); + pSchema->bytes = htonl(pSchema->bytes); EXPECT_EQ(pSchema->colId, 0); EXPECT_EQ(pSchema->type, type); EXPECT_EQ(pSchema->bytes, bytes); @@ -113,17 +113,14 @@ class DndTestUser : public ::testing::Test { pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont; ASSERT_NE(pRetrieveRsp, nullptr); pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); - pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset); pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); EXPECT_EQ(pRetrieveRsp->numOfRows, rows); - EXPECT_EQ(pRetrieveRsp->offset, 0); EXPECT_EQ(pRetrieveRsp->useconds, 0); // EXPECT_EQ(pRetrieveRsp->completed, completed); EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); EXPECT_EQ(pRetrieveRsp->compressed, 0); - EXPECT_EQ(pRetrieveRsp->reserved, 0); EXPECT_EQ(pRetrieveRsp->compLen, 0); pData = pRetrieveRsp->data; @@ -170,7 +167,7 @@ TEST_F(DndTestUser, 01_ShowUser) { SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4); CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name"); CheckSchema(1, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "privilege"); - CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time"); + CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CheckSchema(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account"); SendThenCheckShowRetrieveMsg(1); diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 258a96affe2b02e0a500968a42ee49a8dd24a030..188ca7963c7bfc8451e8547b96b61f4c67415cba 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -747,7 +747,7 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe pShow->bytes[cols] = 2; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; strcpy(pSchema[cols].name, "vgroups"); - pSchema[cols].bytes = htons(pShow->bytes[cols]); + pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; pShow->bytes[cols] = 2; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 91a229956f290c520b41dba18fe2c9fea38caaca..db6777ebf8129d41fac21b95d373246e96127bb8 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -291,7 +291,7 @@ char *mndShowStr(int32_t showType) { case TSDB_MGMT_TABLE_VNODES: return "show vnodes"; case TSDB_MGMT_TABLE_CLUSTER: - return "show clusters"; + return "show cluster"; case TSDB_MGMT_TABLE_STREAMTABLES: return "show streamtables"; case TSDB_MGMT_TABLE_TP: diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3330c86f92353d590a3be3f2f1c12bd21ec753ab..822036b599b5c2cfcb086403b9122416b729b76e 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -80,7 +80,7 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) { SDB_SET_INT64(pRaw, dataPos, pStb->updateTime) SDB_SET_INT64(pRaw, dataPos, pStb->uid) SDB_SET_INT64(pRaw, dataPos, pStb->dbUid) - SDB_SET_INT64(pRaw, dataPos, pStb->version) + SDB_SET_INT32(pRaw, dataPos, pStb->version) SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns) SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags) @@ -157,11 +157,17 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOldStb, SStbObj *pNewStb atomic_exchange_32(&pOldStb->version, pNewStb->version); taosWLockLatch(&pOldStb->lock); + pOldStb->numOfColumns = pNewStb->numOfColumns; + pOldStb->numOfTags = pNewStb->numOfTags; int32_t totalCols = pNewStb->numOfTags + pNewStb->numOfColumns; int32_t totalSize = totalCols * sizeof(SSchema); if (pOldStb->numOfTags + pOldStb->numOfColumns < totalCols) { - pOldStb->pSchema = malloc(totalSize); + void *pSchema = malloc(totalSize); + if (pSchema != NULL) { + free(pOldStb->pSchema); + pOldStb->pSchema = pSchema; + } } memcpy(pOldStb->pSchema, pNewStb->pSchema, totalSize); @@ -200,37 +206,37 @@ static int32_t mndCheckStbMsg(SCreateStbMsg *pCreate) { } if (pCreate->igExists < 0 || pCreate->igExists > 1) { - terrno = TSDB_CODE_MND_STB_INVALID_IGEXIST; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pCreate->numOfColumns < TSDB_MIN_COLUMNS || pCreate->numOfColumns > TSDB_MAX_COLUMNS) { - terrno = TSDB_CODE_MND_STB_INVALID_COLS_NUM; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pCreate->numOfTags <= 0 || pCreate->numOfTags > TSDB_MAX_TAGS) { - terrno = TSDB_CODE_MND_STB_INVALID_TAGS_NUM; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } int32_t maxColId = (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS); for (int32_t i = 0; i < totalCols; ++i) { SSchema *pSchema = &pCreate->pSchema[i]; - if (pSchema->type <= 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_TYPE; + if (pSchema->type < 0) { + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->colId < 0 || pSchema->colId >= maxColId) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_ID; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->bytes <= 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_BYTES; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->name[0] == 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_NAME; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } } @@ -245,6 +251,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre stbObj.createdTime = taosGetTimestampMs(); stbObj.updateTime = stbObj.createdTime; stbObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); + stbObj.dbUid = pDb->uid; stbObj.version = 1; stbObj.numOfColumns = pCreate->numOfColumns; stbObj.numOfTags = pCreate->numOfTags; @@ -350,19 +357,19 @@ static int32_t mndCheckAlterStbMsg(SAlterStbMsg *pAlter) { pSchema->bytes = htonl(pSchema->bytes); if (pSchema->type <= 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_TYPE; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->colId < 0 || pSchema->colId >= (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_ID; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->bytes <= 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_BYTES; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } if (pSchema->name[0] == 0) { - terrno = TSDB_CODE_MND_STB_INVALID_COL_NAME; + terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } @@ -480,31 +487,37 @@ static int32_t mndProcessDropStbMsg(SMnodeMsg *pMsg) { static int32_t mndProcessDropStbInRsp(SMnodeMsg *pMsg) { return 0; } static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SStbInfoMsg *pInfo = pMsg->rpcMsg.pCont; + SMnode *pMnode = pMsg->pMnode; + STableInfoMsg *pInfo = pMsg->rpcMsg.pCont; - mDebug("stb:%s, start to retrieve meta", pInfo->name); + mDebug("stb:%s, start to retrieve meta", pInfo->tableFname); - SDbObj *pDb = mndAcquireDbByStb(pMnode, pInfo->name); + SDbObj *pDb = mndAcquireDbByStb(pMnode, pInfo->tableFname); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - mError("stb:%s, failed to retrieve meta since %s", pInfo->name, terrstr()); + mError("stb:%s, failed to retrieve meta since %s", pInfo->tableFname, terrstr()); return -1; } - SStbObj *pStb = mndAcquireStb(pMnode, pInfo->name); + SStbObj *pStb = mndAcquireStb(pMnode, pInfo->tableFname); if (pStb == NULL) { mndReleaseDb(pMnode, pDb); - terrno = TSDB_CODE_MND_INVALID_TABLE_NAME; - mError("stb:%s, failed to get meta since %s", pInfo->name, terrstr()); + terrno = TSDB_CODE_MND_INVALID_STB; + mError("stb:%s, failed to get meta since %s", pInfo->tableFname, terrstr()); return -1; } - int32_t contLen = sizeof(STableMetaMsg) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema); + taosRLockLatch(&pStb->lock); + int32_t totalCols = pStb->numOfColumns + pStb->numOfTags; + int32_t contLen = sizeof(STableMetaMsg) + totalCols * sizeof(SSchema); + STableMetaMsg *pMeta = rpcMallocCont(contLen); if (pMeta == NULL) { + taosRUnLockLatch(&pStb->lock); + mndReleaseDb(pMnode, pDb); + mndReleaseStb(pMnode, pStb); terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("stb:%s, failed to get meta since %s", pInfo->name, terrstr()); + mError("stb:%s, failed to get meta since %s", pInfo->tableFname, terrstr()); return -1; } @@ -517,7 +530,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) { pMeta->sversion = htonl(pStb->version); pMeta->suid = htonl(pStb->uid); - for (int32_t i = 0; i < pStb->numOfColumns; ++i) { + for (int32_t i = 0; i < totalCols; ++i) { SSchema *pSchema = &pMeta->pSchema[i]; SSchema *pSrcSchema = &pStb->pSchema[i]; memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN); @@ -525,11 +538,14 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) { pSchema->colId = htonl(pSrcSchema->colId); pSchema->bytes = htonl(pSrcSchema->bytes); } + taosRUnLockLatch(&pStb->lock); + mndReleaseDb(pMnode, pDb); + mndReleaseStb(pMnode, pStb); pMsg->pCont = pMeta; pMsg->contLen = contLen; - mDebug("stb:%s, meta is retrieved, cols:%d tags:%d", pInfo->name, pStb->numOfColumns, pStb->numOfTags); + mDebug("stb:%s, meta is retrieved, cols:%d tags:%d", pInfo->tableFname, pStb->numOfColumns, pStb->numOfTags); return 0; } @@ -546,7 +562,7 @@ static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs void *pIter = NULL; while (1) { SStbObj *pStb = NULL; - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pStb); + pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb); if (pIter == NULL) break; if (strcmp(pStb->db, dbName) == 0) { @@ -583,14 +599,14 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 2; - pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "columns"); pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 2; - pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "tags"); pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; @@ -603,6 +619,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; } + pShow->numOfRows = sdbGetSize(pSdb, SDB_STB); pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; strcpy(pMeta->tbFname, mndShowStr(pShow->type)); @@ -646,8 +663,8 @@ static int32_t mndRetrieveStb(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3 cols = 0; - char stbName[TSDB_TABLE_FNAME_LEN] = {0}; - memcpy(stbName, pStb->name + prefixLen, TSDB_TABLE_FNAME_LEN - prefixLen); + char stbName[TSDB_TABLE_NAME_LEN] = {0}; + tstrncpy(stbName, pStb->name + prefixLen, TSDB_TABLE_NAME_LEN); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; STR_TO_VARSTR(pWrite, stbName); cols++; @@ -657,11 +674,11 @@ static int32_t mndRetrieveStb(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3 cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int16_t *)pWrite = pStb->numOfColumns; + *(int32_t *)pWrite = pStb->numOfColumns; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int16_t *)pWrite = pStb->numOfTags; + *(int32_t *)pWrite = pStb->numOfTags; cols++; numOfRows++; diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c new file mode 100644 index 0000000000000000000000000000000000000000..59161b32f290ff7c2eb9c4b724c8d43257f51ca0 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mndInt.h" +#include "mndTrans.h" + +int32_t mndInitSync(SMnode *pMnode) { return 0; } +void mndCleanupSync(SMnode *pMnode) {} + +int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) { + int32_t code = 0; + + // int32_t len = sdbGetRawTotalSize(pRaw); + // SSdbRaw *pReceived = calloc(1, len); + // memcpy(pReceived, pRaw, len); + // mDebug("trans:%d, data:%p recv from sync, code:0x%x pMsg:%p", pMsg->id, pReceived, code & 0xFFFF, pMsg); + + // mndTransApply(pMnode, pReceived, code); + return code; +} + +bool mndIsMaster(SMnode *pMnode) { return true; } \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index c97e1ff7d6b3e98922ba4031d65f3138b0f6c4cf..58d687a14865ec7fe104457d287115e4bc0737f0 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -421,7 +421,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create time"); + strcpy(pSchema[cols].name, "create_time"); pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; diff --git a/source/dnode/vnode/impl/CMakeLists.txt b/source/dnode/vnode/impl/CMakeLists.txt index 6972605afd9c1dd93b7fd0b3198c3837b5351f88..3623516624e8ea31c3eedd0bcdfa52cf20d16ef4 100644 --- a/source/dnode/vnode/impl/CMakeLists.txt +++ b/source/dnode/vnode/impl/CMakeLists.txt @@ -19,5 +19,5 @@ target_link_libraries( # test if(${BUILD_TEST}) - add_subdirectory(test) + #add_subdirectory(test) endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c index f63f13d8ac180ddb93007d564cece710a7e4babc..877ecb2c85457c9aff9de9454306c9fffc559bf8 100644 --- a/source/libs/parser/src/insertParser.c +++ b/source/libs/parser/src/insertParser.c @@ -77,6 +77,14 @@ typedef struct SInsertParseContext { SInsertStmtInfo* pOutput; } SInsertParseContext; +typedef int32_t (*FRowAppend)(const void *value, int32_t len, void *param); + +typedef struct SKvParam { + char buf[TSDB_MAX_TAGS_LEN]; + SKVRowBuilder* builder; + SSchema* schema; +} SKvParam; + static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; @@ -300,14 +308,6 @@ static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec return TSDB_CODE_SUCCESS; } -typedef int32_t (*FRowAppend)(const void *value, int32_t len, void *param); - -typedef struct SKvParam { - char buf[TSDB_MAX_TAGS_LEN]; - SKVRowBuilder* builder; - SSchema* schema; -} SKvParam; - static FORCE_INLINE int32_t KvRowAppend(const void *value, int32_t len, void *param) { SKvParam* pa = (SKvParam*)param; if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { diff --git a/source/libs/planner/CMakeLists.txt b/source/libs/planner/CMakeLists.txt index 4e0d03d07ae55ca85ddb44fc621ad8cce0056f27..8a309af526a03251cff147e23a384bb8cf80479a 100644 --- a/source/libs/planner/CMakeLists.txt +++ b/source/libs/planner/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( planner - PRIVATE os util common catalog parser transport function query + PRIVATE os util common cjson catalog parser transport function query ) ADD_SUBDIRECTORY(test) diff --git a/source/libs/planner/inc/plannerInt.h b/source/libs/planner/inc/plannerInt.h index 38b399fb0bdc388e18f103b385b453649f34eb0b..c5f948b722ada725ec771f9226ff09b9524a59d2 100644 --- a/source/libs/planner/inc/plannerInt.h +++ b/source/libs/planner/inc/plannerInt.h @@ -101,13 +101,7 @@ int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql); int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag); -/** - * Convert to physical plan to string to enable to print it out in the shell. - * @param pPhyNode - * @param str - * @return - */ -int32_t phyPlanToString(struct SPhyNode *pPhyNode, char** str); +int32_t subPlanToString(const SSubplan *pPhyNode, char** str); /** * Destroy the query plan object. diff --git a/source/libs/planner/src/physicalPlan.c b/source/libs/planner/src/physicalPlan.c index 277703f5c0b65618a122f566884394f976f62837..67e5770b758dd439fc493b97ca3cd9ed6b1f8c74 100644 --- a/source/libs/planner/src/physicalPlan.c +++ b/source/libs/planner/src/physicalPlan.c @@ -215,7 +215,3 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD *pDag = context.pDag; return TSDB_CODE_SUCCESS; } - -int32_t subPlanToString(struct SSubplan *pPhyNode, char** str) { - return TSDB_CODE_SUCCESS; -} diff --git a/source/libs/planner/src/physicalPlanJson.c b/source/libs/planner/src/physicalPlanJson.c new file mode 100644 index 0000000000000000000000000000000000000000..943c6b8dc0cb4cd7f5a417f2e41ae693b2d13bc4 --- /dev/null +++ b/source/libs/planner/src/physicalPlanJson.c @@ -0,0 +1,410 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#include "plannerInt.h" +#include "parser.h" +#include "cJSON.h" + +typedef cJSON* (*FToObj)(const void* obj); + +static bool addObject(cJSON* json, const char* name, FToObj func, const void* obj) { + if (NULL == obj) { + return true; + } + + cJSON* jObj = func(obj); + if (NULL == jObj) { + return false; + } + return cJSON_AddItemToObject(json, name, jObj); +} + +static bool addItem(cJSON* json, FToObj func, const void* item) { + cJSON* jItem = func(item); + if (NULL == jItem) { + return false; + } + return cJSON_AddItemToArray(json, jItem); +} + +static bool addArray(cJSON* json, const char* name, FToObj func, const SArray* array) { + size_t size = (NULL == array) ? 0 : taosArrayGetSize(array); + if (size > 0) { + cJSON* jArray = cJSON_AddArrayToObject(json, name); + if (NULL == jArray) { + return false; + } + for (size_t i = 0; i < size; ++i) { + if (!addItem(jArray, func, taosArrayGetP(array, i))) { + return false; + } + } + } + return true; +} + +static bool addRawArray(cJSON* json, const char* name, FToObj func, const void* array, int32_t itemSize, int32_t size) { + if (size > 0) { + cJSON* jArray = cJSON_AddArrayToObject(json, name); + if (NULL == jArray) { + return false; + } + for (size_t i = 0; i < size; ++i) { + if (!addItem(jArray, func, (const char*)array + itemSize * i)) { + return false; + } + } + } + return true; +} + +static cJSON* schemaToJson(const void* obj) { + const SSlotSchema* schema = (const SSlotSchema*)obj; + cJSON* jSchema = cJSON_CreateObject(); + if (NULL == jSchema) { + return NULL; + } + + // The 'name' field do not need to be serialized. + + bool res = cJSON_AddNumberToObject(jSchema, "Type", schema->type); + if (res) { + res = cJSON_AddNumberToObject(jSchema, "ColId", schema->colId); + } + if (res) { + res = cJSON_AddNumberToObject(jSchema, "Bytes", schema->bytes); + } + + if (!res) { + cJSON_Delete(jSchema); + return NULL; + } + return jSchema; +} + +static cJSON* columnFilterInfoToJson(const void* obj) { + const SColumnFilterInfo* filter = (const SColumnFilterInfo*)obj; + cJSON* jFilter = cJSON_CreateObject(); + if (NULL == jFilter) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jFilter, "LowerRelOptr", filter->lowerRelOptr); + if (res) { + res = cJSON_AddNumberToObject(jFilter, "UpperRelOptr", filter->upperRelOptr); + } + if (res) { + res = cJSON_AddNumberToObject(jFilter, "Filterstr", filter->filterstr); + } + if (res) { + res = cJSON_AddNumberToObject(jFilter, "LowerBnd", filter->lowerBndd); + } + if (res) { + res = cJSON_AddNumberToObject(jFilter, "UpperBnd", filter->upperBndd); + } + + if (!res) { + cJSON_Delete(jFilter); + return NULL; + } + return jFilter; +} + +static cJSON* columnInfoToJson(const void* obj) { + const SColumnInfo* col = (const SColumnInfo*)obj; + cJSON* jCol = cJSON_CreateObject(); + if (NULL == jCol) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jCol, "ColId", col->colId); + if (res) { + res = cJSON_AddNumberToObject(jCol, "Type", col->type); + } + if (res) { + res = cJSON_AddNumberToObject(jCol, "Bytes", col->bytes); + } + if (res) { + res = addRawArray(jCol, "FilterList", columnFilterInfoToJson, col->flist.filterInfo, sizeof(SColumnFilterInfo), col->flist.numOfFilters); + } + + if (!res) { + cJSON_Delete(jCol); + return NULL; + } + return jCol; +} + +static cJSON* columnToJson(const void* obj) { + const SColumn* col = (const SColumn*)obj; + cJSON* jCol = cJSON_CreateObject(); + if (NULL == jCol) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jCol, "TableId", col->uid); + if (res) { + res = cJSON_AddNumberToObject(jCol, "Flag", col->flag); + } + if (res) { + res = addObject(jCol, "Info", columnInfoToJson, &col->info); + } + + if (!res) { + cJSON_Delete(jCol); + return NULL; + } + return jCol; +} + +static cJSON* exprNodeToJson(const void* obj); + +static cJSON* operatorToJson(const void* obj) { + const tExprNode* exprInfo = (const tExprNode*)obj; + cJSON* jOper = cJSON_CreateObject(); + if (NULL == jOper) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jOper, "Oper", exprInfo->_node.optr); + if (res) { + res = addObject(jOper, "Left", exprNodeToJson, exprInfo->_node.pLeft); + } + if (res) { + res = addObject(jOper, "Right", exprNodeToJson, exprInfo->_node.pRight); + } + + if (!res) { + cJSON_Delete(jOper); + return NULL; + } + return jOper; +} + +static cJSON* functionToJson(const void* obj) { + const tExprNode* exprInfo = (const tExprNode*)obj; + cJSON* jFunc = cJSON_CreateObject(); + if (NULL == jFunc) { + return NULL; + } + + bool res = cJSON_AddStringToObject(jFunc, "Name", exprInfo->_function.functionName); + if (res) { + res = addRawArray(jFunc, "Child", exprNodeToJson, exprInfo->_function.pChild, sizeof(tExprNode*), exprInfo->_function.num); + } + + if (!res) { + cJSON_Delete(jFunc); + return NULL; + } + return jFunc; +} + +static cJSON* variantToJson(const void* obj) { + const SVariant* var = (const SVariant*)obj; + cJSON* jVar = cJSON_CreateObject(); + if (NULL == jVar) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jVar, "Type", var->nType); + if (res) { + res = cJSON_AddNumberToObject(jVar, "Len", var->nLen); + } + if (res) { + if (0/* in */) { + res = addArray(jVar, "values", variantToJson, var->arr); + } else if (IS_NUMERIC_TYPE(var->nType)) { + res = cJSON_AddNumberToObject(jVar, "Value", var->d); + } else { + res = cJSON_AddStringToObject(jVar, "Value", var->pz); + } + } + + if (!res) { + cJSON_Delete(jVar); + return NULL; + } + return jVar; +} + +static cJSON* exprNodeToJson(const void* obj) { + const tExprNode* exprInfo = (const tExprNode*)obj; + cJSON* jExprInfo = cJSON_CreateObject(); + if (NULL == jExprInfo) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jExprInfo, "Type", exprInfo->nodeType); + if (res) { + switch (exprInfo->nodeType) { + case TEXPR_BINARYEXPR_NODE: + case TEXPR_UNARYEXPR_NODE: + res = addObject(jExprInfo, "Operator", operatorToJson, exprInfo); + break; + case TEXPR_FUNCTION_NODE: + res = addObject(jExprInfo, "Function", functionToJson, exprInfo); + break; + case TEXPR_COL_NODE: + res = addObject(jExprInfo, "Column", schemaToJson, exprInfo->pSchema); + break; + case TEXPR_VALUE_NODE: + res = addObject(jExprInfo, "Value", variantToJson, exprInfo->pVal); + break; + default: + res = false; + break; + } + } + + if (!res) { + cJSON_Delete(jExprInfo); + return NULL; + } + return jExprInfo; +} + +static cJSON* sqlExprToJson(const void* obj) { + const SSqlExpr* expr = (const SSqlExpr*)obj; + cJSON* jExpr = cJSON_CreateObject(); + if (NULL == jExpr) { + return NULL; + } + + // token does not need to be serialized. + + bool res = addObject(jExpr, "Schema", schemaToJson, &expr->resSchema); + if (res) { + res = addRawArray(jExpr, "Columns", columnToJson, expr->pColumns, sizeof(SColumn), expr->numOfCols); + } + if (res) { + res = cJSON_AddNumberToObject(jExpr, "InterBytes", expr->interBytes); + } + if (res) { + res = addRawArray(jExpr, "Params", variantToJson, expr->param, sizeof(SVariant), expr->numOfParams); + } + + if (!res) { + cJSON_Delete(jExpr); + return NULL; + } + return jExpr; +} + +static cJSON* exprInfoToJson(const void* obj) { + const SExprInfo* exprInfo = (const SExprInfo*)obj; + cJSON* jExprInfo = cJSON_CreateObject(); + if (NULL == jExprInfo) { + return NULL; + } + + bool res = addObject(jExprInfo, "Base", sqlExprToJson, &exprInfo->base); + if (res) { + res = addObject(jExprInfo, "Expr", exprNodeToJson, exprInfo->pExpr); + } + + if (!res) { + cJSON_Delete(jExprInfo); + return NULL; + } + return jExprInfo; +} + +static cJSON* phyNodeToJson(const void* obj) { + const SPhyNode* phyNode = (const SPhyNode*)obj; + cJSON* jNode = cJSON_CreateObject(); + if (NULL == jNode) { + return NULL; + } + + // The 'pParent' field do not need to be serialized. + + bool res = cJSON_AddStringToObject(jNode, "Name", phyNode->info.name); + if (res) { + res = addArray(jNode, "Targets", exprInfoToJson, phyNode->pTargets); + } + if (res) { + res = addArray(jNode, "Conditions", exprInfoToJson, phyNode->pConditions); + } + if (res) { + res = addRawArray(jNode, "Schema", schemaToJson, phyNode->targetSchema.pSchema, sizeof(SSlotSchema), phyNode->targetSchema.numOfCols); + } + if (res) { + res = addArray(jNode, "Children", phyNodeToJson, phyNode->pChildren); + } + + if (!res) { + cJSON_Delete(jNode); + return NULL; + } + return jNode; +} + +static cJSON* subplanIdToJson(const void* obj) { + const SSubplanId* id = (const SSubplanId*)obj; + cJSON* jId = cJSON_CreateObject(); + if (NULL == jId) { + return NULL; + } + + bool res = cJSON_AddNumberToObject(jId, "QueryId", id->queryId); + if (res) { + res = cJSON_AddNumberToObject(jId, "TemplateId", id->templateId); + } + if (res) { + res = cJSON_AddNumberToObject(jId, "SubplanId", id->subplanId); + } + + if (!res) { + cJSON_Delete(jId); + return NULL; + } + return jId; +} + +static cJSON* subplanToJson(const SSubplan* subplan) { + cJSON* jSubplan = cJSON_CreateObject(); + if (NULL == jSubplan) { + return NULL; + } + + // The 'type', 'level', 'execEpSet', 'pChildern' and 'pParents' fields do not need to be serialized. + + bool res = addObject(jSubplan, "Id", subplanIdToJson, &subplan->id); + if (res) { + res = addObject(jSubplan, "Node", phyNodeToJson, subplan->pNode); + } + + if (!res) { + cJSON_Delete(jSubplan); + return NULL; + } + return jSubplan; +} + +int32_t subPlanToString(const SSubplan* subplan, char** str) { + cJSON* json = subplanToJson(subplan); + if (NULL == json) { + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + *str = cJSON_Print(json); + return TSDB_CODE_SUCCESS; +} + +int32_t stringToSubplan(const char* str, SSubplan** subplan) { + // todo + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index 744a849e2d55e1293f35f2707acb000e3a8f4221..ee989234d53ebccdf823049b06ac35c79df3f20b 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -41,3 +41,11 @@ int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* destroyQueryPlan(logicPlan); return TSDB_CODE_SUCCESS; } + +int32_t qSubPlanToString(const SSubplan *subplan, char** str) { + return subPlanToString(subplan, str); +} + +int32_t qStringToSubplan(const char* str, SSubplan** subplan) { + return stringToSubplan(str, subplan); +} diff --git a/source/libs/query/src/querymsg.c b/source/libs/query/src/querymsg.c index 74099221498e2262732cfe6735ae72a561f0ffa4..9ca8b6789b328dc00f8d23e1c35264b70ece8413 100644 --- a/source/libs/query/src/querymsg.c +++ b/source/libs/query/src/querymsg.c @@ -39,7 +39,7 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3 STableInfoMsg *bMsg = (STableInfoMsg *)*msg; - bMsg->msgHead.vgId = bInput->vgId; + bMsg->vgId = bInput->vgId; strncpy(bMsg->tableFname, bInput->tableFullName, sizeof(bMsg->tableFname)); bMsg->tableFname[sizeof(bMsg->tableFname) - 1] = 0; diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 8e30ce1403b779ef886c9c523fd5117d025bed7b..4620a816daf426a4a8a7781a0b35b959310e239f 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -38,12 +38,13 @@ enum { }; typedef struct SSchedulerMgmt { + uint64_t taskId; SHashObj *Jobs; // key: queryId, value: SQueryJob* } SSchedulerMgmt; typedef struct SQueryTask { uint64_t taskId; // task id - char *pSubplan; // operator tree + char *msg; // operator tree int8_t status; // task status SQueryProfileSummary summary; // task execution summary } SQueryTask; @@ -68,9 +69,12 @@ typedef struct SQueryJob { } SQueryJob; -#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { return _code; } } while (0) -#define SCH_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); return _code; } } while (0) -#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { goto _return; } } while (0) +#define SCH_JOB_ERR_LOG(param, ...) qError("QID:%"PRIx64 param, job->queryId, __VA_ARGS__) + +#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define SCH_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0) +#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #ifdef __cplusplus diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 8d2e1ed91638c9bea5743db827f1a0acc6159b91..7d387cbc66f481b6b37c96f34afa6b71a43aa8f7 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -51,16 +51,17 @@ int32_t schBuildAndSendRequest(void *pRpc, const SEpSet* pMgmtEps, __taos_async_ } int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { + int32_t code = 0; int32_t levelNum = (int32_t)taosArrayGetSize(dag->pSubplans); if (levelNum <= 0) { qError("invalid level num:%d", levelNum); - return TSDB_CODE_QRY_INVALID_INPUT; + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } job->levels = taosArrayInit(levelNum, sizeof(SQueryLevel)); if (NULL == job->levels) { qError("taosArrayInit %d failed", levelNum); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } job->levelNum = levelNum; @@ -73,28 +74,66 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SQueryJob *job) { SArray *levelPlans = NULL; int32_t levelPlanNum = 0; + level.status = SCH_STATUS_NOT_START; + for (int32_t i = 0; i < levelNum; ++i) { levelPlans = taosArrayGetP(dag->pSubplans, i); if (NULL == levelPlans) { qError("no level plans for level %d", i); - return TSDB_CODE_QRY_INVALID_INPUT; + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } levelPlanNum = (int32_t)taosArrayGetSize(levelPlans); if (levelPlanNum <= 0) { qError("invalid level plans number:%d, level:%d", levelPlanNum, i); - return TSDB_CODE_QRY_INVALID_INPUT; + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + level.taskNum = levelPlanNum; + level.subPlans = levelPlans; + + level.subTasks = taosArrayInit(levelPlanNum, sizeof(SQueryTask)); + if (NULL == level.subTasks) { + qError("taosArrayInit %d failed", levelPlanNum); + SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } for (int32_t n = 0; n < levelPlanNum; ++n) { + SQueryTask *task = taosArrayGet(level.subTasks, n); + + task->taskId = atomic_add_fetch_64(&schMgmt.taskId, 1); + task->status = SCH_STATUS_NOT_START; + } + if (NULL == taosArrayPush(job->levels, &level)) { + qError("taosArrayPush failed"); + SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } } return TSDB_CODE_SUCCESS; + +_return: + if (level.subTasks) { + taosArrayDestroy(level.subTasks); + } + + SCH_RET(code); } +int32_t schJobExecute(SQueryJob *job) { + switch (job->status) { + case SCH_STATUS_NOT_START: + + break; + + default: + SCH_JOB_ERR_LOG("invalid job status:%d", job->status); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } +} + int32_t schedulerInit(SSchedulerCfg *cfg) { schMgmt.Jobs = taosHashInit(SCHEDULE_DEFAULT_JOB_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); @@ -108,32 +147,39 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { int32_t scheduleQueryJob(SQueryDag* pDag, void** pJob) { if (NULL == pDag || NULL == pDag->pSubplans || NULL == pJob) { - return TSDB_CODE_QRY_INVALID_INPUT; + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - + int32_t code = 0; SQueryJob *job = calloc(1, sizeof(SQueryJob)); if (NULL == job) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - schValidateAndBuildJob(pDag, job); - - - + SCH_ERR_JRET(schValidateAndBuildJob(pDag, job)); + SCH_ERR_JRET(schJobExecute(job)); *(SQueryJob **)pJob = job; + + return TSDB_CODE_SUCCESS; +_return: - - + *(SQueryJob **)pJob = NULL; + scheduleFreeJob(job); + + SCH_RET(code); } int32_t scheduleFetchRows(void *pJob, void *data); int32_t scheduleCancelJob(void *pJob); +void scheduleFreeJob(void *pJob) { + +} + void schedulerDestroy(void) { if (schMgmt.Jobs) { taosHashCleanup(schMgmt.Jobs); //TBD diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 5518ec2a315610d2bb19927336ffebc9372394ca..0450513fc50cf17ab27acfee0b0392ba7f516104 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -217,22 +217,20 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_EXIST, "VGroup does not exist // mnode-stable TAOS_DEFINE_ERROR(TSDB_CODE_MND_STB_ALREADY_EXIST, "Stable already exists") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_ID, "Table name too long") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_NAME, "Table does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_TYPE, "Invalid table type in tsdb") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_STB_NOT_EXIST, "Stable not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_STBS, "Too many stables") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STB, "Invalid stable name") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STB_OPTION, "Invalid stable options") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_STB_OPTION_UNCHNAGED, "Stable options not changed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TAGS, "Too many tags") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_COLUMNS, "Too many columns") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TIMESERIES, "Too many time series") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_SUPER_TABLE, "Not super table") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_COL_NAME_TOO_LONG, "Tag name too long") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_ALREAY_EXIST, "Tag already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, "Tag does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, "Field already exists") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, "Field does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STABLE_NAME, "Super table does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG, "Invalid create table message") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_COLUMNS, "Too many columns") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREAY_EXIST, "Column already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES, "Exceed max row bytes") +// mnode-func TAOS_DEFINE_ERROR(TSDB_CODE_MND_FUNC_ALREADY_EXIST, "Func already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FUNC_NOT_EXIST, "Func not exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC, "Invalid func") @@ -241,9 +239,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_COMMENT, "Invalid func comment" TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_CODE, "Invalid func code") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_BUFSIZE, "Invalid func bufSize") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TAG_LENGTH, "invalid tag length") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_COLUMN_LENGTH, "invalid column length") - // dnode TAOS_DEFINE_ERROR(TSDB_CODE_DND_ACTION_IN_PROGRESS, "Action in progress") TAOS_DEFINE_ERROR(TSDB_CODE_DND_EXITING, "Dnode is exiting") @@ -501,6 +496,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_CTG_NOT_READY, "catalog is not ready" TAOS_DEFINE_ERROR(TSDB_CODE_CTG_MEM_ERROR, "catalog memory error") TAOS_DEFINE_ERROR(TSDB_CODE_CTG_SYS_ERROR, "catalog system error") +//scheduler +TAOS_DEFINE_ERROR(TSDB_CODE_SCH_STATUS_ERROR, "scheduler status error") #ifdef TAOS_ERROR_C diff --git a/src/kit/CMakeLists.txt b/src/kit/CMakeLists.txt deleted file mode 100644 index fdf58d5ae1c21ebd8b2948114d9643d38dccae3e..0000000000000000000000000000000000000000 --- a/src/kit/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) -PROJECT(TDengine) - -ADD_SUBDIRECTORY(shell) -ADD_SUBDIRECTORY(taosdemo) -ADD_SUBDIRECTORY(taosdump) -ADD_SUBDIRECTORY(taospack) diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt deleted file mode 100644 index bf2bbca14d25aff3b3717c7b9785f1dc470a013a..0000000000000000000000000000000000000000 --- a/src/kit/shell/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) -PROJECT(TDengine) - -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) -INCLUDE_DIRECTORIES(inc) - -IF (TD_LINUX) - AUX_SOURCE_DIRECTORY(./src SRC) - LIST(REMOVE_ITEM SRC ./src/shellWindows.c) - LIST(REMOVE_ITEM SRC ./src/shellDarwin.c) - ADD_EXECUTABLE(shell ${SRC}) - -IF (TD_LINUX_64 AND JEMALLOC_ENABLED) - ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) - SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc") -ELSE () - SET(LINK_JEMALLOC "") -ENDIF () - - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(shell taos_static lua ${LINK_JEMALLOC}) - ELSE () - TARGET_LINK_LIBRARIES(shell taos lua ${LINK_JEMALLOC}) - ENDIF () - - SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) -ELSEIF (TD_WINDOWS) - LIST(APPEND SRC ./src/shellEngine.c) - LIST(APPEND SRC ./src/shellMain.c) - LIST(APPEND SRC ./src/shellWindows.c) - ADD_EXECUTABLE(shell ${SRC}) - TARGET_LINK_LIBRARIES(shell taos_static) - - IF (TD_POWER) - SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME power) - ELSE () - SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) - ENDIF () -ELSEIF (TD_DARWIN) - LIST(APPEND SRC ./src/shellEngine.c) - LIST(APPEND SRC ./src/shellMain.c) - LIST(APPEND SRC ./src/shellDarwin.c) - LIST(APPEND SRC ./src/shellCommand.c) - LIST(APPEND SRC ./src/shellImport.c) - LIST(APPEND SRC ./src/shellCheck.c) - ADD_EXECUTABLE(shell ${SRC}) - # linking with dylib - TARGET_LINK_LIBRARIES(shell taos) - # linking taos statically - # TARGET_LINK_LIBRARIES(shell taos_static) - SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) -ENDIF () - diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fdf6373810c9b87d426bd12ff93a0be240beea02 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1 @@ +#add_subdirectory(shell) \ No newline at end of file diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9216bfcb6caa4fc36401af1cf6514141774c9f7c --- /dev/null +++ b/tools/shell/CMakeLists.txt @@ -0,0 +1,13 @@ +aux_source_directory(src SHELL_SRC) +list(REMOVE_ITEM SHELL_SRC ./src/shellWindows.c) +list(REMOVE_ITEM SHELL_SRC ./src/shellDarwin.c) + +add_executable(shell ${SHELL_SRC}) +target_link_libraries( + shell + PUBLIC taos + PUBLIC util + PUBLIC os +) + +SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) diff --git a/src/kit/shell/inc/shell.h b/tools/shell/inc/shell.h similarity index 100% rename from src/kit/shell/inc/shell.h rename to tools/shell/inc/shell.h diff --git a/src/kit/shell/inc/shellCommand.h b/tools/shell/inc/shellCommand.h similarity index 100% rename from src/kit/shell/inc/shellCommand.h rename to tools/shell/inc/shellCommand.h diff --git a/src/kit/shell/inc/tnettest.h b/tools/shell/inc/tnettest.h similarity index 100% rename from src/kit/shell/inc/tnettest.h rename to tools/shell/inc/tnettest.h diff --git a/src/kit/shell/src/shellCheck.c b/tools/shell/src/shellCheck.c similarity index 100% rename from src/kit/shell/src/shellCheck.c rename to tools/shell/src/shellCheck.c diff --git a/src/kit/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c similarity index 100% rename from src/kit/shell/src/shellCommand.c rename to tools/shell/src/shellCommand.c diff --git a/src/kit/shell/src/shellDarwin.c b/tools/shell/src/shellDarwin.c similarity index 100% rename from src/kit/shell/src/shellDarwin.c rename to tools/shell/src/shellDarwin.c diff --git a/src/kit/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c similarity index 100% rename from src/kit/shell/src/shellEngine.c rename to tools/shell/src/shellEngine.c diff --git a/src/kit/shell/src/shellImport.c b/tools/shell/src/shellImport.c similarity index 100% rename from src/kit/shell/src/shellImport.c rename to tools/shell/src/shellImport.c diff --git a/src/kit/shell/src/shellLinux.c b/tools/shell/src/shellLinux.c similarity index 100% rename from src/kit/shell/src/shellLinux.c rename to tools/shell/src/shellLinux.c diff --git a/src/kit/shell/src/shellMain.c b/tools/shell/src/shellMain.c similarity index 100% rename from src/kit/shell/src/shellMain.c rename to tools/shell/src/shellMain.c diff --git a/src/kit/shell/src/shellWindows.c b/tools/shell/src/shellWindows.c similarity index 100% rename from src/kit/shell/src/shellWindows.c rename to tools/shell/src/shellWindows.c diff --git a/src/kit/shell/src/tnettest.c b/tools/shell/src/tnettest.c similarity index 100% rename from src/kit/shell/src/tnettest.c rename to tools/shell/src/tnettest.c