From eda09a54da365161be9e80825bb9b04e438acd44 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 22 Jan 2025 16:12:08 +0100 Subject: [PATCH] improve the index-scheduler tests --- crates/index-scheduler/src/test_utils.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/index-scheduler/src/test_utils.rs b/crates/index-scheduler/src/test_utils.rs index a63825104..a6d29e2ea 100644 --- a/crates/index-scheduler/src/test_utils.rs +++ b/crates/index-scheduler/src/test_utils.rs @@ -239,16 +239,22 @@ impl IndexSchedulerHandle { drop(index_scheduler); let Self { _tempdir: tempdir, index_scheduler, test_breakpoint_rcv, last_breakpoint: _ } = self; + let env = index_scheduler.env.clone(); drop(index_scheduler); // We must ensure that the `run` function has stopped running before restarting the index scheduler loop { 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::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) = IndexScheduler::test_with_custom_config(planned_failures, |config| {