From be8254d46e06e904fbd2648d100950eab93280a7 Mon Sep 17 00:00:00 2001 From: Remi Dettai Date: Fri, 13 Sep 2024 16:37:41 +0200 Subject: [PATCH] Enable and fix the test --- quickwit/quickwit-indexing/src/test_utils.rs | 2 +- quickwit/quickwit-search/src/tests.rs | 24 ++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/quickwit/quickwit-indexing/src/test_utils.rs b/quickwit/quickwit-indexing/src/test_utils.rs index 3e6623be79b..ef75d0848db 100644 --- a/quickwit/quickwit-indexing/src/test_utils.rs +++ b/quickwit/quickwit-indexing/src/test_utils.rs @@ -150,7 +150,7 @@ impl TestSandbox { }) } - /// Adds documents. + /// Adds documents and waits for them to be indexed (creating a separate split). /// /// The documents are expected to be `JsonValue`. /// They can be created using the `serde_json::json!` macro. diff --git a/quickwit/quickwit-search/src/tests.rs b/quickwit/quickwit-search/src/tests.rs index a13286b948d..7f313558b50 100644 --- a/quickwit/quickwit-search/src/tests.rs +++ b/quickwit/quickwit-search/src/tests.rs @@ -266,7 +266,7 @@ async fn test_slop_queries() { } // TODO remove me once `Iterator::is_sorted_by_key` is stabilized. -fn is_sorted>(mut it: I) -> bool +fn is_reverse_sorted>(mut it: I) -> bool where E: Ord { let mut previous_el = if let Some(first_el) = it.next() { first_el @@ -275,7 +275,7 @@ where E: Ord { return true; }; for next_el in it { - if next_el < previous_el { + if next_el > previous_el { return false; } previous_el = next_el; @@ -284,7 +284,6 @@ where E: Ord { } #[tokio::test] -#[cfg_attr(not(feature = "ci-test"), ignore)] async fn test_single_node_several_splits() -> anyhow::Result<()> { let index_id = "single-node-several-splits"; let doc_mapping_yaml = r#" @@ -324,17 +323,14 @@ async fn test_single_node_several_splits() -> anyhow::Result<()> { .await?; assert_eq!(single_node_result.num_hits, 20); assert_eq!(single_node_result.hits.len(), 6); - assert!(&single_node_result.hits[0].json.contains("Snoopy")); - assert!(&single_node_result.hits[1].json.contains("breed")); - assert!(is_sorted(single_node_result.hits.iter().flat_map(|hit| { - hit.partial_hit.as_ref().map(|partial_hit| { - ( - partial_hit.sort_value, - partial_hit.split_id.as_str(), - partial_hit.doc_id, - ) - }) - }))); + assert!(&single_node_result.hits[0].json.contains("breed")); + assert!(&single_node_result.hits[1].json.contains("Snoopy")); + let hit_keys = single_node_result.hits.iter().flat_map(|hit| { + hit.partial_hit + .as_ref() + .map(|partial_hit| (partial_hit.split_id.as_str(), partial_hit.doc_id as i32)) + }); + assert!(is_reverse_sorted(hit_keys)); assert!(single_node_result.elapsed_time_micros > 10); assert!(single_node_result.elapsed_time_micros < 1_000_000); test_sandbox.assert_quit().await;