-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: a non-voter not in joint config should not block replication
- Loading branch information
1 parent
23f5f7e
commit 4d58a51
Showing
2 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
async-raft/tests/replication_1_voter_to_isolated_non_voter.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
|
||
use anyhow::Result; | ||
use async_raft::Config; | ||
use fixtures::RaftRouter; | ||
use maplit::btreeset; | ||
|
||
#[macro_use] | ||
mod fixtures; | ||
|
||
/// Test replication to non-voter that is not in membership should not block. | ||
/// | ||
/// What does this test do? | ||
/// | ||
/// - bring on a cluster of 1 voter and 1 non-voter. | ||
/// - isolate replication to node 1. | ||
/// - client write should not be blocked. | ||
/// | ||
/// export RUST_LOG=async_raft,memstore,replication_1_voter_to_isolated_non_voter=trace | ||
/// cargo test -p async-raft --test replication_1_voter_to_isolated_non_voter | ||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)] | ||
async fn replication_1_voter_to_isolated_non_voter() -> Result<()> { | ||
let (_log_guard, ut_span) = init_ut!(); | ||
let _ent = ut_span.enter(); | ||
|
||
let config = Arc::new(Config::build("test".into()).validate().expect("failed to build Raft config")); | ||
let router = Arc::new(RaftRouter::new(config.clone())); | ||
|
||
let mut n_logs = router.new_nodes_from_single(btreeset! {0}, btreeset! {1}).await?; | ||
|
||
tracing::info!("--- stop replication to node 1"); | ||
{ | ||
router.isolate_node(1).await; | ||
|
||
router.client_request_many(0, "0", (10 - n_logs) as usize).await; | ||
n_logs = 10; | ||
|
||
router.wait_for_log(&btreeset![0], n_logs, timeout(), "send log to trigger snapshot").await?; | ||
} | ||
|
||
tracing::info!("--- restore replication to node 1"); | ||
{ | ||
router.restore_node(1).await; | ||
|
||
router.client_request_many(0, "0", (10 - n_logs) as usize).await; | ||
n_logs = 10; | ||
|
||
router.wait_for_log(&btreeset![0], n_logs, timeout(), "send log to trigger snapshot").await?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn timeout() -> Option<Duration> { | ||
Some(Duration::from_millis(5000)) | ||
} |