improve the index-scheduler tests

This commit is contained in:
Tamo 2025-01-22 16:12:08 +01:00
parent a256021f3e
commit 0b26517b55
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69

View File

@ -239,16 +239,22 @@ impl IndexSchedulerHandle {
drop(index_scheduler); drop(index_scheduler);
let Self { _tempdir: tempdir, index_scheduler, test_breakpoint_rcv, last_breakpoint: _ } = let Self { _tempdir: tempdir, index_scheduler, test_breakpoint_rcv, last_breakpoint: _ } =
self; self;
let env = index_scheduler.env.clone();
drop(index_scheduler); drop(index_scheduler);
// We must ensure that the `run` function has stopped running before restarting the index scheduler // We must ensure that the `run` function has stopped running before restarting the index scheduler
loop { loop {
match test_breakpoint_rcv.recv_timeout(Duration::from_secs(5)) { match test_breakpoint_rcv.recv_timeout(Duration::from_secs(5)) {
Ok(_) => continue, Ok((_, true)) => continue,
Ok((b, false)) => {
panic!("Scheduler is not stopped and passed {b:?}")
}
Err(RecvTimeoutError::Timeout) => panic!("The indexing loop is stuck somewhere"), Err(RecvTimeoutError::Timeout) => panic!("The indexing loop is stuck somewhere"),
Err(RecvTimeoutError::Disconnected) => break, Err(RecvTimeoutError::Disconnected) => break,
} }
} }
let closed = env.prepare_for_closing().wait_timeout(Duration::from_secs(5));
assert!(closed, "The index scheduler couldn't close itself, it seems like someone else is holding the env somewhere");
let (scheduler, mut handle) = let (scheduler, mut handle) =
IndexScheduler::test_with_custom_config(planned_failures, |config| { IndexScheduler::test_with_custom_config(planned_failures, |config| {