From b311eb3bed508f9249ab4d3242f4b4f18f27114b Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Mon, 10 Oct 2022 16:18:35 +0200 Subject: [PATCH] Add a test that verifies that sending multiple tasks works --- index-scheduler/src/lib.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 7ac84b880..28f88d411 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -604,6 +604,43 @@ mod tests { assert_eq!(tasks[2].status, Status::Enqueued); } + /// We send a lot of tasks but notify the tasks scheduler only once as + /// we send them very fast, we must make sure that they are all processed. + #[test] + fn process_tasks_inserted_without_new_signal() { + let (index_scheduler, handle) = IndexScheduler::test(); + + index_scheduler + .register(KindWithContent::IndexCreation { + index_uid: S("doggos"), + primary_key: None, + }) + .unwrap(); + index_scheduler + .register(KindWithContent::IndexCreation { + index_uid: S("cattos"), + primary_key: None, + }) + .unwrap(); + index_scheduler + .register(KindWithContent::IndexDeletion { + index_uid: S("doggos"), + }) + .unwrap(); + + handle.wait_till(Breakpoint::Start); + handle.wait_till(Breakpoint::AfterProcessing); + handle.wait_till(Breakpoint::AfterProcessing); + handle.wait_till(Breakpoint::AfterProcessing); + + let mut tasks = index_scheduler.get_tasks(Query::default()).unwrap(); + tasks.reverse(); + assert_eq!(tasks.len(), 3); + assert_eq!(tasks[0].status, Status::Succeeded); + assert_eq!(tasks[1].status, Status::Succeeded); + assert_eq!(tasks[2].status, Status::Succeeded); + } + #[test] fn document_addition() { let (index_scheduler, handle) = IndexScheduler::test();