Skip to content

Commit

Permalink
refactor: change old_leader_will_discard_spec_exe_cmds to `old_lead…
Browse files Browse the repository at this point in the history
…er_will_keep_original_states`

Because the leader no longer revert it state in previous commit, this test should be refactored

Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds authored and Phoenix500526 committed Jul 19, 2023
1 parent cca9204 commit 2850e4f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions simulation/tests/it/curp/server_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ async fn new_leader_will_recover_spec_cmds_cond2() {
group.stop().await;
}

// Old Leader should discard spec states
#[madsim::test]
async fn old_leader_will_discard_spec_exe_cmds() {
async fn old_leader_will_keep_original_states() {
init_logger();

let group = CurpGroup::new(5).await;
Expand All @@ -293,17 +292,6 @@ async fn old_leader_will_discard_spec_exe_cmds() {
};
let mut leader1_connect = group.get_connect(&leader1).await;
leader1_connect.propose(req1).await.unwrap();
let leader1_store = Arc::clone(&group.get_node(&leader1).store);
let res = leader1_store
.lock()
.as_ref()
.unwrap()
.get_all(TEST_TABLE)
.unwrap();
assert_eq!(
res,
vec![(0u32.to_be_bytes().to_vec(), 1u32.to_be_bytes().to_vec())]
);

// 3: recover all others and disable leader, a new leader will be elected
group.disable_node(&leader1);
Expand All @@ -315,10 +303,10 @@ async fn old_leader_will_discard_spec_exe_cmds() {
let leader2 = group.get_leader().await.0;
assert_ne!(leader2, leader1);

// 4: recover the old leader, its state should be reverted to the original state
// 4: recover the old leader, it should keep the original state
group.enable_node(&leader1);
// wait for reversion
sleep_secs(15).await;
let leader1_store = Arc::clone(&group.get_node(&leader1).store);
let res = leader1_store
.lock()
.as_ref()
Expand Down

0 comments on commit 2850e4f

Please sign in to comment.