mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-06-18 20:57:35 +02:00
Merge pull request #5603 from martin-g/faster-search-multi-it-tests
tests: Faster search::multi IT tests
This commit is contained in:
commit
aeaac7270e
@ -43,23 +43,28 @@ pub fn default_snapshot_settings_for_test<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.add_dynamic_redaction(".message", uuid_in_message_redaction);
|
fn uuid_in_json_key_redaction(content: Content, _content_path: ContentPath) -> Content {
|
||||||
settings.add_dynamic_redaction(".error.message", uuid_in_message_redaction);
|
match content {
|
||||||
settings.add_dynamic_redaction(".indexUid", |content, _content_path| match &content {
|
Content::Map(map) => {
|
||||||
Content::String(s) => match uuid::Uuid::parse_str(s) {
|
let new_map = map
|
||||||
Ok(_) => Content::String("[uuid]".to_owned()),
|
.iter()
|
||||||
Err(_) => content,
|
.map(|(key, value)| match key {
|
||||||
},
|
|
||||||
_ => content,
|
|
||||||
});
|
|
||||||
|
|
||||||
settings.add_dynamic_redaction(".error.message", |content, _content_path| match &content {
|
|
||||||
Content::String(s) => {
|
Content::String(s) => {
|
||||||
let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "$before[uuid]$after");
|
let uuid_replaced = UUID_IN_MESSAGE_RE.replace_all(s, "[uuid]");
|
||||||
Content::String(uuid_replaced.to_string())
|
(Content::String(uuid_replaced.to_string()), value.clone())
|
||||||
|
}
|
||||||
|
_ => (key.clone(), value.clone()),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Content::Map(new_map)
|
||||||
}
|
}
|
||||||
_ => content,
|
_ => content,
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction);
|
||||||
|
settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction);
|
||||||
|
settings.add_dynamic_redaction(".**.facetsByIndex", uuid_in_json_key_redaction);
|
||||||
|
|
||||||
let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name);
|
let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name);
|
||||||
let test_name = test_name.rsplit("::").next().unwrap().to_owned();
|
let test_name = test_name.rsplit("::").next().unwrap().to_owned();
|
||||||
|
@ -269,7 +269,7 @@ pub async fn shared_index_with_score_documents() -> &'static Index<'static, Shar
|
|||||||
static INDEX: OnceCell<Index<'static, Shared>> = OnceCell::const_new();
|
static INDEX: OnceCell<Index<'static, Shared>> = OnceCell::const_new();
|
||||||
INDEX.get_or_init(|| async {
|
INDEX.get_or_init(|| async {
|
||||||
let server = Server::new_shared();
|
let server = Server::new_shared();
|
||||||
let index = server._index("SCORE_DOCUMENTS").to_shared();
|
let index = server._index("SHARED_SCORE_DOCUMENTS").to_shared();
|
||||||
let documents = SCORE_DOCUMENTS.clone();
|
let documents = SCORE_DOCUMENTS.clone();
|
||||||
let (response, _code) = index._add_documents(documents, None).await;
|
let (response, _code) = index._add_documents(documents, None).await;
|
||||||
index.wait_task(response.uid()).await.succeeded();
|
index.wait_task(response.uid()).await.succeeded();
|
||||||
|
@ -347,6 +347,16 @@ impl<State> Server<State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unique_index_with_prefix(&self, prefix: &str) -> Index<'_> {
|
||||||
|
let uuid = Uuid::new_v4();
|
||||||
|
Index {
|
||||||
|
uid: format!("{prefix}-{}", uuid),
|
||||||
|
service: &self.service,
|
||||||
|
encoder: Encoder::Plain,
|
||||||
|
marker: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unique_index_with_encoder(&self, encoder: Encoder) -> Index<'_> {
|
pub fn unique_index_with_encoder(&self, encoder: Encoder) -> Index<'_> {
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
Index { uid: uuid.to_string(), service: &self.service, encoder, marker: PhantomData }
|
Index { uid: uuid.to_string(), service: &self.service, encoder, marker: PhantomData }
|
||||||
|
@ -46,8 +46,10 @@ async fn create_index_with_gzip_encoded_request_and_receiving_brotli_encoded_res
|
|||||||
let server = Server::new_shared();
|
let server = Server::new_shared();
|
||||||
let app = server.init_web_app().await;
|
let app = server.init_web_app().await;
|
||||||
|
|
||||||
|
let index = server.unique_index_with_prefix("test");
|
||||||
|
|
||||||
let body = serde_json::to_string(&json!({
|
let body = serde_json::to_string(&json!({
|
||||||
"uid": "test",
|
"uid": index.uid.clone(),
|
||||||
"primaryKey": None::<&str>,
|
"primaryKey": None::<&str>,
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -68,7 +70,7 @@ async fn create_index_with_gzip_encoded_request_and_receiving_brotli_encoded_res
|
|||||||
let parsed_response =
|
let parsed_response =
|
||||||
serde_json::from_slice::<Value>(decoded.into().as_ref()).expect("Expecting valid json");
|
serde_json::from_slice::<Value>(decoded.into().as_ref()).expect("Expecting valid json");
|
||||||
|
|
||||||
assert_eq!(parsed_response["indexUid"], "test");
|
assert_eq!(parsed_response["indexUid"], index.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user