From be839ae341a22dc0bcfa9551ba297eae5db11410 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 4 Feb 2025 11:49:11 +0100 Subject: [PATCH] add a dump test with batches and enqueued tasks --- ...v6_v1.13.0_batches_and_enqueued_tasks.dump | Bin 0 -> 1706 bytes crates/meilisearch/tests/common/server.rs | 4 + crates/meilisearch/tests/dumps/data.rs | 5 ++ crates/meilisearch/tests/dumps/mod.rs | 55 ++++++++++++ .../batches.snap | 78 ++++++++++++++++++ .../tasks.snap | 78 ++++++++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 crates/meilisearch/tests/assets/v6_v1.13.0_batches_and_enqueued_tasks.dump create mode 100644 crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/batches.snap create mode 100644 crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/tasks.snap diff --git a/crates/meilisearch/tests/assets/v6_v1.13.0_batches_and_enqueued_tasks.dump b/crates/meilisearch/tests/assets/v6_v1.13.0_batches_and_enqueued_tasks.dump new file mode 100644 index 0000000000000000000000000000000000000000..a1816b79a61b0eaf7612974cc3304db694f1bb3a GIT binary patch literal 1706 zcmV;b237eViwFP!00000|Lt2}Z`(Ey*YiGwr^mu}#6OZOzqJj51;f^&O*){%V9*kk zaFIn#qSkmpzWa`(<=Al?r>U*2t$q)YMII^gjy&EUW_aWr9G*wL(D&i#q0skMpA8&D zp@alJJau_U5pjH{1=N*dWv}OaDVm8i&#wghy5Oal@m#TNkaDK#l2^k&E15fcgNHmX zpmeMJ5yAK5k0|wt(+U&6bNS!6GpO^FUmy6I&YG zt*K2_RmU;s35Vtgny7ifO}WSue*L-xTf!U?y3Q1xi^SAl@l=$$+j^4`hMi&00sD?+jmoui|X<*>IhRjB6Oswd2ZIUp}uiBD>K2X?cec8 z7)60;DYN8Bl()A(EZB!u+2@u#=HhRjEYD0sV0f@z_=Sv47G1qe;D82RzbVg)gz1C( zxjg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KV&x; zc=oJS`ww2o=Kp^LUH-QXEK)zq1lc0xrDINGts0h*q3wy%z{A7~X|xg;+M2l|kkq^sWF65gB^A5a^CgLV9ab zE1(dz>2~(lgw?d^u!cX*{;|{k-^~AY_rF@gQ}X0ahYlS&bol1*FWU#kjsQde05Il! ALjV8( literal 0 HcmV?d00001 diff --git a/crates/meilisearch/tests/common/server.rs b/crates/meilisearch/tests/common/server.rs index c017a060c..c9ab3dced 100644 --- a/crates/meilisearch/tests/common/server.rs +++ b/crates/meilisearch/tests/common/server.rs @@ -163,6 +163,10 @@ impl Server { self.service.get("/tasks").await } + pub async fn batches(&self) -> (Value, StatusCode) { + self.service.get("/batches").await + } + pub async fn set_features(&self, value: Value) -> (Value, StatusCode) { self.service.patch("/experimental-features", value).await } diff --git a/crates/meilisearch/tests/dumps/data.rs b/crates/meilisearch/tests/dumps/data.rs index d353aaf1d..cb46aa41f 100644 --- a/crates/meilisearch/tests/dumps/data.rs +++ b/crates/meilisearch/tests/dumps/data.rs @@ -22,6 +22,7 @@ pub enum GetDump { TestV5, TestV6WithExperimental, + TestV6WithBatchesAndEnqueuedTasks, } impl GetDump { @@ -74,6 +75,10 @@ impl GetDump { "tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump" ) .into(), + GetDump::TestV6WithBatchesAndEnqueuedTasks => { + exist_relative_path!("tests/assets/v6_v1.13.0_batches_and_enqueued_tasks.dump") + .into() + } } } } diff --git a/crates/meilisearch/tests/dumps/mod.rs b/crates/meilisearch/tests/dumps/mod.rs index 2b4c32cc7..66bac7277 100644 --- a/crates/meilisearch/tests/dumps/mod.rs +++ b/crates/meilisearch/tests/dumps/mod.rs @@ -1993,6 +1993,61 @@ async fn import_dump_v6_containing_experimental_features() { .await; } +#[actix_rt::test] +async fn import_dump_v6_containing_batches_and_enqueued_tasks() { + let temp = tempfile::tempdir().unwrap(); + + let options = Opt { + import_dump: Some(GetDump::TestV6WithBatchesAndEnqueuedTasks.path()), + ..default_settings(temp.path()) + }; + let mut server = Server::new_auth_with_options(options, temp).await; + server.use_api_key("MASTER_KEY"); + server.wait_task(2).await.succeeded(); + let (tasks, _) = server.tasks().await; + snapshot!(json_string!(tasks, { ".results[1].startedAt" => "[date]", ".results[1].finishedAt" => "[date]", ".results[1].duration" => "[date]" }), name: "tasks"); + let (batches, _) = server.batches().await; + snapshot!(json_string!(batches, { ".results[0].startedAt" => "[date]", ".results[0].finishedAt" => "[date]", ".results[0].duration" => "[date]" }), name: "batches"); + + let (indexes, code) = server.list_indexes(None, None).await; + assert_eq!(code, 200, "{indexes}"); + + assert_eq!(indexes["results"].as_array().unwrap().len(), 1); + assert_eq!(indexes["results"][0]["uid"], json!("kefir")); + assert_eq!(indexes["results"][0]["primaryKey"], json!("id")); + + let (response, code) = server.get_features().await; + meili_snap::snapshot!(code, @"200 OK"); + meili_snap::snapshot!(meili_snap::json_string!(response), @r###" + { + "metrics": false, + "logsRoute": false, + "editDocumentsByFunction": false, + "containsFilter": false + } + "###); + + let index = server.index("kefir"); + let (documents, _) = index.get_all_documents_raw("").await; + snapshot!(documents, @r#" + { + "results": [ + { + "id": 1, + "dog": "kefir" + }, + { + "id": 2, + "dog": "intel" + } + ], + "offset": 0, + "limit": 20, + "total": 2 + } + "#); +} + // In this test we must generate the dump ourselves to ensure the // `user provided` vectors are well set #[actix_rt::test] diff --git a/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/batches.snap b/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/batches.snap new file mode 100644 index 000000000..aeac6cf55 --- /dev/null +++ b/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/batches.snap @@ -0,0 +1,78 @@ +--- +source: crates/meilisearch/tests/dumps/mod.rs +snapshot_kind: text +--- +{ + "results": [ + { + "uid": 2, + "progress": null, + "details": { + "receivedDocuments": 1, + "indexedDocuments": 1 + }, + "stats": { + "totalNbTasks": 1, + "status": { + "succeeded": 1 + }, + "types": { + "documentAdditionOrUpdate": 1 + }, + "indexUids": { + "kefir": 1 + } + }, + "duration": "[date]", + "startedAt": "[date]", + "finishedAt": "[date]" + }, + { + "uid": 1, + "progress": null, + "details": { + "receivedDocuments": 1, + "indexedDocuments": 1 + }, + "stats": { + "totalNbTasks": 1, + "status": { + "succeeded": 1 + }, + "types": { + "documentAdditionOrUpdate": 1 + }, + "indexUids": { + "kefir": 1 + } + }, + "duration": "PT0.144827890S", + "startedAt": "2025-02-04T10:15:21.275640274Z", + "finishedAt": "2025-02-04T10:15:21.420468164Z" + }, + { + "uid": 0, + "progress": null, + "details": {}, + "stats": { + "totalNbTasks": 1, + "status": { + "succeeded": 1 + }, + "types": { + "indexCreation": 1 + }, + "indexUids": { + "kefir": 1 + } + }, + "duration": "PT0.032902186S", + "startedAt": "2025-02-04T10:14:43.559526162Z", + "finishedAt": "2025-02-04T10:14:43.592428348Z" + } + ], + "total": 3, + "limit": 20, + "from": 2, + "next": null +} diff --git a/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/tasks.snap b/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/tasks.snap new file mode 100644 index 000000000..99dc06f24 --- /dev/null +++ b/crates/meilisearch/tests/dumps/snapshots/mod.rs/import_dump_v6_containing_batches_and_enqueued_tasks/tasks.snap @@ -0,0 +1,78 @@ +--- +source: crates/meilisearch/tests/dumps/mod.rs +snapshot_kind: text +--- +{ + "results": [ + { + "uid": 3, + "batchUid": null, + "indexUid": null, + "status": "succeeded", + "type": "dumpCreation", + "canceledBy": null, + "details": { + "dumpUid": null + }, + "error": null, + "duration": "PT0.000629059S", + "enqueuedAt": "2025-02-04T10:22:31.318175268Z", + "startedAt": "2025-02-04T10:22:31.331701375Z", + "finishedAt": "2025-02-04T10:22:31.332330434Z" + }, + { + "uid": 2, + "batchUid": 2, + "indexUid": "kefir", + "status": "succeeded", + "type": "documentAdditionOrUpdate", + "canceledBy": null, + "details": { + "receivedDocuments": 1, + "indexedDocuments": 1 + }, + "error": null, + "duration": "[date]", + "enqueuedAt": "2025-02-04T10:15:49.212484063Z", + "startedAt": "[date]", + "finishedAt": "[date]" + }, + { + "uid": 1, + "batchUid": null, + "indexUid": "kefir", + "status": "succeeded", + "type": "documentAdditionOrUpdate", + "canceledBy": null, + "details": { + "receivedDocuments": 1, + "indexedDocuments": 1 + }, + "error": null, + "duration": "PT0.144827890S", + "enqueuedAt": "2025-02-04T10:15:21.258630973Z", + "startedAt": "2025-02-04T10:15:21.275640274Z", + "finishedAt": "2025-02-04T10:15:21.420468164Z" + }, + { + "uid": 0, + "batchUid": null, + "indexUid": "kefir", + "status": "succeeded", + "type": "indexCreation", + "canceledBy": null, + "details": { + "primaryKey": null + }, + "error": null, + "duration": "PT0.032902186S", + "enqueuedAt": "2025-02-04T10:14:43.550379968Z", + "startedAt": "2025-02-04T10:14:43.559526162Z", + "finishedAt": "2025-02-04T10:14:43.592428348Z" + } + ], + "total": 4, + "limit": 20, + "from": 3, + "next": null +}