From bc3b2fd210864bf164c629bae6e1a583c1390d70 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Fri, 16 Aug 2024 11:00:21 +0200 Subject: [PATCH] Improve --- .../services/buffer/envelope_buffer/mod.rs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/relay-server/src/services/buffer/envelope_buffer/mod.rs b/relay-server/src/services/buffer/envelope_buffer/mod.rs index d0513a7609..4bbeb880c0 100644 --- a/relay-server/src/services/buffer/envelope_buffer/mod.rs +++ b/relay-server/src/services/buffer/envelope_buffer/mod.rs @@ -563,9 +563,21 @@ mod tests { envelope } + fn mock_config() -> Config { + Config::from_json_value(serde_json::json!({ + "spool": { + "envelopes": { + "version": "experimental", + "max_evictable_stacks": 3 + } + } + })) + .unwrap() + } + #[tokio::test] async fn test_insert_pop() { - let mut buffer = EnvelopeBuffer::::new(10); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); let project_key1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap(); let project_key2 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fee").unwrap(); @@ -649,7 +661,7 @@ mod tests { #[tokio::test] async fn test_project_internal_order() { - let mut buffer = EnvelopeBuffer::::new(10); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); let project_key = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap(); @@ -676,7 +688,7 @@ mod tests { #[tokio::test] async fn test_sampling_projects() { - let mut buffer = EnvelopeBuffer::::new(10); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); let project_key1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap(); let project_key2 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fef").unwrap(); @@ -754,7 +766,7 @@ mod tests { assert_ne!(stack_key1, stack_key2); - let mut buffer = EnvelopeBuffer::::new(10); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); buffer .push(new_envelope(project_key1, Some(project_key2), None)) .await @@ -768,7 +780,7 @@ mod tests { #[tokio::test] async fn test_last_peek_internal_order() { - let mut buffer = EnvelopeBuffer::::new(10); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); let project_key_1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap(); let event_id_1 = EventId::new(); @@ -798,7 +810,7 @@ mod tests { #[tokio::test] async fn test_eviction() { - let mut buffer = EnvelopeBuffer::::new(3); + let mut buffer = EnvelopeBuffer::::new(&mock_config()); let project_key_1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap(); let project_key_2 = ProjectKey::parse("b56ae32be2584e0bbd7a4cbb95971fed").unwrap();