From 03ffabe889c84762e2ff9194093fb85addce687c Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 6 Dec 2023 14:52:51 +0100 Subject: [PATCH] Add a new dump test --- ..._use_deactivated_experimental_setting.dump | Bin 0 -> 1522 bytes meilisearch/tests/dumps/data.rs | 6 + meilisearch/tests/dumps/mod.rs | 105 ++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump diff --git a/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump b/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump new file mode 100644 index 0000000000000000000000000000000000000000..4f50733fd179e3b36e5a36fb822783deaaa9209f GIT binary patch literal 1522 zcmVY!mkw^Si{|%th|HVvx z5$9S4PtZTX4sP||05)R5g(;edd}`nSQZ^x*P4it|j&Sho0s zFQ62vx^|Rtrg(g*pn$+;-NU4Zyc_HcC>{{hM=r+H`2>>1JpR5U_4*;`*d?Fr`%a6W z1Y7o>bEQQ3Id9VbG1~q9Q{SPj{WpN69gBRPu!S~Tm5FhoU>g|xWxulj?%FwLSu|zi zgzu@Gh(z&hr&2eQnc7#LvGf*J*ZU$VyZI`!SnoM%F_&iRk#}My)WSSk$@!nA-ZV{R zI^=VfF(tDbdCSxKQTqyG5h)>4*v2ZM1vFpGpmuq$YjarRk$M=NJxGfrS$qC<#v_qK z53rB1T51@vgja*TkqNwc8bQ;g%~SoZu!*Xy;9YwrQa$dW_{QJBus~Wr*On>Q_x8Yr zF22gDJS@kfJ9w9_z3xNV<`jbTghgDNsP1#d?mn`l;Q2Mr-sp1hjLF9ITk{SOxM2;6{v0e?ED$07d@ zLEZNG-}U`=|8D?{#POJM+GCVQJsOdq7dVvkJmgJy40>?9XY(#CejNO6&cWjc%7-Pr z2{`&i#!u`09drJ}JN_S~UTgmiU}@)(%=i_Y`$YoZ{s~KRaALmj2z;s`{PKq~;07`g ztz=;7fS++)OeP|I&-MMPZl5b?==fYVCpDi4;f3jo$*vGiF{{{f(zhXB3$g}FW z^U;GNPCQ-};J({Ox(vjwm_96RQ#)jULCB$@i(6{vx#5;CP8#dkheP}ic6Q=_n0T%I zHvzDJo=2IOmsEiLA?KD*mXcP<{aBMs&dRV%CR4>z%?PJ#ruTs>K4C?otYIm6dHvSX zv~jnhlqaDR1c4XzCQ(Rx6gj9j=GgCXH>PojNDz5?V_}A?F?>+@NX`CKwB!TV1ipp< z$8^M0P1aPbv?teP!o3Bnckq93>kw&zQ-aQv6mfxN?`{!x-KMr=={Er4;^nXzr_6QjL zbL0R$CI83w+Wem;Q0o8Rf*1U3Zr}m`kD}f4A8}j%uMt%7e^hx2A2yQ#U~W_a&V!v7 zQN(%7<1zqd;$C&Ec>DgCFd9UlL_Ugn!qti!0`DbB+`ZGB+quW&y z4e)GJsrv+`G=b3URh?+5sg?SE6v-l0WuDxzTBtj^jANmN-eoI&!0PAX3pnf#PcVI# zXM)Yr!#dFUJCuNbe^3XdWEg~pbzqW$JmdsxI&ju?P@Yj9pMPMcUO!CH($@~ literal 0 HcmV?d00001 diff --git a/meilisearch/tests/dumps/data.rs b/meilisearch/tests/dumps/data.rs index 5df09bfd1..d353aaf1d 100644 --- a/meilisearch/tests/dumps/data.rs +++ b/meilisearch/tests/dumps/data.rs @@ -20,6 +20,8 @@ pub enum GetDump { RubyGemsWithSettingsV4, TestV5, + + TestV6WithExperimental, } impl GetDump { @@ -68,6 +70,10 @@ impl GetDump { GetDump::TestV5 => { exist_relative_path!("tests/assets/v5_v0.28.0_test_dump.dump").into() } + GetDump::TestV6WithExperimental => exist_relative_path!( + "tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump" + ) + .into(), } } } diff --git a/meilisearch/tests/dumps/mod.rs b/meilisearch/tests/dumps/mod.rs index e60893d4e..c69623e9e 100644 --- a/meilisearch/tests/dumps/mod.rs +++ b/meilisearch/tests/dumps/mod.rs @@ -1810,3 +1810,108 @@ async fn import_dump_v5() { json_string!(tasks, { ".results[].details.dumpUid" => "[uid]", ".results[].duration" => "[duration]" , ".results[].startedAt" => "[date]" , ".results[].finishedAt" => "[date]" }) ); } + +#[actix_rt::test] +async fn import_dump_v6_containing_experimental_features() { + let temp = tempfile::tempdir().unwrap(); + + let options = Opt { + import_dump: Some(GetDump::TestV6WithExperimental.path()), + ..default_settings(temp.path()) + }; + let mut server = Server::new_auth_with_options(options, temp).await; + server.use_api_key("MASTER_KEY"); + + 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!("movies")); + 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###" + { + "scoreDetails": false, + "vectorStore": false, + "metrics": false, + "exportPuffinReports": false, + "proximityPrecision": false + } + "###); + + let index = server.index("movies"); + + let (response, code) = index.settings().await; + meili_snap::snapshot!(code, @"200 OK"); + meili_snap::snapshot!(meili_snap::json_string!(response), @r###" + { + "displayedAttributes": [ + "*" + ], + "searchableAttributes": [ + "*" + ], + "filterableAttributes": [], + "sortableAttributes": [], + "rankingRules": [ + "words", + "typo", + "proximity" + ], + "stopWords": [], + "nonSeparatorTokens": [], + "separatorTokens": [], + "dictionary": [], + "synonyms": {}, + "distinctAttribute": null, + "proximityPrecision": "attributeScale", + "typoTolerance": { + "enabled": true, + "minWordSizeForTypos": { + "oneTypo": 5, + "twoTypos": 9 + }, + "disableOnWords": [], + "disableOnAttributes": [] + }, + "faceting": { + "maxValuesPerFacet": 100, + "sortFacetValuesBy": { + "*": "alpha" + } + }, + "pagination": { + "maxTotalHits": 1000 + } + } + "###); + + // the expected order is [1, 3, 2] instead of [3, 1, 2] + // because the attribute scale doesn't make the difference between 1 and 3. + index + .search(json!({"q": "the soup of day"}), |response, code| { + snapshot!(code, @"200 OK"); + snapshot!(json_string!(response["hits"]), @r###" + [ + { + "id": 1, + "a": "Soup of the day", + "b": "many the fish" + }, + { + "id": 3, + "a": "the Soup of day", + "b": "many the fish" + }, + { + "id": 2, + "a": "Soup of day", + "b": "many the lazy fish" + } + ] + "###); + }) + .await; +}