#4840 - Partial fix - Confirm task success after waiting for it.

This commit is contained in:
Mahmoud Rawas 2024-12-24 18:00:23 +11:00
parent 91c7ef8723
commit bf19f86e38
23 changed files with 79 additions and 79 deletions

View File

@ -100,11 +100,11 @@ macro_rules! compute_authorized_search {
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task1,_status_code) = index.add_documents(documents, None).await; let (task1,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task1.uid()).await; index.wait_task(task1.uid()).await.succeeded();
let (task2,_status_code) = index let (task2,_status_code) = index
.update_settings(json!({"filterableAttributes": ["color"]})) .update_settings(json!({"filterableAttributes": ["color"]}))
.await; .await;
index.wait_task(task2.uid()).await; index.wait_task(task2.uid()).await.succeeded();
drop(index); drop(index);
for key_content in ACCEPTED_KEYS.iter() { for key_content in ACCEPTED_KEYS.iter() {
@ -147,7 +147,7 @@ macro_rules! compute_forbidden_search {
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
drop(index); drop(index);
for key_content in $parent_keys.iter() { for key_content in $parent_keys.iter() {

View File

@ -268,21 +268,21 @@ macro_rules! compute_authorized_single_search {
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (add_task,_status_code) = index.add_documents(documents, None).await; let (add_task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task.uid()).await; index.wait_task(add_task.uid()).await.succeeded();
let (update_task,_status_code) = index let (update_task,_status_code) = index
.update_settings(json!({"filterableAttributes": ["color"]})) .update_settings(json!({"filterableAttributes": ["color"]}))
.await; .await;
index.wait_task(update_task.uid()).await; index.wait_task(update_task.uid()).await.succeeded();
drop(index); drop(index);
let index = server.index("products"); let index = server.index("products");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (add_task2,_status_code) = index.add_documents(documents, None).await; let (add_task2,_status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task2.uid()).await; index.wait_task(add_task2.uid()).await.succeeded();
let (update_task2,_status_code) = index let (update_task2,_status_code) = index
.update_settings(json!({"filterableAttributes": ["doggos"]})) .update_settings(json!({"filterableAttributes": ["doggos"]}))
.await; .await;
index.wait_task(update_task2.uid()).await; index.wait_task(update_task2.uid()).await.succeeded();
drop(index); drop(index);
@ -339,21 +339,21 @@ macro_rules! compute_authorized_multiple_search {
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index let (task,_status_code) = index
.update_settings(json!({"filterableAttributes": ["color"]})) .update_settings(json!({"filterableAttributes": ["color"]}))
.await; .await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
drop(index); drop(index);
let index = server.index("products"); let index = server.index("products");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index let (task,_status_code) = index
.update_settings(json!({"filterableAttributes": ["doggos"]})) .update_settings(json!({"filterableAttributes": ["doggos"]}))
.await; .await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
drop(index); drop(index);
@ -423,7 +423,7 @@ macro_rules! compute_forbidden_single_search {
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index let (task,_status_code) = index
.update_settings(json!({"filterableAttributes": ["color"]})) .update_settings(json!({"filterableAttributes": ["color"]}))
.await; .await;

View File

@ -426,7 +426,7 @@ pub async fn shared_index_with_test_set() -> &'static Index<'static, Shared> {
) )
.await; .await;
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
index index
}) })
.await .await

View File

@ -131,7 +131,7 @@ async fn create_index_with_invalid_primary_key() {
let (response, code) = index.add_documents(documents, Some("title")).await; let (response, code) = index.add_documents(documents, Some("title")).await;
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.get().await; let (response, code) = index.get().await;
assert_eq!(code, 200); assert_eq!(code, 200);
@ -142,7 +142,7 @@ async fn create_index_with_invalid_primary_key() {
let (response, code) = index.add_documents(documents, Some("id")).await; let (response, code) = index.add_documents(documents, Some("id")).await;
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.get().await; let (response, code) = index.get().await;
assert_eq!(code, 200); assert_eq!(code, 200);

View File

@ -11,7 +11,7 @@ async fn create_and_get_index() {
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get().await; let (response, code) = index.get().await;
@ -57,7 +57,7 @@ async fn list_multiple_indexes() {
server.index("test").create(None).await; server.index("test").create(None).await;
let (task,_status_code) = server.index("test1").create(Some("key")).await; let (task,_status_code) = server.index("test1").create(Some("key")).await;
server.index("test").wait_task(task.uid()).await; server.index("test").wait_task(task.uid()).await.succeeded();
let (response, code) = server.list_indexes(None, None).await; let (response, code) = server.list_indexes(None, None).await;
assert_eq!(code, 200); assert_eq!(code, 200);

View File

@ -9,7 +9,7 @@ async fn stats() {
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.stats().await; let (response, code) = index.stats().await;
@ -33,7 +33,7 @@ async fn stats() {
assert_eq!(code, 202); assert_eq!(code, 202);
assert_eq!(response["taskUid"], 1); assert_eq!(response["taskUid"], 1);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.stats().await; let (response, code) = index.stats().await;

View File

@ -61,7 +61,7 @@ async fn update_nothing() {
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(task1.uid()).await; index.wait_task(task1.uid()).await.succeeded();
let (task2, code) = index.update(None).await; let (task2, code) = index.update(None).await;

View File

@ -94,7 +94,7 @@ async fn basic_test_log_stream_route() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
server.wait_task(ret.uid()).await; server.wait_task(ret.uid()).await.succeeded();
let req = actix_web::test::TestRequest::delete().uri("/logs/stream"); let req = actix_web::test::TestRequest::delete().uri("/logs/stream");
let req = req.to_request(); let req = req.to_request();

View File

@ -152,7 +152,7 @@ async fn distinct_search_with_offset_no_ranking() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await; index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await;
let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await; let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
fn get_hits(response: &Value) -> Vec<&str> { fn get_hits(response: &Value) -> Vec<&str> {
let hits_array = response["hits"].as_array().unwrap(); let hits_array = response["hits"].as_array().unwrap();
@ -211,7 +211,7 @@ async fn distinct_search_with_pagination_no_ranking() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await; index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await;
let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await; let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
fn get_hits(response: &Value) -> Vec<&str> { fn get_hits(response: &Value) -> Vec<&str> {
let hits_array = response["hits"].as_array().unwrap(); let hits_array = response["hits"].as_array().unwrap();

View File

@ -640,7 +640,7 @@ async fn filter_invalid_syntax_object() {
let index = server.unique_index(); let index = server.unique_index();
let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search(json!({"filter": "title & Glass"}), |response, code| { .search(json!({"filter": "title & Glass"}), |response, code| {
@ -663,7 +663,7 @@ async fn filter_invalid_syntax_array() {
let index = server.unique_index(); let index = server.unique_index();
let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search(json!({"filter": ["title & Glass"]}), |response, code| { .search(json!({"filter": ["title & Glass"]}), |response, code| {
@ -686,7 +686,7 @@ async fn filter_invalid_syntax_string() {
let index = server.unique_index(); let index = server.unique_index();
let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
"message": "Found unexpected characters at the end of the filter: `XOR title = Glass`. You probably forgot an `OR` or an `AND` rule.\n15:32 title = Glass XOR title = Glass", "message": "Found unexpected characters at the end of the filter: `XOR title = Glass`. You probably forgot an `OR` or an `AND` rule.\n15:32 title = Glass XOR title = Glass",

View File

@ -42,7 +42,7 @@ async fn simple_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -176,7 +176,7 @@ async fn advanced_facet_search() {
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "enabled": false })).await; index.update_settings_typo_tolerance(json!({ "enabled": false })).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
@ -200,7 +200,7 @@ async fn more_advanced_facet_search() {
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await; index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
@ -224,7 +224,7 @@ async fn simple_facet_search_with_max_values() {
index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await; index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -246,7 +246,7 @@ async fn simple_facet_search_by_count_with_max_values() {
.await; .await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -262,7 +262,7 @@ async fn non_filterable_facet_search_error() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;

View File

@ -65,7 +65,7 @@ async fn formatted_contain_wildcard() {
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (response, _) = index.add_documents(documents, None).await; let (response, _) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
index.search(json!({ "q": "pésti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true }), index.search(json!({ "q": "pésti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true }),
|response, code| |response, code|
@ -398,7 +398,7 @@ async fn displayedattr_2_smol() {
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (response, _) = index.add_documents(documents, None).await; let (response, _) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
index index
.search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }), .search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }),

View File

@ -47,7 +47,7 @@ async fn geo_sort_with_geo_strings() {
index.update_settings_filterable_attributes(json!(["_geo"])).await; index.update_settings_filterable_attributes(json!(["_geo"])).await;
index.update_settings_sortable_attributes(json!(["_geo"])).await; index.update_settings_sortable_attributes(json!(["_geo"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search( .search(
@ -128,7 +128,7 @@ async fn bug_4640() {
index.add_documents(documents, None).await; index.add_documents(documents, None).await;
index.update_settings_filterable_attributes(json!(["_geo"])).await; index.update_settings_filterable_attributes(json!(["_geo"])).await;
let (ret, _code) = index.update_settings_sortable_attributes(json!(["_geo"])).await; let (ret, _code) = index.update_settings_sortable_attributes(json!(["_geo"])).await;
index.wait_task(ret.uid()).await; index.wait_task(ret.uid()).await.succeeded();
// Sort the document with the second one first // Sort the document with the second one first
index index

View File

@ -30,11 +30,11 @@ async fn index_with_documents_user_provided<'a>(
"dimensions": 2}}} )) "dimensions": 2}}} ))
.await; .await;
assert_eq!(202, code, "{:?}", response); assert_eq!(202, code, "{:?}", response);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.add_documents(documents.clone(), None).await; let (response, code) = index.add_documents(documents.clone(), None).await;
assert_eq!(202, code, "{:?}", response); assert_eq!(202, code, "{:?}", response);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
index index
} }
@ -63,11 +63,11 @@ async fn index_with_documents_hf<'a>(server: &'a Server, documents: &Value) -> I
}}} )) }}} ))
.await; .await;
assert_eq!(202, code, "{:?}", response); assert_eq!(202, code, "{:?}", response);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.add_documents(documents.clone(), None).await; let (response, code) = index.add_documents(documents.clone(), None).await;
assert_eq!(202, code, "{:?}", response); assert_eq!(202, code, "{:?}", response);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
index index
} }

View File

@ -99,7 +99,7 @@ async fn simple_search() {
) )
.await; .await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// english // english
index index
@ -221,7 +221,7 @@ async fn force_locales() {
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// chinese detection // chinese detection
index index
@ -299,7 +299,7 @@ async fn force_locales_with_pattern() {
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// chinese detection // chinese detection
index index
@ -375,7 +375,7 @@ async fn force_locales_with_pattern_nested() {
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// chinese // chinese
index index
@ -450,7 +450,7 @@ async fn force_different_locales_with_pattern() {
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// force chinese // force chinese
index index

View File

@ -9,7 +9,7 @@ async fn index_with_documents<'a>(server: &'a Server, documents: &Value) -> Inde
let index = server.index("test"); let index = server.index("test");
let(task,_status_code) =index.add_documents(documents.clone(), None).await; let(task,_status_code) =index.add_documents(documents.clone(), None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
} }

View File

@ -139,7 +139,7 @@ async fn phrase_search_with_stop_word() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search(json!({"q": "how \"to\" train \"the" }), |response, code| { .search(json!({"q": "how \"to\" train \"the" }), |response, code| {
@ -219,10 +219,10 @@ async fn negative_special_cases_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index.update_settings(json!({"synonyms": { "escape": ["gläss"] }})).await; let (task,_status_code) = index.update_settings(json!({"synonyms": { "escape": ["gläss"] }})).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// There is a synonym for escape -> glass but we don't want "escape", only the derivates: glass // There is a synonym for escape -> glass but we don't want "escape", only the derivates: glass
index index

View File

@ -90,7 +90,7 @@ async fn simple_search_single_index() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"queries": [ .multi_search(json!({"queries": [
@ -162,7 +162,7 @@ async fn federation_single_search_single_index() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -209,7 +209,7 @@ async fn federation_multiple_search_single_index() {
let documents = SCORE_DOCUMENTS.clone(); let documents = SCORE_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -284,7 +284,7 @@ async fn federation_two_search_single_index() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -352,7 +352,7 @@ async fn simple_search_missing_index_uid() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"queries": [ .multi_search(json!({"queries": [
@ -377,7 +377,7 @@ async fn federation_simple_search_missing_index_uid() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -402,7 +402,7 @@ async fn simple_search_illegal_index_uid() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"queries": [ .multi_search(json!({"queries": [
@ -427,7 +427,7 @@ async fn federation_search_illegal_index_uid() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": {}, "queries": [ .multi_search(json!({"federation": {}, "queries": [
@ -452,12 +452,12 @@ async fn simple_search_two_indexes() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (add_task,_status_code) = index.add_documents(documents, None).await; let (add_task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task.uid()).await; index.wait_task(add_task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
.multi_search(json!({"queries": [ .multi_search(json!({"queries": [
@ -559,7 +559,7 @@ async fn federation_two_search_two_indexes() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task,_status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();

View File

@ -66,7 +66,7 @@ async fn search_no_searchable_attribute_set() {
.await; .await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await; let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search( .search(
@ -79,7 +79,7 @@ async fn search_no_searchable_attribute_set() {
.await; .await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await; let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search( .search(
@ -110,7 +110,7 @@ async fn search_on_all_attributes_restricted_set() {
let server = Server::new().await; let server = Server::new().await;
let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await; let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["title"])).await; let (task,_status_code) = index.update_settings_searchable_attributes(json!(["title"])).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| { .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| {
@ -193,7 +193,7 @@ async fn word_ranking_rule_order_exact_words() {
let server = Server::new().await; let server = Server::new().await;
let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await; let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
let (task,_status_code) = index.update_settings_typo_tolerance(json!({"disableOnWords": ["Captain", "Marvel"]})).await; let (task,_status_code) = index.update_settings_typo_tolerance(json!({"disableOnWords": ["Captain", "Marvel"]})).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
// simple search should return 2 documents (ids: 2 and 3). // simple search should return 2 documents (ids: 2 and 3).
index index
@ -359,7 +359,7 @@ async fn search_on_exact_field() {
let (response, code) = let (response, code) =
index.update_settings_typo_tolerance(json!({ "disableOnAttributes": ["exact"] })).await; index.update_settings_typo_tolerance(json!({ "disableOnAttributes": ["exact"] })).await;
assert_eq!(202, code, "{:?}", response); assert_eq!(202, code, "{:?}", response);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
// Searching on an exact attribute should only return the document matching without typo. // Searching on an exact attribute should only return the document matching without typo.
index index
.search(json!({"q": "Marvel", "attributesToSearchOn": ["exact"]}), |response, code| { .search(json!({"q": "Marvel", "attributesToSearchOn": ["exact"]}), |response, code| {

View File

@ -31,7 +31,7 @@ async fn stats() {
let (task, code) = index.create(Some("id")).await; let (task, code) = index.create(Some("id")).await;
assert_eq!(code, 202); assert_eq!(code, 202);
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = server.stats().await; let (response, code) = server.stats().await;
@ -57,7 +57,7 @@ async fn stats() {
assert_eq!(code, 202, "{}", response); assert_eq!(code, 202, "{}", response);
assert_eq!(response["taskUid"], 1); assert_eq!(response["taskUid"], 1);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let timestamp = OffsetDateTime::now_utc(); let timestamp = OffsetDateTime::now_utc();
let (response, code) = server.stats().await; let (response, code) = server.stats().await;

View File

@ -14,7 +14,7 @@ async fn error_get_unexisting_task_status() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(1).await; let (response, code) = index.get_task(1).await;
let expected_response = json!({ let expected_response = json!({
@ -42,7 +42,7 @@ async fn get_task_status() {
None, None,
) )
.await; .await;
index.wait_task(create_task.uid()).await; index.wait_task(create_task.uid()).await.succeeded();
let (_response, code) = index.get_task(add_task.uid()).await; let (_response, code) = index.get_task(add_task.uid()).await;
assert_eq!(code, 200); assert_eq!(code, 200);
// TODO check response format, as per #48 // TODO check response format, as per #48
@ -53,7 +53,7 @@ async fn list_tasks() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -105,7 +105,7 @@ async fn list_tasks_with_star_filters() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task, _code) = index.create(None).await; let (task, _code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -150,7 +150,7 @@ async fn list_tasks_status_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -164,7 +164,7 @@ async fn list_tasks_status_filtered() {
// assert_eq!(code, 200, "{}", response); // assert_eq!(code, 200, "{}", response);
// assert_eq!(response["results"].as_array().unwrap().len(), 1); // assert_eq!(response["results"].as_array().unwrap().len(), 1);
index.wait_task(response.uid()).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.filtered_tasks(&[], &["succeeded"], &[]).await; let (response, code) = index.filtered_tasks(&[], &["succeeded"], &[]).await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{}", response);
@ -176,7 +176,7 @@ async fn list_tasks_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -196,7 +196,7 @@ async fn list_tasks_invalid_canceled_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -211,7 +211,7 @@ async fn list_tasks_status_and_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task,_status_code) = index.create(None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -279,7 +279,7 @@ async fn test_summarized_document_addition_or_update() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await; let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(0).await; let (task, _) = index.get_task(0).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },

View File

@ -55,7 +55,7 @@ async fn add_remove_user_provided() {
})) }))
.await; .await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
server.wait_task(response.uid()).await; server.wait_task(response.uid()).await.succeeded();
let documents = json!([ let documents = json!([
{"id": 0, "name": "kefir", "_vectors": { "manual": [0, 0, 0] }}, {"id": 0, "name": "kefir", "_vectors": { "manual": [0, 0, 0] }},

View File

@ -73,7 +73,7 @@ async fn update_embedder() {
})) }))
.await; .await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
server.wait_task(response.uid()).await; server.wait_task(response.uid()).await.succeeded();
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({