mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	add a dump test with batches and enqueued tasks
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| @@ -163,6 +163,10 @@ impl Server<Owned> { | ||||
|         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 | ||||
|     } | ||||
|   | ||||
| @@ -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() | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1994,6 +1994,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] | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
| @@ -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 | ||||
| } | ||||
		Reference in New Issue
	
	Block a user