From b0293696534663edf8dc891c0c830476e9b375fd Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Thu, 13 Oct 2022 10:57:33 +0200 Subject: [PATCH] Add a test to check different indexes autobatching --- index-scheduler/src/lib.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 8eda8f0e9..090e0cbb6 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -663,7 +663,6 @@ mod tests { }) .unwrap(); - handle.wait_till(Breakpoint::Start); handle.wait_till(Breakpoint::AfterProcessing); handle.wait_till(Breakpoint::AfterProcessing); handle.wait_till(Breakpoint::AfterProcessing); @@ -796,6 +795,43 @@ mod tests { assert_snapshot!(snapshot_index_scheduler(&index_scheduler)); } + #[test] + fn do_not_batch_task_of_different_indexes() { + let (index_scheduler, handle) = IndexScheduler::test(true); + let index_names = ["doggos", "cattos", "girafos"]; + + for name in index_names { + index_scheduler + .register(KindWithContent::IndexCreation { + index_uid: name.to_string(), + primary_key: None, + }) + .unwrap(); + } + + for name in index_names { + index_scheduler + .register(KindWithContent::DocumentClear { + index_uid: name.to_string(), + }) + .unwrap(); + } + + for _ in 0..(index_names.len() * 2) { + handle.wait_till(Breakpoint::AfterProcessing); + } + + let mut tasks = index_scheduler.get_tasks(Query::default()).unwrap(); + tasks.reverse(); + assert_eq!(tasks.len(), 6); + assert_eq!(tasks[0].status, Status::Succeeded); + assert_eq!(tasks[1].status, Status::Succeeded); + assert_eq!(tasks[2].status, Status::Succeeded); + assert_eq!(tasks[3].status, Status::Succeeded); + assert_eq!(tasks[4].status, Status::Succeeded); + assert_eq!(tasks[5].status, Status::Succeeded); + } + #[macro_export] macro_rules! assert_smol_debug_snapshot { ($value:expr, @$snapshot:literal) => {{