提交 9e3a6804 编写于 作者: S Shengliang Guan

add show test

上级 fdca2ec4
...@@ -6,4 +6,4 @@ add_subdirectory(trans) ...@@ -6,4 +6,4 @@ add_subdirectory(trans)
add_subdirectory(qnode) add_subdirectory(qnode)
add_subdirectory(snode) add_subdirectory(snode)
add_subdirectory(bnode) add_subdirectory(bnode)
add_subdirectory(show)
aux_source_directory(. SHOW_SRC) aux_source_directory(. SHOW_SRC)
add_executable(dnode_test_show ${SHOW_SRC}) add_executable(mnode_test_show ${SHOW_SRC})
target_link_libraries( target_link_libraries(
dnode_test_show mnode_test_show
PUBLIC sut PUBLIC sut
) )
add_test( add_test(
NAME dnode_test_show NAME mnode_test_show
COMMAND dnode_test_show COMMAND mnode_test_show
) )
/** /**
* @file show.cpp * @file show.cpp
* @author slguan (slguan@taosdata.com) * @author slguan (slguan@taosdata.com)
* @brief DNODE module show-msg tests * @brief MNODE module show tests
* @version 0.1 * @version 1.0
* @date 2021-12-15 * @date 2022-01-06
* *
* @copyright Copyright (c) 2021 * @copyright Copyright (c) 2022
* *
*/ */
#include "sut.h" #include "sut.h"
class DndTestShow : public ::testing::Test { class MndTestShow : public ::testing::Test {
protected: 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 void TearDownTestSuite() { test.Cleanup(); }
static Testbase test; static Testbase test;
...@@ -23,9 +23,9 @@ class DndTestShow : public ::testing::Test { ...@@ -23,9 +23,9 @@ class DndTestShow : public ::testing::Test {
void TearDown() override {} 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); int32_t contLen = sizeof(SShowMsg);
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
...@@ -37,7 +37,7 @@ TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) { ...@@ -37,7 +37,7 @@ TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) {
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); 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); int32_t contLen = sizeof(SShowMsg);
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
...@@ -49,12 +49,12 @@ TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) { ...@@ -49,12 +49,12 @@ TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) {
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); 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); int32_t contLen = sizeof(SConnectMsg);
SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen); SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen);
pReq->pid = htonl(1234); pReq->pid = htonl(1234);
strcpy(pReq->app, "dnode_test_show"); strcpy(pReq->app, "mnode_test_show");
strcpy(pReq->db, ""); strcpy(pReq->db, "");
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
...@@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) { ...@@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) {
EXPECT_EQ(pRetrieveRsp->compressed, 0); EXPECT_EQ(pRetrieveRsp->compressed, 0);
EXPECT_EQ(pRetrieveRsp->compLen, 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册