Skip to content

Commit

Permalink
Chore: print server metrics changes to address a flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Jan 28, 2024
1 parent 3822e22 commit 87713ec
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/tests/metrics/t10_server_metrics_and_data_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ async fn server_metrics_and_data_metrics() -> Result<()> {
let data_metrics = node.data_metrics();

let current_leader = router.current_leader(0).await;
let leader = server_metrics.borrow_and_update().current_leader;
let server_metrics_1 = {
let sm = server_metrics.borrow_and_update();
sm.clone()
};
let leader = server_metrics_1.current_leader;
assert_eq!(leader, current_leader, "current_leader should be {:?}", current_leader);

// Write some logs.
Expand All @@ -41,9 +45,16 @@ async fn server_metrics_and_data_metrics() -> Result<()> {

let last_log_index = data_metrics.borrow().last_log.unwrap_or_default().index;
assert_eq!(last_log_index, log_index, "last_log_index should be {:?}", log_index);

let sm = server_metrics.borrow();
let server_metrics_2 = sm.clone();

// TODO: flaky fail, find out why.
assert!(
!server_metrics.borrow().has_changed(),
"server metrics should not update"
!sm.has_changed(),
"server metrics should not update, but {:?} --> {:?}",
server_metrics_1,
server_metrics_2
);
Ok(())
}

0 comments on commit 87713ec

Please sign in to comment.