Fix flaky optimistic violation detection cluster test (#18027)
* Fix flaky optimistic violation detection cluster test * Add small sleep to avoid tight loop
This commit is contained in:
@ -2184,11 +2184,21 @@ fn test_optimistic_confirmation_violation_detection() {
|
|||||||
OptimisticConfirmationVerifier::format_optimistic_confirmed_slot_violation_log(
|
OptimisticConfirmationVerifier::format_optimistic_confirmed_slot_violation_log(
|
||||||
prev_voted_slot,
|
prev_voted_slot,
|
||||||
);
|
);
|
||||||
|
// Violation detection thread can be behind so poll logs up to 10 seconds
|
||||||
if let Some(mut buf) = buf {
|
if let Some(mut buf) = buf {
|
||||||
|
let start = Instant::now();
|
||||||
|
let mut success = false;
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
buf.read_to_string(&mut output).unwrap();
|
while start.elapsed().as_secs() < 10 {
|
||||||
assert!(output.contains(&expected_log));
|
buf.read_to_string(&mut output).unwrap();
|
||||||
|
if output.contains(&expected_log) {
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep(Duration::from_millis(10));
|
||||||
|
}
|
||||||
print!("{}", output);
|
print!("{}", output);
|
||||||
|
assert!(success);
|
||||||
} else {
|
} else {
|
||||||
panic!("dumped log and disabled testing");
|
panic!("dumped log and disabled testing");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user