Skip to content

Commit

Permalink
test: make integration tests shut up (#771)
Browse files Browse the repository at this point in the history
PR #766 changed the proxy tests to set a much more verbose default log
filter, relying on libtest's output capturing to prevent the tests from
spamming stdout when they don't fail. However, the integration tests run
the proxy in a separate thread, and libtest can't currently capture
output from spawned threads. This results in a bunch of unnecessary
noise when running the integration tests.

This branch changes the integration tests so that the spawned proxy
thread uses the old filter settings instead. We still get more detailed
output from stack tests, and from the main test threads in the
integration tests. I removed some code that would set the value of the
log level env vars, since that made this impossible — I'm not really
sure why that code was ever necessary in the first place.

Also, I fixed a compiler error in `linkerd2-app-test` due to a missing
Cargo feature.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Dec 15, 2020
1 parent cf9900d commit d2a25ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 9 additions & 1 deletion linkerd/app/integration/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions linkerd/app/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

0 comments on commit d2a25ce

Please sign in to comment.