diff --git a/Cargo.lock b/Cargo.lock index 2753ca8d09..893876725c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1012,6 +1012,7 @@ dependencies = [ "hyper", "linkerd2-app-core", "linkerd2-identity", + "linkerd2-io", "regex 0.1.80", "tokio 0.3.5", "tokio-test 0.3.0", diff --git a/linkerd/app/integration/src/proxy.rs b/linkerd/app/integration/src/proxy.rs index f340418a90..03accaf2d0 100644 --- a/linkerd/app/integration/src/proxy.rs +++ b/linkerd/app/integration/src/proxy.rs @@ -198,6 +198,14 @@ impl Listening { } async fn run(proxy: Proxy, mut env: TestEnv, random_ports: bool) -> Listening { + // Logs from spawned threads will not be captured, so use a filter that + // disables most of the proxy's logs by default. + // TODO(eliza): when we're on Rust 1.49.0+, libtest *will* capture these + // logs, so we can use the same default filter as other test code. + const DEFAULT_LOG: &'static str = "error,\ + linkerd2_proxy_http=off,\ + linkerd2_proxy_transport=off"; + use app::env::Strings; let controller = if let Some(controller) = proxy.controller { @@ -291,7 +299,7 @@ async fn run(proxy: Proxy, mut env: TestEnv, random_ports: bool) -> Listening { } let config = app::env::parse_config(&env).unwrap(); - let (trace, trace_handle) = super::trace_subscriber(); + let (trace, trace_handle) = super::trace_subscriber(DEFAULT_LOG); let (running_tx, running_rx) = oneshot::channel(); let (term_tx, term_rx) = oneshot::channel(); diff --git a/linkerd/app/test/Cargo.toml b/linkerd/app/test/Cargo.toml index 10a34493b0..37334d7777 100644 --- a/linkerd/app/test/Cargo.toml +++ b/linkerd/app/test/Cargo.toml @@ -25,6 +25,7 @@ http-body = "0.4" hyper = "0.14.0-dev" linkerd2-app-core = { path = "../core", features = ["mock-orig-dst"] } linkerd2-identity = { path = "../../identity" } +linkerd2-io = { path = "../../io", features = ["tokio-test"] } regex = "0.1" tokio = { version = "0.3", features = ["io-util", "net", "rt", "sync"]} tokio-test = "0.3" diff --git a/linkerd/app/test/src/lib.rs b/linkerd/app/test/src/lib.rs index 4dbe855dad..b68b330ea3 100644 --- a/linkerd/app/test/src/lib.rs +++ b/linkerd/app/test/src/lib.rs @@ -54,13 +54,11 @@ const DEFAULT_LOG: &'static str = "warn,\ linkerd2_proxy_http=error,\ linkerd2_proxy_transport=error"; -pub fn trace_subscriber() -> (Dispatch, app_core::trace::Handle) { +pub fn trace_subscriber(default_filter: &str) -> (Dispatch, app_core::trace::Handle) { use std::env; let log_level = env::var("LINKERD2_PROXY_LOG") .or_else(|_| env::var("RUST_LOG")) - .unwrap_or_else(|_| DEFAULT_LOG.to_owned()); - env::set_var("RUST_LOG", &log_level); - env::set_var("LINKERD2_PROXY_LOG", &log_level); + .unwrap_or_else(|_| default_filter.to_owned()); let log_format = env::var("LINKERD2_PROXY_LOG_FORMAT").unwrap_or_else(|_| "PLAIN".to_string()); env::set_var("LINKERD2_PROXY_LOG_FORMAT", &log_format); // This may fail, since the global log compat layer may have been @@ -74,6 +72,6 @@ pub fn trace_subscriber() -> (Dispatch, app_core::trace::Handle) { } pub fn trace_init() -> tracing::dispatcher::DefaultGuard { - let (d, _) = trace_subscriber(); + let (d, _) = trace_subscriber(DEFAULT_LOG); tracing::dispatcher::set_default(&d) }