diff --git a/crates/dump/src/lib.rs b/crates/dump/src/lib.rs index 0fb5570b0..ad2d96e1c 100644 --- a/crates/dump/src/lib.rs +++ b/crates/dump/src/lib.rs @@ -229,7 +229,7 @@ pub(crate) mod test { use big_s::S; use maplit::{btreemap, btreeset}; use meilisearch_types::facet_values_sort::FacetValuesSort; - use meilisearch_types::features::RuntimeTogglableFeatures; + use meilisearch_types::features::{Network, Remote, RuntimeTogglableFeatures}; use meilisearch_types::index_uid_pattern::IndexUidPattern; use meilisearch_types::keys::{Action, Key}; use meilisearch_types::milli; @@ -455,6 +455,10 @@ pub(crate) mod test { dump.create_experimental_features(features).unwrap(); + // ========== network + let network = create_test_network(); + dump.create_network(network).unwrap(); + // create the dump let mut file = tempfile::tempfile().unwrap(); dump.persist_to(&mut file).unwrap(); @@ -467,6 +471,13 @@ pub(crate) mod test { RuntimeTogglableFeatures::default() } + fn create_test_network() -> Network { + Network { + local: Some("myself".to_string()), + remotes: maplit::btreemap! {"other".to_string() => Remote { url: "http://test".to_string(), search_api_key: Some("apiKey".to_string()) }}, + } + } + #[test] fn test_creating_and_read_dump() { let mut file = create_test_dump(); @@ -515,5 +526,9 @@ pub(crate) mod test { // ==== checking the features let expected = create_test_features(); assert_eq!(dump.features().unwrap().unwrap(), expected); + + // ==== checking the network + let expected = create_test_network(); + assert_eq!(&expected, dump.network().unwrap().unwrap()); } } diff --git a/crates/dump/src/reader/mod.rs b/crates/dump/src/reader/mod.rs index 50180fbc7..ec74fa4fd 100644 --- a/crates/dump/src/reader/mod.rs +++ b/crates/dump/src/reader/mod.rs @@ -23,6 +23,7 @@ mod v6; pub type Document = serde_json::Map; pub type UpdateFile = dyn Iterator>; +#[allow(clippy::large_enum_variant)] pub enum DumpReader { Current(V6Reader), Compat(CompatV5ToV6), @@ -335,6 +336,7 @@ pub(crate) mod test { } assert_eq!(dump.features().unwrap().unwrap(), RuntimeTogglableFeatures::default()); + assert_eq!(dump.network().unwrap(), None); } #[test] @@ -380,6 +382,27 @@ pub(crate) mod test { assert_eq!(dump.features().unwrap().unwrap(), RuntimeTogglableFeatures::default()); } + #[test] + fn import_dump_v6_network() { + let dump = File::open("tests/assets/v6-with-network.dump").unwrap(); + let dump = DumpReader::open(dump).unwrap(); + + // top level infos + insta::assert_snapshot!(dump.date().unwrap(), @"2025-01-29 15:45:32.738676 +00:00:00"); + insta::assert_debug_snapshot!(dump.instance_uid().unwrap(), @"None"); + + // network + + let network = dump.network().unwrap().unwrap(); + insta::assert_snapshot!(network.local.as_ref().unwrap(), @"ms-0"); + insta::assert_snapshot!(network.remotes.get("ms-0").as_ref().unwrap().url, @"http://localhost:7700"); + insta::assert_snapshot!(network.remotes.get("ms-0").as_ref().unwrap().search_api_key.is_none(), @"true"); + insta::assert_snapshot!(network.remotes.get("ms-1").as_ref().unwrap().url, @"http://localhost:7701"); + insta::assert_snapshot!(network.remotes.get("ms-1").as_ref().unwrap().search_api_key.is_none(), @"true"); + insta::assert_snapshot!(network.remotes.get("ms-2").as_ref().unwrap().url, @"http://ms-5679.example.meilisearch.io"); + insta::assert_snapshot!(network.remotes.get("ms-2").as_ref().unwrap().search_api_key.as_ref().unwrap(), @"foo"); + } + #[test] fn import_dump_v5() { let dump = File::open("tests/assets/v5.dump").unwrap(); diff --git a/crates/dump/src/writer.rs b/crates/dump/src/writer.rs index 880441445..923147c63 100644 --- a/crates/dump/src/writer.rs +++ b/crates/dump/src/writer.rs @@ -299,7 +299,8 @@ pub(crate) mod test { ├---- experimental-features.json ├---- instance_uid.uuid ├---- keys.jsonl - └---- metadata.json + ├---- metadata.json + └---- network.json "###); // ==== checking the top level infos diff --git a/crates/index-scheduler/src/queue/test.rs b/crates/index-scheduler/src/queue/test.rs index eb3314496..3dbdd2db3 100644 --- a/crates/index-scheduler/src/queue/test.rs +++ b/crates/index-scheduler/src/queue/test.rs @@ -326,7 +326,7 @@ fn test_auto_deletion_of_tasks() { fn test_task_queue_is_full() { let (index_scheduler, mut handle) = IndexScheduler::test_with_custom_config(vec![], |config| { // that's the minimum map size possible - config.task_db_size = 1048576; + config.task_db_size = 1048576 * 3; None }); diff --git a/crates/meilisearch/tests/dumps/mod.rs b/crates/meilisearch/tests/dumps/mod.rs index a2b008fe3..21e2eaf28 100644 --- a/crates/meilisearch/tests/dumps/mod.rs +++ b/crates/meilisearch/tests/dumps/mod.rs @@ -1908,7 +1908,8 @@ async fn import_dump_v6_containing_experimental_features() { "metrics": false, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -2069,7 +2070,8 @@ async fn generate_and_import_dump_containing_vectors() { "metrics": false, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); diff --git a/crates/meilisearch/tests/features/mod.rs b/crates/meilisearch/tests/features/mod.rs index 8e1ac921d..f6433eaf3 100644 --- a/crates/meilisearch/tests/features/mod.rs +++ b/crates/meilisearch/tests/features/mod.rs @@ -21,7 +21,8 @@ async fn experimental_features() { "metrics": false, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -33,7 +34,8 @@ async fn experimental_features() { "metrics": true, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -45,7 +47,8 @@ async fn experimental_features() { "metrics": true, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -58,7 +61,8 @@ async fn experimental_features() { "metrics": true, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -71,7 +75,8 @@ async fn experimental_features() { "metrics": true, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); } @@ -91,7 +96,8 @@ async fn experimental_feature_metrics() { "metrics": true, "logsRoute": false, "editDocumentsByFunction": false, - "containsFilter": false + "containsFilter": false, + "proxySearch": false } "###); @@ -146,7 +152,7 @@ async fn errors() { meili_snap::snapshot!(code, @"400 Bad Request"); meili_snap::snapshot!(meili_snap::json_string!(response), @r###" { - "message": "Unknown field `NotAFeature`: expected one of `metrics`, `logsRoute`, `editDocumentsByFunction`, `containsFilter`", + "message": "Unknown field `NotAFeature`: expected one of `metrics`, `logsRoute`, `editDocumentsByFunction`, `containsFilter`, `proxySearch`", "code": "bad_request", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#bad_request"