MCPcopy Create free account
hub / github.com/baidu/braft / TEST_F

Function TEST_F

test/test_cli.cpp:80–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78};
79
80TEST_F(CliTest, add_and_remove_peer) {
81 RaftNode node1;
82 ASSERT_EQ(0, node1.start(9500, true));
83 // Add a non-exists peer should return ECATCHUP
84 butil::Status st;
85 braft::Configuration old_conf;
86 braft::PeerId peer1 = node1.peer_id();
87 old_conf.add_peer(peer1);
88 braft::PeerId peer2("127.0.0.1:9501");
89 st = braft::cli::add_peer("test", old_conf, peer2,
90 braft::cli::CliOptions());
91 ASSERT_FALSE(st.ok());
92 LOG(INFO) << "st=" << st;
93 RaftNode node2;
94 ASSERT_EQ(0, node2.start(peer2.addr.port, false));
95 st = braft::cli::add_peer("test", old_conf, peer2,
96 braft::cli::CliOptions());
97 ASSERT_TRUE(st.ok()) << st;
98 st = braft::cli::add_peer("test", old_conf, peer2,
99 braft::cli::CliOptions());
100 ASSERT_TRUE(st.ok()) << st;
101 braft::PeerId peer3("127.0.0.1:9502");
102 RaftNode node3;
103 ASSERT_EQ(0, node3.start(peer3.addr.port, false));
104 old_conf.add_peer(peer2);
105 st = braft::cli::add_peer("test", old_conf, peer3,
106 braft::cli::CliOptions());
107 ASSERT_TRUE(st.ok()) << st;
108 old_conf.add_peer(peer3);
109 st = braft::cli::remove_peer("test", old_conf, peer1,
110 braft::cli::CliOptions());
111 ASSERT_TRUE(st.ok()) << st;
112 usleep(1000 * 1000);
113 // Retried remove_peer
114 st = braft::cli::remove_peer("test", old_conf, peer1,
115 braft::cli::CliOptions());
116 ASSERT_TRUE(st.ok()) << st;
117}
118
119TEST_F(CliTest, set_peer) {
120 RaftNode node1;

Callers

nothing calls this directly

Calls 9

CliOptionsClass · 0.85
peer_idMethod · 0.80
add_peerFunction · 0.50
remove_peerFunction · 0.50
reset_peerFunction · 0.50
change_peersFunction · 0.50
startMethod · 0.45
add_peerMethod · 0.45
is_leaderMethod · 0.45

Tested by

no test coverage detected