Skip to content

Commit c779487

Browse files
committed
a
Signed-off-by: Calvin Neo <[email protected]>
1 parent 3c18cbb commit c779487

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

proxy_tests/proxy/shared/region.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ fn test_get_region_local_state() {
145145
cluster.shutdown();
146146
}
147147

148+
/// When a learner peer is removed by conf change, it will not wait until the conf change.
149+
/// However, leader could stop sending raft messages to the peer at an earlier stage,
150+
/// the peer is eventually removed by stale peer checking.
148151
#[test]
149152
fn test_stale_peer() {
150153
let (mut cluster, pd_client) = new_mock_cluster(0, 2);
151154

152-
cluster.cfg.raft_store.max_leader_missing_duration = ReadableDuration::secs(6);
155+
cluster.cfg.raft_store.max_leader_missing_duration = ReadableDuration::secs(4);
153156

154157
pd_client.disable_default_operator();
155158
disable_auto_gen_compact_log(&mut cluster);
@@ -173,14 +176,17 @@ fn test_stale_peer() {
173176
check_key(&cluster, b"k2", b"v", Some(false), None, Some(vec![2]));
174177

175178
pd_client.must_remove_peer(1, p2.clone());
176-
std::thread::sleep(std::time::Duration::from_millis(1500));
179+
std::thread::sleep(std::time::Duration::from_millis(1000));
177180

178181
fail::cfg("proxy_record_all_messages", "return(1)");
179182
cluster.clear_send_filters();
180183

181-
std::thread::sleep(std::time::Duration::from_millis(1500));
184+
std::thread::sleep(std::time::Duration::from_millis(1000));
182185
check_key(&cluster, b"k2", b"v", Some(false), None, Some(vec![2]));
183-
std::thread::sleep(std::time::Duration::from_millis(6000));
186+
std::thread::sleep(std::time::Duration::from_millis(3000));
187+
// Must received a gc peer message.
188+
/// "receives gc message, trying to remove"
189+
/// "raft message is stale, tell to gc"
184190
assert_ne!(
185191
cluster
186192
.get_debug_struct()
@@ -189,4 +195,5 @@ fn test_stale_peer() {
189195
.load(Ordering::SeqCst),
190196
0
191197
);
198+
fail::remove("proxy_record_all_messages")
192199
}

0 commit comments

Comments
 (0)