show.cpp 2.3 KB
Newer Older
S
Shengliang Guan 已提交
1
/**
S
Shengliang Guan 已提交
2
 * @file show.cpp
S
Shengliang Guan 已提交
3
 * @author slguan (slguan@taosdata.com)
S
Shengliang Guan 已提交
4 5 6
 * @brief MNODE module show tests
 * @version 1.0
 * @date 2022-01-06
S
Shengliang Guan 已提交
7
 *
S
Shengliang Guan 已提交
8
 * @copyright Copyright (c) 2022
S
Shengliang Guan 已提交
9 10 11
 *
 */

S
Shengliang Guan 已提交
12
#include "sut.h"
S
Shengliang Guan 已提交
13

S
Shengliang Guan 已提交
14
class MndTestShow : public ::testing::Test {
S
Shengliang Guan 已提交
15
 protected:
16
  static void SetUpTestSuite() { test.Init(TD_TMP_DIR_PATH "mnode_test_show", 9021); }
S
Shengliang Guan 已提交
17
  static void TearDownTestSuite() { test.Cleanup(); }
S
Shengliang Guan 已提交
18

S
Shengliang Guan 已提交
19
  static Testbase test;
S
Shengliang Guan 已提交
20

S
Shengliang Guan 已提交
21 22 23 24
 public:
  void SetUp() override {}
  void TearDown() override {}
};
S
Shengliang Guan 已提交
25

S
Shengliang Guan 已提交
26
Testbase MndTestShow::test;
S
Shengliang Guan 已提交
27

S
Shengliang Guan 已提交
28
TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
S
Shengliang Guan 已提交
29 30
  SShowReq showReq = {0};
  showReq.type = TSDB_MGMT_TABLE_MAX;
S
Shengliang Guan 已提交
31

S
Shengliang Guan 已提交
32 33 34 35
  int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
  void*   pReq = rpcMallocCont(contLen);
  tSerializeSShowReq(pReq, contLen, &showReq);
  tFreeSShowReq(&showReq);
S
Shengliang Guan 已提交
36

S
Shengliang Guan 已提交
37
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
S
Shengliang Guan 已提交
38
  ASSERT_NE(pRsp, nullptr);
H
Haojun Liao 已提交
39
  ASSERT_NE(pRsp->code, 0);
S
Shengliang Guan 已提交
40 41
}

S
Shengliang Guan 已提交
42
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
S
Shengliang Guan 已提交
43 44
  SShowReq showReq = {0};
  showReq.type = TSDB_MGMT_TABLE_START;
S
Shengliang Guan 已提交
45

S
Shengliang Guan 已提交
46 47 48 49
  int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
  void*   pReq = rpcMallocCont(contLen);
  tSerializeSShowReq(pReq, contLen, &showReq);
  tFreeSShowReq(&showReq);
S
Shengliang Guan 已提交
50

S
Shengliang Guan 已提交
51
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
S
Shengliang Guan 已提交
52
  ASSERT_NE(pRsp, nullptr);
H
Haojun Liao 已提交
53
  ASSERT_NE(pRsp->code, 0);
S
Shengliang Guan 已提交
54
}
S
Shengliang Guan 已提交
55

S
Shengliang Guan 已提交
56
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
dengyihao's avatar
dengyihao 已提交
57
  char passwd[] = "taosdata";
58
  char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
dengyihao's avatar
dengyihao 已提交
59 60
  taosEncryptPass_c((uint8_t*)passwd, strlen(passwd), secretEncrypt);

S
Shengliang Guan 已提交
61 62 63 64
  SConnectReq connectReq = {0};
  connectReq.pid = 1234;
  strcpy(connectReq.app, "mnode_test_show");
  strcpy(connectReq.db, "");
dengyihao's avatar
dengyihao 已提交
65 66
  strcpy(connectReq.user, "root");
  strcpy(connectReq.passwd, secretEncrypt);
67
  strcpy(connectReq.sVer, version);
S
Shengliang Guan 已提交
68

S
Shengliang Guan 已提交
69 70 71
  int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
  void*   pReq = rpcMallocCont(contLen);
  tSerializeSConnectReq(pReq, contLen, &connectReq);
S
Shengliang Guan 已提交
72

S
Shengliang Guan 已提交
73 74 75
  SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen);
  ASSERT_NE(pRsp, nullptr);
  ASSERT_EQ(pRsp->code, 0);
S
Shengliang Guan 已提交
76

D
dapan1121 已提交
77
  test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "perf_connections", "");
S
Shengliang Guan 已提交
78
  // EXPECT_EQ(test.GetShowRows(), 1);
S
Shengliang Guan 已提交
79
}
S
Shengliang Guan 已提交
80 81

TEST_F(MndTestShow, 04_ShowMsg_Cluster) {
D
dapan1121 已提交
82
  test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "ins_cluster", "");
S
Shengliang Guan 已提交
83
  EXPECT_EQ(test.GetShowRows(), 1);
dengyihao's avatar
dengyihao 已提交
84
}