cluster.cpp 1.3 KB
Newer Older
S
Shengliang Guan 已提交
1
/**
S
Shengliang Guan 已提交
2
 * @file cluster.cpp
S
Shengliang Guan 已提交
3 4 5 6
 * @author slguan (slguan@taosdata.com)
 * @brief DNODE module cluster-msg tests
 * @version 0.1
 * @date 2021-12-15
S
Shengliang Guan 已提交
7
 *
S
Shengliang Guan 已提交
8
 * @copyright Copyright (c) 2021
S
Shengliang Guan 已提交
9 10 11
 *
 */

S
Shengliang Guan 已提交
12
#include "base.h"
S
Shengliang Guan 已提交
13 14 15

class DndTestCluster : public ::testing::Test {
 protected:
S
Shengliang Guan 已提交
16 17
  static void SetUpTestSuite() { test.Init("/tmp/dnode_test_cluster", 9030); }
  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 DndTestCluster::test;
S
Shengliang Guan 已提交
27

S
Shengliang Guan 已提交
28
TEST_F(DndTestCluster, 01_ShowCluster) {
S
Shengliang Guan 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER);
  EXPECT_EQ(test.GetMetaNum(), 3);
  EXPECT_STREQ(test.GetMetaTbName(), "show cluster");

  EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_INT);
  EXPECT_EQ(test.GetMetaBytes(0), 4);
  EXPECT_STREQ(test.GetMetaName(0), "id");

  EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_BINARY);
  EXPECT_EQ(test.GetMetaBytes(0), TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE);
  EXPECT_STREQ(test.GetMetaName(0), "name");

  EXPECT_EQ(test.GetMetaType(0), TSDB_DATA_TYPE_TIMESTAMP);
  EXPECT_EQ(test.GetMetaBytes(0), 8);
  EXPECT_STREQ(test.GetMetaName(0), "create_time");

  test.SendShowRetrieveMsg();
  test.GetShowInt32();
  test.GetShowBinary(TSDB_CLUSTER_ID_LEN);
  EXPECT_GT(test.GetShowTimestamp(), 0);
S
Shengliang Guan 已提交
49
}