From bf19f86e38ad5ab732746058bf7be856f3877045 Mon Sep 17 00:00:00 2001 From: Mahmoud Rawas Date: Tue, 24 Dec 2024 18:00:23 +1100 Subject: [PATCH] #4840 - Partial fix - Confirm task success after waiting for it. --- crates/meilisearch/tests/auth/tenant_token.rs | 6 ++--- .../tests/auth/tenant_token_multi_search.rs | 18 +++++++-------- crates/meilisearch/tests/common/mod.rs | 2 +- .../meilisearch/tests/index/create_index.rs | 4 ++-- crates/meilisearch/tests/index/get_index.rs | 4 ++-- crates/meilisearch/tests/index/stats.rs | 4 ++-- .../meilisearch/tests/index/update_index.rs | 2 +- crates/meilisearch/tests/logs/mod.rs | 2 +- crates/meilisearch/tests/search/distinct.rs | 4 ++-- crates/meilisearch/tests/search/errors.rs | 6 ++--- .../meilisearch/tests/search/facet_search.rs | 12 +++++----- crates/meilisearch/tests/search/formatted.rs | 4 ++-- crates/meilisearch/tests/search/geo.rs | 4 ++-- crates/meilisearch/tests/search/hybrid.rs | 8 +++---- crates/meilisearch/tests/search/locales.rs | 10 ++++----- .../tests/search/matching_strategy.rs | 2 +- crates/meilisearch/tests/search/mod.rs | 6 ++--- crates/meilisearch/tests/search/multi.rs | 22 +++++++++---------- .../tests/search/restrict_searchable.rs | 10 ++++----- crates/meilisearch/tests/stats/mod.rs | 4 ++-- crates/meilisearch/tests/tasks/mod.rs | 20 ++++++++--------- crates/meilisearch/tests/vector/mod.rs | 2 +- crates/meilisearch/tests/vector/settings.rs | 2 +- 23 files changed, 79 insertions(+), 79 deletions(-) diff --git a/crates/meilisearch/tests/auth/tenant_token.rs b/crates/meilisearch/tests/auth/tenant_token.rs index 808d5247f..6bdb0c50f 100644 --- a/crates/meilisearch/tests/auth/tenant_token.rs +++ b/crates/meilisearch/tests/auth/tenant_token.rs @@ -100,11 +100,11 @@ macro_rules! compute_authorized_search { let index = server.index("sales"); let documents = DOCUMENTS.clone(); 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 .update_settings(json!({"filterableAttributes": ["color"]})) .await; - index.wait_task(task2.uid()).await; + index.wait_task(task2.uid()).await.succeeded(); drop(index); for key_content in ACCEPTED_KEYS.iter() { @@ -147,7 +147,7 @@ macro_rules! compute_forbidden_search { let index = server.index("sales"); let documents = DOCUMENTS.clone(); 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); for key_content in $parent_keys.iter() { diff --git a/crates/meilisearch/tests/auth/tenant_token_multi_search.rs b/crates/meilisearch/tests/auth/tenant_token_multi_search.rs index 36a5fe9e4..530eb876a 100644 --- a/crates/meilisearch/tests/auth/tenant_token_multi_search.rs +++ b/crates/meilisearch/tests/auth/tenant_token_multi_search.rs @@ -268,21 +268,21 @@ macro_rules! compute_authorized_single_search { let index = server.index("sales"); let documents = DOCUMENTS.clone(); 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 .update_settings(json!({"filterableAttributes": ["color"]})) .await; - index.wait_task(update_task.uid()).await; + index.wait_task(update_task.uid()).await.succeeded(); drop(index); let index = server.index("products"); let documents = NESTED_DOCUMENTS.clone(); 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 .update_settings(json!({"filterableAttributes": ["doggos"]})) .await; - index.wait_task(update_task2.uid()).await; + index.wait_task(update_task2.uid()).await.succeeded(); drop(index); @@ -339,21 +339,21 @@ macro_rules! compute_authorized_multiple_search { let index = server.index("sales"); let documents = DOCUMENTS.clone(); 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!({"filterableAttributes": ["color"]})) .await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); drop(index); let index = server.index("products"); let documents = NESTED_DOCUMENTS.clone(); 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!({"filterableAttributes": ["doggos"]})) .await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); drop(index); @@ -423,7 +423,7 @@ macro_rules! compute_forbidden_single_search { let index = server.index("sales"); let documents = DOCUMENTS.clone(); 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!({"filterableAttributes": ["color"]})) .await; diff --git a/crates/meilisearch/tests/common/mod.rs b/crates/meilisearch/tests/common/mod.rs index 44385752e..918256d6a 100644 --- a/crates/meilisearch/tests/common/mod.rs +++ b/crates/meilisearch/tests/common/mod.rs @@ -426,7 +426,7 @@ pub async fn shared_index_with_test_set() -> &'static Index<'static, Shared> { ) .await; assert_eq!(code, 202); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); index }) .await diff --git a/crates/meilisearch/tests/index/create_index.rs b/crates/meilisearch/tests/index/create_index.rs index 9b9fbd039..ed5f9e9cd 100644 --- a/crates/meilisearch/tests/index/create_index.rs +++ b/crates/meilisearch/tests/index/create_index.rs @@ -131,7 +131,7 @@ async fn create_index_with_invalid_primary_key() { let (response, code) = index.add_documents(documents, Some("title")).await; assert_eq!(code, 202); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); let (response, code) = index.get().await; 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; assert_eq!(code, 202); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); let (response, code) = index.get().await; assert_eq!(code, 200); diff --git a/crates/meilisearch/tests/index/get_index.rs b/crates/meilisearch/tests/index/get_index.rs index e22874b81..16c9dcd0e 100644 --- a/crates/meilisearch/tests/index/get_index.rs +++ b/crates/meilisearch/tests/index/get_index.rs @@ -11,7 +11,7 @@ async fn create_and_get_index() { assert_eq!(code, 202); - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); let (response, code) = index.get().await; @@ -57,7 +57,7 @@ async fn list_multiple_indexes() { server.index("test").create(None).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; assert_eq!(code, 200); diff --git a/crates/meilisearch/tests/index/stats.rs b/crates/meilisearch/tests/index/stats.rs index c427af12d..291cb0ce0 100644 --- a/crates/meilisearch/tests/index/stats.rs +++ b/crates/meilisearch/tests/index/stats.rs @@ -9,7 +9,7 @@ async fn stats() { assert_eq!(code, 202); - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); let (response, code) = index.stats().await; @@ -33,7 +33,7 @@ async fn stats() { assert_eq!(code, 202); assert_eq!(response["taskUid"], 1); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); let (response, code) = index.stats().await; diff --git a/crates/meilisearch/tests/index/update_index.rs b/crates/meilisearch/tests/index/update_index.rs index d00a44564..0430cee34 100644 --- a/crates/meilisearch/tests/index/update_index.rs +++ b/crates/meilisearch/tests/index/update_index.rs @@ -61,7 +61,7 @@ async fn update_nothing() { assert_eq!(code, 202); - index.wait_task(task1.uid()).await; + index.wait_task(task1.uid()).await.succeeded(); let (task2, code) = index.update(None).await; diff --git a/crates/meilisearch/tests/logs/mod.rs b/crates/meilisearch/tests/logs/mod.rs index 26482b561..e4dc50a9c 100644 --- a/crates/meilisearch/tests/logs/mod.rs +++ b/crates/meilisearch/tests/logs/mod.rs @@ -94,7 +94,7 @@ async fn basic_test_log_stream_route() { "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 = req.to_request(); diff --git a/crates/meilisearch/tests/search/distinct.rs b/crates/meilisearch/tests/search/distinct.rs index b488c35a2..968cc58a1 100644 --- a/crates/meilisearch/tests/search/distinct.rs +++ b/crates/meilisearch/tests/search/distinct.rs @@ -152,7 +152,7 @@ async fn distinct_search_with_offset_no_ranking() { let documents = DOCUMENTS.clone(); index.add_documents(documents, Some(DOCUMENT_PRIMARY_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> { let hits_array = response["hits"].as_array().unwrap(); @@ -211,7 +211,7 @@ async fn distinct_search_with_pagination_no_ranking() { let documents = DOCUMENTS.clone(); index.add_documents(documents, Some(DOCUMENT_PRIMARY_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> { let hits_array = response["hits"].as_array().unwrap(); diff --git a/crates/meilisearch/tests/search/errors.rs b/crates/meilisearch/tests/search/errors.rs index ab50e2aa1..a1c6fd92a 100644 --- a/crates/meilisearch/tests/search/errors.rs +++ b/crates/meilisearch/tests/search/errors.rs @@ -640,7 +640,7 @@ async fn filter_invalid_syntax_object() { let index = server.unique_index(); let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .search(json!({"filter": "title & Glass"}), |response, code| { @@ -663,7 +663,7 @@ async fn filter_invalid_syntax_array() { let index = server.unique_index(); let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .search(json!({"filter": ["title & Glass"]}), |response, code| { @@ -686,7 +686,7 @@ async fn filter_invalid_syntax_string() { let index = server.unique_index(); 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!({ "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", diff --git a/crates/meilisearch/tests/search/facet_search.rs b/crates/meilisearch/tests/search/facet_search.rs index 56afc35e7..c4ef2df9b 100644 --- a/crates/meilisearch/tests/search/facet_search.rs +++ b/crates/meilisearch/tests/search/facet_search.rs @@ -42,7 +42,7 @@ async fn simple_facet_search() { let documents = DOCUMENTS.clone(); index.update_settings_filterable_attributes(json!(["genres"])).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) = 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_typo_tolerance(json!({ "enabled": false })).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) = 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_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).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) = 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_filterable_attributes(json!(["genres"])).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) = index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; @@ -246,7 +246,7 @@ async fn simple_facet_search_by_count_with_max_values() { .await; index.update_settings_filterable_attributes(json!(["genres"])).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) = 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 (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) = index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; diff --git a/crates/meilisearch/tests/search/formatted.rs b/crates/meilisearch/tests/search/formatted.rs index 5ded39976..17fd4c517 100644 --- a/crates/meilisearch/tests/search/formatted.rs +++ b/crates/meilisearch/tests/search/formatted.rs @@ -65,7 +65,7 @@ async fn formatted_contain_wildcard() { let documents = NESTED_DOCUMENTS.clone(); 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 }), |response, code| @@ -398,7 +398,7 @@ async fn displayedattr_2_smol() { let documents = NESTED_DOCUMENTS.clone(); let (response, _) = index.add_documents(documents, None).await; - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); index .search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }), diff --git a/crates/meilisearch/tests/search/geo.rs b/crates/meilisearch/tests/search/geo.rs index 0af88a699..d304e940e 100644 --- a/crates/meilisearch/tests/search/geo.rs +++ b/crates/meilisearch/tests/search/geo.rs @@ -47,7 +47,7 @@ async fn geo_sort_with_geo_strings() { index.update_settings_filterable_attributes(json!(["_geo"])).await; index.update_settings_sortable_attributes(json!(["_geo"])).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 .search( @@ -128,7 +128,7 @@ async fn bug_4640() { index.add_documents(documents, None).await; index.update_settings_filterable_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 index diff --git a/crates/meilisearch/tests/search/hybrid.rs b/crates/meilisearch/tests/search/hybrid.rs index 00a65d9aa..03bea609c 100644 --- a/crates/meilisearch/tests/search/hybrid.rs +++ b/crates/meilisearch/tests/search/hybrid.rs @@ -30,11 +30,11 @@ async fn index_with_documents_user_provided<'a>( "dimensions": 2}}} )) .await; 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; assert_eq!(202, code, "{:?}", response); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); index } @@ -63,11 +63,11 @@ async fn index_with_documents_hf<'a>(server: &'a Server, documents: &Value) -> I }}} )) .await; 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; assert_eq!(202, code, "{:?}", response); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); index } diff --git a/crates/meilisearch/tests/search/locales.rs b/crates/meilisearch/tests/search/locales.rs index 345c52193..89f3ff597 100644 --- a/crates/meilisearch/tests/search/locales.rs +++ b/crates/meilisearch/tests/search/locales.rs @@ -99,7 +99,7 @@ async fn simple_search() { ) .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 index @@ -221,7 +221,7 @@ async fn force_locales() { } "###); 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 index @@ -299,7 +299,7 @@ async fn force_locales_with_pattern() { } "###); 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 index @@ -375,7 +375,7 @@ async fn force_locales_with_pattern_nested() { } "###); let (task,_status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); // chinese index @@ -450,7 +450,7 @@ async fn force_different_locales_with_pattern() { } "###); 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 index diff --git a/crates/meilisearch/tests/search/matching_strategy.rs b/crates/meilisearch/tests/search/matching_strategy.rs index 83334703a..37004569b 100644 --- a/crates/meilisearch/tests/search/matching_strategy.rs +++ b/crates/meilisearch/tests/search/matching_strategy.rs @@ -9,7 +9,7 @@ async fn index_with_documents<'a>(server: &'a Server, documents: &Value) -> Inde let index = server.index("test"); 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 } diff --git a/crates/meilisearch/tests/search/mod.rs b/crates/meilisearch/tests/search/mod.rs index 8ccd7f1df..e8da55165 100644 --- a/crates/meilisearch/tests/search/mod.rs +++ b/crates/meilisearch/tests/search/mod.rs @@ -139,7 +139,7 @@ async fn phrase_search_with_stop_word() { let documents = DOCUMENTS.clone(); let (task,_status_code) = index.add_documents(documents, None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .search(json!({"q": "how \"to\" train \"the" }), |response, code| { @@ -219,10 +219,10 @@ async fn negative_special_cases_search() { let documents = DOCUMENTS.clone(); 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; - 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 index diff --git a/crates/meilisearch/tests/search/multi.rs b/crates/meilisearch/tests/search/multi.rs index bf07914be..134914902 100644 --- a/crates/meilisearch/tests/search/multi.rs +++ b/crates/meilisearch/tests/search/multi.rs @@ -90,7 +90,7 @@ async fn simple_search_single_index() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"queries": [ @@ -162,7 +162,7 @@ async fn federation_single_search_single_index() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"federation": {}, "queries": [ @@ -209,7 +209,7 @@ async fn federation_multiple_search_single_index() { let documents = SCORE_DOCUMENTS.clone(); 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 .multi_search(json!({"federation": {}, "queries": [ @@ -284,7 +284,7 @@ async fn federation_two_search_single_index() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"federation": {}, "queries": [ @@ -352,7 +352,7 @@ async fn simple_search_missing_index_uid() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"queries": [ @@ -377,7 +377,7 @@ async fn federation_simple_search_missing_index_uid() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"federation": {}, "queries": [ @@ -402,7 +402,7 @@ async fn simple_search_illegal_index_uid() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"queries": [ @@ -427,7 +427,7 @@ async fn federation_search_illegal_index_uid() { let documents = DOCUMENTS.clone(); 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 .multi_search(json!({"federation": {}, "queries": [ @@ -452,12 +452,12 @@ async fn simple_search_two_indexes() { let documents = DOCUMENTS.clone(); 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 documents = NESTED_DOCUMENTS.clone(); 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 .multi_search(json!({"queries": [ @@ -559,7 +559,7 @@ async fn federation_two_search_two_indexes() { let documents = DOCUMENTS.clone(); 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 documents = NESTED_DOCUMENTS.clone(); diff --git a/crates/meilisearch/tests/search/restrict_searchable.rs b/crates/meilisearch/tests/search/restrict_searchable.rs index 37b2068b2..0a119f912 100644 --- a/crates/meilisearch/tests/search/restrict_searchable.rs +++ b/crates/meilisearch/tests/search/restrict_searchable.rs @@ -66,7 +66,7 @@ async fn search_no_searchable_attribute_set() { .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 .search( @@ -79,7 +79,7 @@ async fn search_no_searchable_attribute_set() { .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 .search( @@ -110,7 +110,7 @@ async fn search_on_all_attributes_restricted_set() { let server = Server::new().await; let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).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 .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 index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).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). index @@ -359,7 +359,7 @@ async fn search_on_exact_field() { let (response, code) = index.update_settings_typo_tolerance(json!({ "disableOnAttributes": ["exact"] })).await; 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. index .search(json!({"q": "Marvel", "attributesToSearchOn": ["exact"]}), |response, code| { diff --git a/crates/meilisearch/tests/stats/mod.rs b/crates/meilisearch/tests/stats/mod.rs index 8ce86fceb..1b4e458d3 100644 --- a/crates/meilisearch/tests/stats/mod.rs +++ b/crates/meilisearch/tests/stats/mod.rs @@ -31,7 +31,7 @@ async fn stats() { let (task, code) = index.create(Some("id")).await; assert_eq!(code, 202); - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); let (response, code) = server.stats().await; @@ -57,7 +57,7 @@ async fn stats() { assert_eq!(code, 202, "{}", response); assert_eq!(response["taskUid"], 1); - index.wait_task(response.uid()).await; + index.wait_task(response.uid()).await.succeeded(); let timestamp = OffsetDateTime::now_utc(); let (response, code) = server.stats().await; diff --git a/crates/meilisearch/tests/tasks/mod.rs b/crates/meilisearch/tests/tasks/mod.rs index 21345c972..3bbb15d75 100644 --- a/crates/meilisearch/tests/tasks/mod.rs +++ b/crates/meilisearch/tests/tasks/mod.rs @@ -14,7 +14,7 @@ async fn error_get_unexisting_task_status() { let server = Server::new().await; let index = server.index("test"); 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 expected_response = json!({ @@ -42,7 +42,7 @@ async fn get_task_status() { None, ) .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; assert_eq!(code, 200); // TODO check response format, as per #48 @@ -53,7 +53,7 @@ async fn list_tasks() { let server = Server::new().await; let index = server.index("test"); let (task,_status_code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -105,7 +105,7 @@ async fn list_tasks_with_star_filters() { let server = Server::new().await; let index = server.index("test"); let (task, _code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -150,7 +150,7 @@ async fn list_tasks_status_filtered() { let server = Server::new().await; let index = server.index("test"); let (task,_status_code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -164,7 +164,7 @@ async fn list_tasks_status_filtered() { // assert_eq!(code, 200, "{}", response); // 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; assert_eq!(code, 200, "{}", response); @@ -176,7 +176,7 @@ async fn list_tasks_type_filtered() { let server = Server::new().await; let index = server.index("test"); let (task,_status_code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -196,7 +196,7 @@ async fn list_tasks_invalid_canceled_by_filter() { let server = Server::new().await; let index = server.index("test"); let (task,_status_code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -211,7 +211,7 @@ async fn list_tasks_status_and_type_filtered() { let server = Server::new().await; let index = server.index("test"); let (task,_status_code) = index.create(None).await; - index.wait_task(task.uid()).await; + index.wait_task(task.uid()).await.succeeded(); index .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .await; @@ -279,7 +279,7 @@ async fn test_summarized_document_addition_or_update() { let server = Server::new().await; let index = server.index("test"); 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; assert_json_snapshot!(task, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }, diff --git a/crates/meilisearch/tests/vector/mod.rs b/crates/meilisearch/tests/vector/mod.rs index adad9fa81..5f5cbe359 100644 --- a/crates/meilisearch/tests/vector/mod.rs +++ b/crates/meilisearch/tests/vector/mod.rs @@ -55,7 +55,7 @@ async fn add_remove_user_provided() { })) .await; snapshot!(code, @"202 Accepted"); - server.wait_task(response.uid()).await; + server.wait_task(response.uid()).await.succeeded(); let documents = json!([ {"id": 0, "name": "kefir", "_vectors": { "manual": [0, 0, 0] }}, diff --git a/crates/meilisearch/tests/vector/settings.rs b/crates/meilisearch/tests/vector/settings.rs index 027c55219..85b7d2b7f 100644 --- a/crates/meilisearch/tests/vector/settings.rs +++ b/crates/meilisearch/tests/vector/settings.rs @@ -73,7 +73,7 @@ async fn update_embedder() { })) .await; snapshot!(code, @"202 Accepted"); - server.wait_task(response.uid()).await; + server.wait_task(response.uid()).await.succeeded(); let (response, code) = index .update_settings(json!({