diff --git a/crates/meilisearch/tests/documents/delete_documents.rs b/crates/meilisearch/tests/documents/delete_documents.rs index 4dfe2cc79..060f17958 100644 --- a/crates/meilisearch/tests/documents/delete_documents.rs +++ b/crates/meilisearch/tests/documents/delete_documents.rs @@ -157,11 +157,14 @@ async fn delete_document_by_filter() { index.wait_task(task.uid()).await.succeeded(); let (stats, _) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 4, - "rawDocumentDbSize": 42, - "avgDocumentSize": 10, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -208,11 +211,14 @@ async fn delete_document_by_filter() { "###); let (stats, _) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 16, - "avgDocumentSize": 8, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -278,11 +284,14 @@ async fn delete_document_by_filter() { "###); let (stats, _) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 1, - "rawDocumentDbSize": 12, - "avgDocumentSize": 12, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, diff --git a/crates/meilisearch/tests/dumps/mod.rs b/crates/meilisearch/tests/dumps/mod.rs index addcbeeb5..e5aa52dc6 100644 --- a/crates/meilisearch/tests/dumps/mod.rs +++ b/crates/meilisearch/tests/dumps/mod.rs @@ -28,12 +28,15 @@ async fn import_dump_v1_movie_raw() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -185,12 +188,15 @@ async fn import_dump_v1_movie_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -355,12 +361,15 @@ async fn import_dump_v1_rubygems_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 8606, - "avgDocumentSize": 162, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -522,12 +531,15 @@ async fn import_dump_v2_movie_raw() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -679,12 +691,15 @@ async fn import_dump_v2_movie_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -846,12 +861,15 @@ async fn import_dump_v2_rubygems_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 8606, - "avgDocumentSize": 162, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1010,12 +1028,15 @@ async fn import_dump_v3_movie_raw() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1167,12 +1188,15 @@ async fn import_dump_v3_movie_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1334,12 +1358,15 @@ async fn import_dump_v3_rubygems_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 8606, - "avgDocumentSize": 162, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1498,12 +1525,15 @@ async fn import_dump_v4_movie_raw() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1655,12 +1685,15 @@ async fn import_dump_v4_movie_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 21965, - "avgDocumentSize": 414, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1822,12 +1855,15 @@ async fn import_dump_v4_rubygems_with_settings() { let (stats, code) = index.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 53, - "rawDocumentDbSize": 8606, - "avgDocumentSize": 162, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -1994,11 +2030,14 @@ async fn import_dump_v5() { let (stats, code) = index1.stats().await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 10, - "rawDocumentDbSize": 6782, - "avgDocumentSize": 678, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -2031,12 +2070,15 @@ async fn import_dump_v5() { let (stats, code) = index2.stats().await; snapshot!(code, @"200 OK"); snapshot!( - json_string!(stats), + json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 10, - "rawDocumentDbSize": 6782, - "avgDocumentSize": 678, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, diff --git a/crates/meilisearch/tests/stats/mod.rs b/crates/meilisearch/tests/stats/mod.rs index 20a8eaef6..aee626460 100644 --- a/crates/meilisearch/tests/stats/mod.rs +++ b/crates/meilisearch/tests/stats/mod.rs @@ -110,11 +110,14 @@ async fn add_remove_embeddings() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 27, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 5, "numberOfEmbeddedDocuments": 2, @@ -135,11 +138,14 @@ async fn add_remove_embeddings() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 27, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 3, "numberOfEmbeddedDocuments": 2, @@ -160,11 +166,14 @@ async fn add_remove_embeddings() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 27, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 2, "numberOfEmbeddedDocuments": 2, @@ -186,11 +195,14 @@ async fn add_remove_embeddings() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 27, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 2, "numberOfEmbeddedDocuments": 1, @@ -236,11 +248,14 @@ async fn add_remove_embedded_documents() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 27, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 5, "numberOfEmbeddedDocuments": 2, @@ -257,11 +272,14 @@ async fn add_remove_embedded_documents() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 1, - "rawDocumentDbSize": 13, - "avgDocumentSize": 13, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 3, "numberOfEmbeddedDocuments": 1, @@ -290,11 +308,14 @@ async fn update_embedder_settings() { index.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 108, - "avgDocumentSize": 54, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -326,11 +347,14 @@ async fn update_embedder_settings() { server.wait_task(response.uid()).await.succeeded(); let (stats, _code) = index.stats().await; - snapshot!(json_string!(stats), @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[size]", + ".avgDocumentSize" => "[size]", + }), @r###" { "numberOfDocuments": 2, - "rawDocumentDbSize": 108, - "avgDocumentSize": 54, + "rawDocumentDbSize": "[size]", + "avgDocumentSize": "[size]", "isIndexing": false, "numberOfEmbeddings": 3, "numberOfEmbeddedDocuments": 2, diff --git a/crates/meilisearch/tests/upgrade/v1_12/v1_12_0.rs b/crates/meilisearch/tests/upgrade/v1_12/v1_12_0.rs index 9fc4d0e5b..1b2ae054c 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/v1_12_0.rs +++ b/crates/meilisearch/tests/upgrade/v1_12/v1_12_0.rs @@ -133,7 +133,9 @@ async fn check_the_index_scheduler(server: &Server) { let (stats, _) = server.stats().await; assert_json_snapshot!(stats, { ".databaseSize" => "[bytes]", - ".usedDatabaseSize" => "[bytes]" + ".usedDatabaseSize" => "[bytes]", + ".indexes.kefir.rawDocumentDbSize" => "[bytes]", + ".indexes.kefir.avgDocumentSize" => "[bytes]", }, @r###" { @@ -143,8 +145,8 @@ async fn check_the_index_scheduler(server: &Server) { "indexes": { "kefir": { "numberOfDocuments": 1, - "rawDocumentDbSize": 109, - "avgDocumentSize": 109, + "rawDocumentDbSize": "[bytes]", + "avgDocumentSize": "[bytes]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -217,7 +219,9 @@ async fn check_the_index_scheduler(server: &Server) { let (stats, _) = server.stats().await; assert_json_snapshot!(stats, { ".databaseSize" => "[bytes]", - ".usedDatabaseSize" => "[bytes]" + ".usedDatabaseSize" => "[bytes]", + ".indexes.kefir.rawDocumentDbSize" => "[bytes]", + ".indexes.kefir.avgDocumentSize" => "[bytes]", }, @r###" { @@ -227,8 +231,8 @@ async fn check_the_index_scheduler(server: &Server) { "indexes": { "kefir": { "numberOfDocuments": 1, - "rawDocumentDbSize": 109, - "avgDocumentSize": 109, + "rawDocumentDbSize": "[bytes]", + "avgDocumentSize": "[bytes]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0, @@ -245,11 +249,14 @@ async fn check_the_index_scheduler(server: &Server) { "###); let index = server.index("kefir"); let (stats, _) = index.stats().await; - snapshot!(stats, @r###" + snapshot!(json_string!(stats, { + ".rawDocumentDbSize" => "[bytes]", + ".avgDocumentSize" => "[bytes]", + }), @r###" { "numberOfDocuments": 1, - "rawDocumentDbSize": 109, - "avgDocumentSize": 109, + "rawDocumentDbSize": "[bytes]", + "avgDocumentSize": "[bytes]", "isIndexing": false, "numberOfEmbeddings": 0, "numberOfEmbeddedDocuments": 0,