Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Fix flaky optimistic violation detection cluster test (#18027) (#18126)
Browse files Browse the repository at this point in the history
* Fix flaky optimistic violation detection cluster test

* Add small sleep to avoid tight loop

(cherry picked from commit 423e0d9)

Co-authored-by: Ashwin Sekar <[email protected]>
  • Loading branch information
mergify[bot] and AshwinSekar authored Jun 22, 2021
1 parent c48ec02 commit 9c1a6be
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2183,11 +2183,21 @@ fn test_optimistic_confirmation_violation_detection() {
OptimisticConfirmationVerifier::format_optimistic_confirmed_slot_violation_log(
prev_voted_slot,
);
// Violation detection thread can be behind so poll logs up to 10 seconds
if let Some(mut buf) = buf {
let start = Instant::now();
let mut success = false;
let mut output = String::new();
buf.read_to_string(&mut output).unwrap();
assert!(output.contains(&expected_log));
while start.elapsed().as_secs() < 10 {
buf.read_to_string(&mut output).unwrap();
if output.contains(&expected_log) {
success = true;
break;
}
sleep(Duration::from_millis(10));
}
print!("{}", output);
assert!(success);
} else {
panic!("dumped log and disabled testing");
}
Expand Down

0 comments on commit 9c1a6be

Please sign in to comment.