WIP: More snapshot updates

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
Martin Tzvetanov Grigorov
2025-06-03 09:13:56 +03:00
parent 7380808b26
commit cb15e5c67e

View File

@ -12,10 +12,10 @@ async fn error_get_unexisting_batch_status() {
let index = server.unique_index(); let index = server.unique_index();
let (task, _coder) = index.create(None).await; let (task, _coder) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_batch(1).await; let (response, code) = index.get_batch(task.uid() as u32).await;
let expected_response = json!({ let expected_response = json!({
"message": "Batch `1` not found.", "message": format!("Batch `{}` not found.", task.uid()),
"code": "batch_not_found", "code": "batch_not_found",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#batch_not_found" "link": "https://docs.meilisearch.com/errors#batch_not_found"
@ -147,15 +147,15 @@ async fn list_batches_status_filtered() {
index.wait_task(task.uid()).await.failed(); index.wait_task(task.uid()).await.failed();
let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await; let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await;
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);
let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await; let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await;
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);
let (response, code) = index.filtered_batches(&[], &["succeeded", "failed"], &[]).await; let (response, code) = index.filtered_batches(&[], &["succeeded", "failed"], &[]).await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{response}");
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
} }
@ -168,16 +168,16 @@ async fn list_batches_type_filtered() {
let (task, _) = index.delete().await; let (task, _) = index.delete().await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.filtered_batches(&["indexCreation"], &[], &[]).await; let (response, code) = index.filtered_batches(&["indexCreation"], &[], &[]).await;
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);
let (response, code) = let (response, code) =
index.filtered_batches(&["indexCreation", "IndexDeletion"], &[], &[]).await; index.filtered_batches(&["indexCreation", "indexDeletion"], &[], &[]).await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{response}");
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index.filtered_batches(&["indexCreation"], &[], &[]).await; let (response, code) = index.filtered_batches(&["indexCreation"], &[], &[]).await;
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);
} }
@ -189,7 +189,7 @@ async fn list_batches_invalid_canceled_by_filter() {
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.filtered_batches(&[], &[], &["0"]).await; let (response, code) = index.filtered_batches(&[], &[], &["0"]).await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{response}");
assert_eq!(response["results"].as_array().unwrap().len(), 0); assert_eq!(response["results"].as_array().unwrap().len(), 0);
} }
@ -203,7 +203,7 @@ async fn list_batches_status_and_type_filtered() {
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.filtered_batches(&["indexCreation"], &["failed"], &[]).await; let (response, code) = index.filtered_batches(&["indexCreation"], &["failed"], &[]).await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{response}");
assert_eq!(response["results"].as_array().unwrap().len(), 0); assert_eq!(response["results"].as_array().unwrap().len(), 0);
let (response, code) = index let (response, code) = index
@ -213,7 +213,7 @@ async fn list_batches_status_and_type_filtered() {
&[], &[],
) )
.await; .await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{response}");
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
} }
@ -222,7 +222,7 @@ async fn list_batch_filter_error() {
let server = Server::new_shared(); let server = Server::new_shared();
let (response, code) = server.batches_filter("lol=pied").await; let (response, code) = server.batches_filter("lol=pied").await;
assert_eq!(code, 400, "{}", response); assert_eq!(code, 400, "{response}");
meili_snap::snapshot!(meili_snap::json_string!(response), @r#" meili_snap::snapshot!(meili_snap::json_string!(response), @r#"
{ {
"message": "Unknown parameter `lol`: expected one of `limit`, `from`, `reverse`, `batchUids`, `uids`, `canceledBy`, `types`, `statuses`, `indexUids`, `afterEnqueuedAt`, `beforeEnqueuedAt`, `afterStartedAt`, `beforeStartedAt`, `afterFinishedAt`, `beforeFinishedAt`", "message": "Unknown parameter `lol`: expected one of `limit`, `from`, `reverse`, `batchUids`, `uids`, `canceledBy`, `types`, `statuses`, `indexUids`, `afterEnqueuedAt`, `beforeEnqueuedAt`, `afterStartedAt`, `beforeStartedAt`, `afterFinishedAt`, `beforeFinishedAt`",
@ -233,7 +233,7 @@ async fn list_batch_filter_error() {
"#); "#);
let (response, code) = server.batches_filter("uids=pied").await; let (response, code) = server.batches_filter("uids=pied").await;
assert_eq!(code, 400, "{}", response); assert_eq!(code, 400, "{response}");
meili_snap::snapshot!(meili_snap::json_string!(response), @r#" meili_snap::snapshot!(meili_snap::json_string!(response), @r#"
{ {
"message": "Invalid value in parameter `uids`: could not parse `pied` as a positive integer", "message": "Invalid value in parameter `uids`: could not parse `pied` as a positive integer",
@ -244,7 +244,7 @@ async fn list_batch_filter_error() {
"#); "#);
let (response, code) = server.batches_filter("from=pied").await; let (response, code) = server.batches_filter("from=pied").await;
assert_eq!(code, 400, "{}", response); assert_eq!(code, 400, "{response}");
meili_snap::snapshot!(meili_snap::json_string!(response), @r#" meili_snap::snapshot!(meili_snap::json_string!(response), @r#"
{ {
"message": "Invalid value in parameter `from`: could not parse `pied` as a positive integer", "message": "Invalid value in parameter `from`: could not parse `pied` as a positive integer",
@ -255,7 +255,7 @@ async fn list_batch_filter_error() {
"#); "#);
let (response, code) = server.batches_filter("beforeStartedAt=pied").await; let (response, code) = server.batches_filter("beforeStartedAt=pied").await;
assert_eq!(code, 400, "{}", response); assert_eq!(code, 400, "{response}");
meili_snap::snapshot!(meili_snap::json_string!(response), @r#" meili_snap::snapshot!(meili_snap::json_string!(response), @r#"
{ {
"message": "Invalid value in parameter `beforeStartedAt`: `pied` is an invalid date-time. It should follow the YYYY-MM-DD or RFC 3339 date-time format.", "message": "Invalid value in parameter `beforeStartedAt`: `pied` is an invalid date-time. It should follow the YYYY-MM-DD or RFC 3339 date-time format.",
@ -283,7 +283,8 @@ async fn test_summarized_document_addition_or_update() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.internalDatabaseSizes" => "[internalDatabaseSizes]" ".stats.internalDatabaseSizes" => "[internalDatabaseSizes]",
".stats.indexUids" => r#"""{"test": 1}"""#
}, },
@r###" @r###"
{ {
@ -301,9 +302,7 @@ async fn test_summarized_document_addition_or_update() {
"types": { "types": {
"documentAdditionOrUpdate": 1 "documentAdditionOrUpdate": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]", "progressTrace": "[progressTrace]",
"writeChannelCongestion": "[writeChannelCongestion]", "writeChannelCongestion": "[writeChannelCongestion]",
"internalDatabaseSizes": "[internalDatabaseSizes]" "internalDatabaseSizes": "[internalDatabaseSizes]"
@ -376,7 +375,7 @@ async fn test_summarized_delete_documents_by_batch() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"test\": 1}" ".stats.indexUids" => r#"""{"test": 1}"""#
}, },
@r###" @r###"
{ {
@ -394,9 +393,7 @@ async fn test_summarized_delete_documents_by_batch() {
"types": { "types": {
"documentDeletion": 1 "documentDeletion": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -467,7 +464,8 @@ async fn test_summarized_delete_documents_by_filter() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"test\": 1}" ".stats.indexUids" => r#"""{"test": 1}"""#,
".batchCreationComplete" => "batched all enqueued tasks for index `[uuid`"
}, },
@r###" @r###"
{ {
@ -486,15 +484,13 @@ async fn test_summarized_delete_documents_by_filter() {
"types": { "types": {
"documentDeletion": 1 "documentDeletion": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
"startedAt": "[date]", "startedAt": "[date]",
"finishedAt": "[date]", "finishedAt": "[date]",
"batchCreationComplete": "batched all enqueued tasks" "batchCreationComplete": "batched all enqueued tasks for index `[uuid`"
} }
"###); "###);
@ -603,7 +599,7 @@ async fn test_summarized_delete_document_by_id() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"test\": 1}" ".stats.indexUids" => r#"""{"test": 1}"""#
}, },
@r###" @r###"
{ {
@ -621,9 +617,7 @@ async fn test_summarized_delete_document_by_id() {
"types": { "types": {
"documentDeletion": 1 "documentDeletion": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -705,7 +699,7 @@ async fn test_summarized_settings_update() {
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.internalDatabaseSizes" => "[internalDatabaseSizes]", ".stats.internalDatabaseSizes" => "[internalDatabaseSizes]",
".stats.indexUids" => "{\n\t\"test\": 1}", ".stats.indexUids" => r#"""{"test": 1}"""#,
".batchCreationComplete" => "batched all enqueued tasks for index `[uuid]`" ".batchCreationComplete" => "batched all enqueued tasks for index `[uuid]`"
}, },
@ -734,9 +728,7 @@ async fn test_summarized_settings_update() {
"types": { "types": {
"settingsUpdate": 1 "settingsUpdate": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -763,7 +755,7 @@ async fn test_summarized_index_creation() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"test\": 1}", ".stats.indexUids" => r#"""{"test": 1}"""#,
".batchCreationComplete" => "task with id X of type `indexCreation` cannot be batched" ".batchCreationComplete" => "task with id X of type `indexCreation` cannot be batched"
}, },
@r###" @r###"
@ -779,9 +771,7 @@ async fn test_summarized_index_creation() {
"types": { "types": {
"indexCreation": 1 "indexCreation": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -896,7 +886,7 @@ async fn test_summarized_index_deletion() {
{ {
"uid": "[uid]", "uid": "[uid]",
"batchUid": "[batch_uid]", "batchUid": "[batch_uid]",
"indexUid": "test", "indexUid": "[uuid]",
"status": "succeeded", "status": "succeeded",
"type": "indexDeletion", "type": "indexDeletion",
"canceledBy": null, "canceledBy": null,
@ -919,7 +909,7 @@ async fn test_summarized_index_deletion() {
{ {
"uid": "[uid]", "uid": "[uid]",
"batchUid": "[batch_uid]", "batchUid": "[batch_uid]",
"indexUid": "test", "indexUid": "[uuid]",
"status": "failed", "status": "failed",
"type": "indexDeletion", "type": "indexDeletion",
"canceledBy": null, "canceledBy": null,
@ -927,7 +917,7 @@ async fn test_summarized_index_deletion() {
"deletedDocuments": 0 "deletedDocuments": 0
}, },
"error": { "error": {
"message": "Index `test` not found.", "message": "Index `[uuid]` not found.",
"code": "index_not_found", "code": "index_not_found",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found" "link": "https://docs.meilisearch.com/errors#index_not_found"
@ -947,7 +937,7 @@ async fn test_summarized_index_update() {
// If the index doesn't exist yet, we should get errors with or without the primary key. // If the index doesn't exist yet, we should get errors with or without the primary key.
let (task, _status_code) = index.update(None).await; let (task, _status_code) = index.update(None).await;
index.wait_task(task.uid()).await.failed(); index.wait_task(task.uid()).await.failed();
let (batch, _) = index.get_batch(task.uid() as u32).await; let (batch, _) = index.get_batch(task.uid() as u32).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
{ {
".uid" => "[uid]", ".uid" => "[uid]",
@ -957,7 +947,7 @@ async fn test_summarized_index_update() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"test\": 1}", ".stats.indexUids" => r#"{"test": 1}"#,
".batchCreationComplete" => "task with id X of type `indexUpdate` cannot be batched" ".batchCreationComplete" => "task with id X of type `indexUpdate` cannot be batched"
}, },
@r###" @r###"
@ -973,9 +963,7 @@ async fn test_summarized_index_update() {
"types": { "types": {
"indexUpdate": 1 "indexUpdate": 1
}, },
"indexUids": { "indexUids": {"test": 1},
"test": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -1177,7 +1165,7 @@ async fn test_summarized_index_swap() {
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]", ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".stats.indexUids" => "{\n\t\"doggos\": 1}" ".stats.indexUids" => r#"""{"doggos": 1}"""#
}, },
@r###" @r###"
{ {
@ -1192,9 +1180,7 @@ async fn test_summarized_index_swap() {
"types": { "types": {
"indexCreation": 1 "indexCreation": 1
}, },
"indexUids": { "indexUids": {"doggos": 1},
"doggos": 1
},
"progressTrace": "[progressTrace]" "progressTrace": "[progressTrace]"
}, },
"duration": "[duration]", "duration": "[duration]",
@ -1214,19 +1200,21 @@ async fn test_summarized_batch_cancelation() {
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _status_code) = server.cancel_tasks(format!("uids={}", task.uid()).as_str()).await; let (task, _status_code) = server.cancel_tasks(format!("uids={}", task.uid()).as_str()).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(1).await; let (batch, _) = index.get_batch(task.uid() as u32).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
{ {
".uid" => "[uid]",
".duration" => "[duration]", ".duration" => "[duration]",
".enqueuedAt" => "[date]", ".enqueuedAt" => "[date]",
".startedAt" => "[date]", ".startedAt" => "[date]",
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]" ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".batchCreationComplete" => "task with id X of type `taskCancelation` cannot be batched"
}, },
@r###" @r###"
{ {
"uid": 1, "uid": "[uid]",
"progress": null, "progress": null,
"details": { "details": {
"matchedTasks": 1, "matchedTasks": 1,
@ -1247,7 +1235,7 @@ async fn test_summarized_batch_cancelation() {
"duration": "[duration]", "duration": "[duration]",
"startedAt": "[date]", "startedAt": "[date]",
"finishedAt": "[date]", "finishedAt": "[date]",
"batchCreationComplete": "task with id 1 of type `taskCancelation` cannot be batched" "batchCreationComplete": "task with id X of type `taskCancelation` cannot be batched"
} }
"###); "###);
} }
@ -1316,7 +1304,8 @@ async fn test_summarized_dump_creation() {
".startedAt" => "[date]", ".startedAt" => "[date]",
".finishedAt" => "[date]", ".finishedAt" => "[date]",
".stats.progressTrace" => "[progressTrace]", ".stats.progressTrace" => "[progressTrace]",
".stats.writeChannelCongestion" => "[writeChannelCongestion]" ".stats.writeChannelCongestion" => "[writeChannelCongestion]",
".batchCreationComplete" => "task with id X of type `dumpCreation` cannot be batched"
}, },
@r###" @r###"
{ {
@ -1339,7 +1328,7 @@ async fn test_summarized_dump_creation() {
"duration": "[duration]", "duration": "[duration]",
"startedAt": "[date]", "startedAt": "[date]",
"finishedAt": "[date]", "finishedAt": "[date]",
"batchCreationComplete": "task with id 0 of type `dumpCreation` cannot be batched" "batchCreationComplete": "task with id X of type `dumpCreation` cannot be batched"
} }
"###); "###);
} }