YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tserver/remote_bootstrap_session-test.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
#ifndef YB_TSERVER_REMOTE_BOOTSTRAP_SESSION_TEST_H_
33
#define YB_TSERVER_REMOTE_BOOTSTRAP_SESSION_TEST_H_
34
35
#include <memory>
36
37
#include <glog/logging.h>
38
#include <gtest/gtest.h>
39
40
#include "yb/consensus/consensus_fwd.h"
41
#include "yb/common/partial_row.h"
42
#include "yb/common/wire_protocol-test-util.h"
43
44
#include "yb/consensus/consensus_meta.h"
45
#include "yb/consensus/metadata.pb.h"
46
#include "yb/consensus/opid_util.h"
47
#include "yb/consensus/multi_raft_batcher.h"
48
#include "yb/gutil/ref_counted.h"
49
#include "yb/gutil/strings/fastmem.h"
50
#include "yb/gutil/strings/substitute.h"
51
52
#include "yb/rpc/messenger.h"
53
#include "yb/rpc/proxy.h"
54
55
#include "yb/tablet/tablet-test-util.h"
56
57
#include "yb/tserver/remote_bootstrap_session.h"
58
59
#include "yb/util/metrics.h"
60
#include "yb/util/test_util.h"
61
#include "yb/util/threadpool.h"
62
63
METRIC_DECLARE_entity(table);
64
METRIC_DECLARE_entity(tablet);
65
66
DECLARE_bool(quick_leader_election_on_create);
67
68
using std::shared_ptr;
69
using std::string;
70
71
namespace yb {
72
namespace tserver {
73
74
using std::unique_ptr;
75
using consensus::ConsensusMetadata;
76
using consensus::RaftConfigPB;
77
using consensus::RaftPeerPB;
78
using log::Log;
79
using log::LogOptions;
80
using log::LogAnchorRegistry;
81
using rpc::Messenger;
82
using rpc::MessengerBuilder;
83
using strings::Substitute;
84
using tablet::YBTabletTest;
85
using tablet::TabletPeer;
86
using tablet::RaftGroupReplicaSuperBlockPB;
87
88
const int64_t kLeaderTerm = 1;
89
90
class RemoteBootstrapSessionTest : public YBTabletTest {
91
 public:
92
  explicit RemoteBootstrapSessionTest(TableType table_type)
93
4
    : YBTabletTest(GetSimpleTestSchema(), table_type) {
94
4
  }
95
96
  void SetUp() override;
97
98
  void TearDown() override;
99
100
 protected:
101
  void SetUpTabletPeer();
102
103
  void TabletPeerStateChangedCallback(const string& tablet_id,
104
                                      std::shared_ptr<consensus::StateChangeContext> context);
105
106
  void PopulateTablet();
107
108
  virtual void InitSession();
109
110
  MetricRegistry metric_registry_;
111
  scoped_refptr<LogAnchorRegistry> log_anchor_registry_;
112
  unique_ptr<ThreadPool> raft_pool_;
113
  unique_ptr<ThreadPool> tablet_prepare_pool_;
114
  unique_ptr<ThreadPool> log_thread_pool_;
115
  std::shared_ptr<TabletPeer> tablet_peer_;
116
  scoped_refptr<RemoteBootstrapSession> session_;
117
  std::unique_ptr<rpc::Messenger> messenger_;
118
  std::unique_ptr<rpc::ProxyCache> proxy_cache_;
119
  std::unique_ptr<consensus::MultiRaftManager> multi_raft_manager_;
120
};
121
122
}  // namespace tserver
123
}  // namespace yb
124
125
#endif  // YB_TSERVER_REMOTE_BOOTSTRAP_SESSION_TEST_H_