Skip to content

Commit

Permalink
Test: block until membership changed for add_learner_with_set_nodes()
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Mar 19, 2024
1 parent 6f13b3f commit b30e4b5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/tests/membership/t11_add_learner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,13 @@ async fn add_learner_with_set_nodes() -> Result<()> {
let raft = router.get_raft_handle(&0)?;
raft.change_membership(ChangeMembers::SetNodes(btreemap! {2=>(), 4=>()}), true).await?;

// TODO: Flaky: there is chance that the log is committed but metrics is not updated.
// Because metrics is updated in the next loop in the `runtime_loop`
let metrics = router.get_raft_handle(&0)?.metrics().borrow().clone();
let node_ids = metrics.membership_config.membership().nodes().map(|x| *x.0).collect::<Vec<_>>();
assert_eq!(vec![0, 1, 2, 4], node_ids);
router
.wait(&0, timeout())
.metrics(
|m| m.membership_config.membership().nodes().map(|x| *x.0).collect::<Vec<_>>() == vec![0, 1, 2, 4],
"set node 2 and 4",
)
.await?;
}

Ok(())
Expand Down

0 comments on commit b30e4b5

Please sign in to comment.