“a7edb3f3292e547e34087002816608995b75a6e9”上不存在“paddle/phi/core/tensor_utils.cc”
show.cpp 2.8 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:
S
Shengliang Guan 已提交
16
  static void SetUpTestSuite() { test.Init("/tmp/mnode_test_show", 9020); }
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
  int32_t contLen = sizeof(SShowMsg);
S
Shengliang Guan 已提交
30

S
Shengliang Guan 已提交
31
  SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
S
Shengliang Guan 已提交
32 33 34
  pReq->type = TSDB_MGMT_TABLE_MAX;
  strcpy(pReq->db, "");

H
Hongze Cheng 已提交
35
  SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
S
Shengliang Guan 已提交
36 37 38 39
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
}

S
Shengliang Guan 已提交
40
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
S
Shengliang Guan 已提交
41
  int32_t contLen = sizeof(SShowMsg);
S
Shengliang Guan 已提交
42 43 44 45 46

  SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
  pReq->type = TSDB_MGMT_TABLE_START;
  strcpy(pReq->db, "");

H
Hongze Cheng 已提交
47
  SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen);
S
Shengliang Guan 已提交
48 49 50
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
}
S
Shengliang Guan 已提交
51

S
Shengliang Guan 已提交
52
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
S
Shengliang Guan 已提交
53 54 55 56
  int32_t contLen = sizeof(SConnectMsg);

  SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen);
  pReq->pid = htonl(1234);
S
Shengliang Guan 已提交
57
  strcpy(pReq->app, "mnode_test_show");
S
Shengliang Guan 已提交
58 59
  strcpy(pReq->db, "");

H
Hongze Cheng 已提交
60
  SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen);
S
Shengliang Guan 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  ASSERT_NE(pMsg, nullptr);
  ASSERT_EQ(pMsg->code, 0);

  test.SendShowMetaMsg(TSDB_MGMT_TABLE_CONNS, "");

  STableMetaMsg* pMeta = test.GetShowMeta();
  EXPECT_STREQ(pMeta->tbFname, "show connections");
  EXPECT_EQ(pMeta->numOfTags, 0);
  EXPECT_EQ(pMeta->numOfColumns, 7);
  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);

  test.SendShowRetrieveMsg();

  SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp();
  EXPECT_EQ(pRetrieveRsp->numOfRows, 1);
  EXPECT_EQ(pRetrieveRsp->useconds, 0);
  EXPECT_EQ(pRetrieveRsp->completed, 1);
  EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
  EXPECT_EQ(pRetrieveRsp->compressed, 0);
  EXPECT_EQ(pRetrieveRsp->compLen, 0);
}
S
Shengliang Guan 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

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();
}