From 77254765e834ad6f536c5ef474f700458bc3278a Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 31 Jan 2024 17:46:36 +0100 Subject: [PATCH] get rids of env loggegr and fix the tests --- Cargo.lock | 1 - meilisearch/Cargo.toml | 1 - meilisearch/tests/common/server.rs | 8 ++++++++ meilisearch/tests/common/service.rs | 8 ++++++++ meilisearch/tests/tasks/webhook.rs | 4 ---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 866912cc8..1f15047cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3620,7 +3620,6 @@ dependencies = [ "deserr", "dump", "either", - "env_logger", "file-store", "flate2", "fst", diff --git a/meilisearch/Cargo.toml b/meilisearch/Cargo.toml index 8ed35d542..21136b6e8 100644 --- a/meilisearch/Cargo.toml +++ b/meilisearch/Cargo.toml @@ -42,7 +42,6 @@ crossbeam-channel = "0.5.11" deserr = { version = "0.6.1", features = ["actix-web"] } dump = { path = "../dump" } either = "1.9.0" -env_logger = "0.10.1" file-store = { path = "../file-store" } flate2 = "1.0.28" fst = "0.4.7" diff --git a/meilisearch/tests/common/server.rs b/meilisearch/tests/common/server.rs index 27feb187f..134124cc8 100644 --- a/meilisearch/tests/common/server.rs +++ b/meilisearch/tests/common/server.rs @@ -13,6 +13,8 @@ use meilisearch::{analytics, create_app, setup_meilisearch}; use once_cell::sync::Lazy; use tempfile::TempDir; use tokio::time::sleep; +use tracing::level_filters::LevelFilter; +use tracing_subscriber::Layer; use super::index::Index; use super::service::Service; @@ -81,10 +83,16 @@ impl Server { Response = ServiceResponse, Error = actix_web::Error, > { + let (_route_layer, route_layer_handle) = + tracing_subscriber::reload::Layer::new(None.with_filter( + tracing_subscriber::filter::Targets::new().with_target("", LevelFilter::OFF), + )); + actix_web::test::init_service(create_app( self.service.index_scheduler.clone().into(), self.service.auth.clone().into(), self.service.options.clone(), + route_layer_handle, analytics::MockAnalytics::new(&self.service.options), true, )) diff --git a/meilisearch/tests/common/service.rs b/meilisearch/tests/common/service.rs index 078ddb6e5..4c23a18d8 100644 --- a/meilisearch/tests/common/service.rs +++ b/meilisearch/tests/common/service.rs @@ -7,6 +7,8 @@ use actix_web::test::TestRequest; use index_scheduler::IndexScheduler; use meilisearch::{analytics, create_app, Opt}; use meilisearch_auth::AuthController; +use tracing::level_filters::LevelFilter; +use tracing_subscriber::Layer; use crate::common::encoder::Encoder; use crate::common::Value; @@ -105,10 +107,16 @@ impl Service { } pub async fn request(&self, mut req: test::TestRequest) -> (Value, StatusCode) { + let (_route_layer, route_layer_handle) = + tracing_subscriber::reload::Layer::new(None.with_filter( + tracing_subscriber::filter::Targets::new().with_target("", LevelFilter::OFF), + )); + let app = test::init_service(create_app( self.index_scheduler.clone().into(), self.auth.clone().into(), self.options.clone(), + route_layer_handle, analytics::MockAnalytics::new(&self.options), true, )) diff --git a/meilisearch/tests/tasks/webhook.rs b/meilisearch/tests/tasks/webhook.rs index 6979ff294..a18a93edb 100644 --- a/meilisearch/tests/tasks/webhook.rs +++ b/meilisearch/tests/tasks/webhook.rs @@ -44,10 +44,6 @@ struct WebhookHandle { } async fn create_webhook_server() -> WebhookHandle { - let mut log_builder = env_logger::Builder::new(); - log_builder.parse_filters("info"); - log_builder.init(); - let (sender, receiver) = mpsc::unbounded_channel(); let sender = Arc::new(sender);