Skip to content

Commit

Permalink
Enable and fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Sep 13, 2024
1 parent 8988310 commit be8254d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion quickwit/quickwit-indexing/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 10 additions & 14 deletions quickwit/quickwit-search/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async fn test_slop_queries() {
}

// TODO remove me once `Iterator::is_sorted_by_key` is stabilized.
fn is_sorted<E, I: Iterator<Item = E>>(mut it: I) -> bool
fn is_reverse_sorted<E, I: Iterator<Item = E>>(mut it: I) -> bool
where E: Ord {
let mut previous_el = if let Some(first_el) = it.next() {
first_el
Expand All @@ -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;
Expand All @@ -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#"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit be8254d

Please sign in to comment.