2021-12-16 09:07:40 +00:00
|
|
|
/**
|
2021-12-16 12:16:35 +00:00
|
|
|
* @file show.cpp
|
2021-12-16 09:07:40 +00:00
|
|
|
* @author slguan (slguan@taosdata.com)
|
2022-01-05 10:20:59 +00:00
|
|
|
* @brief MNODE module show tests
|
|
|
|
|
* @version 1.0
|
|
|
|
|
* @date 2022-01-06
|
2021-12-06 07:58:26 +00:00
|
|
|
*
|
2022-01-05 10:20:59 +00:00
|
|
|
* @copyright Copyright (c) 2022
|
2021-12-06 07:58:26 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-04 12:36:54 +00:00
|
|
|
#include "sut.h"
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-01-05 10:20:59 +00:00
|
|
|
class MndTestShow : public ::testing::Test {
|
2021-12-06 07:58:26 +00:00
|
|
|
protected:
|
2022-05-21 15:47:39 +00:00
|
|
|
static void SetUpTestSuite() { test.Init(TD_TMP_DIR_PATH "mnode_test_show", 9021); }
|
2021-12-22 07:39:32 +00:00
|
|
|
static void TearDownTestSuite() { test.Cleanup(); }
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2021-12-22 07:39:32 +00:00
|
|
|
static Testbase test;
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2021-12-21 14:35:45 +00:00
|
|
|
public:
|
|
|
|
|
void SetUp() override {}
|
|
|
|
|
void TearDown() override {}
|
|
|
|
|
};
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-01-05 10:20:59 +00:00
|
|
|
Testbase MndTestShow::test;
|
2021-12-21 14:35:45 +00:00
|
|
|
|
2022-01-05 10:20:59 +00:00
|
|
|
TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
2022-02-14 10:42:42 +00:00
|
|
|
SShowReq showReq = {0};
|
|
|
|
|
showReq.type = TSDB_MGMT_TABLE_MAX;
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-02-14 10:42:42 +00:00
|
|
|
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
|
|
|
|
void* pReq = rpcMallocCont(contLen);
|
|
|
|
|
tSerializeSShowReq(pReq, contLen, &showReq);
|
|
|
|
|
tFreeSShowReq(&showReq);
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-04-15 06:20:50 +00:00
|
|
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
2022-01-05 12:18:56 +00:00
|
|
|
ASSERT_NE(pRsp, nullptr);
|
2022-04-21 10:55:01 +00:00
|
|
|
ASSERT_NE(pRsp->code, 0);
|
2021-12-06 07:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
2022-01-05 10:20:59 +00:00
|
|
|
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
2022-02-14 10:42:42 +00:00
|
|
|
SShowReq showReq = {0};
|
|
|
|
|
showReq.type = TSDB_MGMT_TABLE_START;
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-02-14 10:42:42 +00:00
|
|
|
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
|
|
|
|
void* pReq = rpcMallocCont(contLen);
|
|
|
|
|
tSerializeSShowReq(pReq, contLen, &showReq);
|
|
|
|
|
tFreeSShowReq(&showReq);
|
2021-12-06 07:58:26 +00:00
|
|
|
|
2022-04-15 06:20:50 +00:00
|
|
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
2022-01-05 12:18:56 +00:00
|
|
|
ASSERT_NE(pRsp, nullptr);
|
2022-04-21 10:55:01 +00:00
|
|
|
ASSERT_NE(pRsp->code, 0);
|
2021-12-06 07:58:26 +00:00
|
|
|
}
|
2021-12-22 08:38:20 +00:00
|
|
|
|
2022-01-05 10:20:59 +00:00
|
|
|
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
2022-04-21 07:24:12 +00:00
|
|
|
char passwd[] = "taosdata";
|
2023-03-08 08:10:11 +00:00
|
|
|
char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
|
2022-04-21 07:24:12 +00:00
|
|
|
taosEncryptPass_c((uint8_t*)passwd, strlen(passwd), secretEncrypt);
|
|
|
|
|
|
2022-02-16 03:45:44 +00:00
|
|
|
SConnectReq connectReq = {0};
|
|
|
|
|
connectReq.pid = 1234;
|
|
|
|
|
strcpy(connectReq.app, "mnode_test_show");
|
|
|
|
|
strcpy(connectReq.db, "");
|
2022-04-21 07:24:12 +00:00
|
|
|
strcpy(connectReq.user, "root");
|
|
|
|
|
strcpy(connectReq.passwd, secretEncrypt);
|
2023-03-08 08:10:11 +00:00
|
|
|
strcpy(connectReq.sVer, version);
|
2021-12-22 08:38:20 +00:00
|
|
|
|
2022-02-16 03:45:44 +00:00
|
|
|
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
|
|
|
|
void* pReq = rpcMallocCont(contLen);
|
|
|
|
|
tSerializeSConnectReq(pReq, contLen, &connectReq);
|
2021-12-22 08:38:20 +00:00
|
|
|
|
2022-01-05 12:18:56 +00:00
|
|
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
|
|
|
|
|
ASSERT_NE(pRsp, nullptr);
|
|
|
|
|
ASSERT_EQ(pRsp->code, 0);
|
2021-12-22 08:38:20 +00:00
|
|
|
|
2022-08-02 05:47:04 +00:00
|
|
|
test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "perf_connections", "");
|
2022-04-15 02:58:27 +00:00
|
|
|
// EXPECT_EQ(test.GetShowRows(), 1);
|
2021-12-22 08:38:20 +00:00
|
|
|
}
|
2022-01-05 10:20:59 +00:00
|
|
|
|
|
|
|
|
TEST_F(MndTestShow, 04_ShowMsg_Cluster) {
|
2022-08-02 05:47:04 +00:00
|
|
|
test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "ins_cluster", "");
|
2022-01-05 10:20:59 +00:00
|
|
|
EXPECT_EQ(test.GetShowRows(), 1);
|
2022-04-21 07:24:12 +00:00
|
|
|
}
|