diff --git a/source/dnode/mnode/impl/test/CMakeLists.txt b/source/dnode/mnode/impl/test/CMakeLists.txt index 075ff38bc672e05c187c92d801b94ea664360daf..6cdc43344d688bf5c2ad88a9863fa346d76014b8 100644 --- a/source/dnode/mnode/impl/test/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/CMakeLists.txt @@ -6,4 +6,4 @@ add_subdirectory(trans) add_subdirectory(qnode) add_subdirectory(snode) add_subdirectory(bnode) - +add_subdirectory(show) diff --git a/source/dnode/mnode/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt index 9786f65605ca25686b8d88e236d8834ce24274d9..cc0706ca5031638774e73c981b4afcdc404a2350 100644 --- a/source/dnode/mnode/impl/test/show/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/show/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. SHOW_SRC) -add_executable(dnode_test_show ${SHOW_SRC}) +add_executable(mnode_test_show ${SHOW_SRC}) target_link_libraries( - dnode_test_show + mnode_test_show PUBLIC sut ) add_test( - NAME dnode_test_show - COMMAND dnode_test_show + NAME mnode_test_show + COMMAND mnode_test_show ) diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 8622672758a40593a602aa5efe046f375c04163a..6d2c9150f23633c57686de2d124b9a72a9b1e78f 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -1,19 +1,19 @@ /** * @file show.cpp * @author slguan (slguan@taosdata.com) - * @brief DNODE module show-msg tests - * @version 0.1 - * @date 2021-12-15 + * @brief MNODE module show tests + * @version 1.0 + * @date 2022-01-06 * - * @copyright Copyright (c) 2021 + * @copyright Copyright (c) 2022 * */ #include "sut.h" -class DndTestShow : public ::testing::Test { +class MndTestShow : public ::testing::Test { protected: - static void SetUpTestSuite() { test.Init("/tmp/dnode_test_show", 9091); } + static void SetUpTestSuite() { test.Init("/tmp/mnode_test_show", 9020); } static void TearDownTestSuite() { test.Cleanup(); } static Testbase test; @@ -23,9 +23,9 @@ class DndTestShow : public ::testing::Test { void TearDown() override {} }; -Testbase DndTestShow::test; +Testbase MndTestShow::test; -TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) { +TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) { int32_t contLen = sizeof(SShowMsg); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen); @@ -37,7 +37,7 @@ TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) { ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } -TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) { +TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { int32_t contLen = sizeof(SShowMsg); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); @@ -49,12 +49,12 @@ TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) { ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } -TEST_F(DndTestShow, 02_ShowMsg_Conn) { +TEST_F(MndTestShow, 03_ShowMsg_Conn) { int32_t contLen = sizeof(SConnectMsg); SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen); pReq->pid = htonl(1234); - strcpy(pReq->app, "dnode_test_show"); + strcpy(pReq->app, "mnode_test_show"); strcpy(pReq->db, ""); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); @@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) { EXPECT_EQ(pRetrieveRsp->compressed, 0); EXPECT_EQ(pRetrieveRsp->compLen, 0); } + +TEST_F(MndTestShow, 04_ShowMsg_Cluster) { + test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, ""); + CHECK_META( "show cluster", 3); + CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); + CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); + CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + + test.SendShowRetrieveMsg(); + EXPECT_EQ(test.GetShowRows(), 1); + + IgnoreInt64(); + IgnoreBinary(TSDB_CLUSTER_ID_LEN); + CheckTimestamp(); +} \ No newline at end of file