Skip to content

Commit

Permalink
test: add test about that membership will be persisted after initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Aug 16, 2021
1 parent adc24f5 commit 0d6f6de
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions async-raft/tests/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ mod fixtures;
use std::sync::Arc;

use anyhow::Result;
use async_raft::raft::EntryPayload;
use async_raft::raft::MembershipConfig;
use async_raft::Config;
use async_raft::State;
use fixtures::RaftRouter;
Expand Down Expand Up @@ -46,5 +48,28 @@ async fn initialization() -> Result<()> {
router.wait_for_log(&hashset![0, 1, 2], want, None, "init").await?;
router.assert_stable_cluster(Some(1), Some(want)).await;

for i in 0..3 {
let sto = router.get_storage_handle(&1).await?;
let first = sto.get_log().await.get(&1).cloned();

tracing::info!("--- check membership is replicated: id: {}, first log: {:?}", i, first);
let mem = match first.unwrap().payload {
EntryPayload::ConfigChange(ref x) => x.membership.clone(),
_ => {
panic!("expect ConfigChange payload")
}
};
assert_eq!(hashset![0, 1, 2], mem.members);

let sm_mem = sto.get_state_machine().await.last_membership.clone();
assert_eq!(
Some(MembershipConfig {
members: hashset![0, 1, 2],
members_after_consensus: None,
}),
sm_mem
);
}

Ok(())
}

0 comments on commit 0d6f6de

Please sign in to comment.