Skip to content

Commit

Permalink
Refactor: await the reporting of the replication status in the test c…
Browse files Browse the repository at this point in the history
…ase 'add_learner_non_blocking'.

In this case, a replication failure status is supposed to be reported to
the matrix. But sometimes it times out before the failure report can be
delivered.

To address this issue, just extend the time out duration.
  • Loading branch information
drmingdrmer committed Nov 7, 2023
1 parent f4564fe commit f1819c2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions tests/tests/membership/t11_add_learner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,27 @@ async fn add_learner_non_blocking() -> Result<()> {
let raft = router.get_raft_handle(&0)?;
raft.add_learner(1, (), false).await?;

sleep(Duration::from_millis(500)).await;

let metrics = router.get_raft_handle(&0)?.metrics().borrow().clone();
let repl = metrics.replication.as_ref().unwrap();
let n1_repl = repl.get(&1);
assert_eq!(Some(&None), n1_repl, "no replication state to the learner is reported");
let n = 6;
for i in 0..=n {
if i == n {
unreachable!("no replication status is reported to metrics!");
}

let metrics = router.get_raft_handle(&0)?.metrics().borrow().clone();
let repl = metrics.replication.as_ref().unwrap();

// The result is Some(&None) when there is no success replication is made,
// and is None if no replication attempt is made(no success or failure is reported to metrics).
let n1_repl = repl.get(&1);
if n1_repl.is_none() {
tracing::info!("--- no replication attempt is made, sleep and retry: {}-th attempt", i);

sleep(Duration::from_millis(500)).await;
continue;
}
assert_eq!(Some(&None), n1_repl, "no replication state to the learner is reported");
break;
}
}

Ok(())
Expand Down

0 comments on commit f1819c2

Please sign in to comment.