Skip to content

Commit d2a25ce

Browse files
authored
test: make integration tests shut up (#771)
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 <[email protected]>
1 parent cf9900d commit d2a25ce

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ dependencies = [
10121012
"hyper",
10131013
"linkerd2-app-core",
10141014
"linkerd2-identity",
1015+
"linkerd2-io",
10151016
"regex 0.1.80",
10161017
"tokio 0.3.5",
10171018
"tokio-test 0.3.0",

linkerd/app/integration/src/proxy.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ impl Listening {
198198
}
199199

200200
async fn run(proxy: Proxy, mut env: TestEnv, random_ports: bool) -> Listening {
201+
// Logs from spawned threads will not be captured, so use a filter that
202+
// disables most of the proxy's logs by default.
203+
// TODO(eliza): when we're on Rust 1.49.0+, libtest *will* capture these
204+
// logs, so we can use the same default filter as other test code.
205+
const DEFAULT_LOG: &'static str = "error,\
206+
linkerd2_proxy_http=off,\
207+
linkerd2_proxy_transport=off";
208+
201209
use app::env::Strings;
202210

203211
let controller = if let Some(controller) = proxy.controller {
@@ -291,7 +299,7 @@ async fn run(proxy: Proxy, mut env: TestEnv, random_ports: bool) -> Listening {
291299
}
292300

293301
let config = app::env::parse_config(&env).unwrap();
294-
let (trace, trace_handle) = super::trace_subscriber();
302+
let (trace, trace_handle) = super::trace_subscriber(DEFAULT_LOG);
295303

296304
let (running_tx, running_rx) = oneshot::channel();
297305
let (term_tx, term_rx) = oneshot::channel();

linkerd/app/test/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ http-body = "0.4"
2525
hyper = "0.14.0-dev"
2626
linkerd2-app-core = { path = "../core", features = ["mock-orig-dst"] }
2727
linkerd2-identity = { path = "../../identity" }
28+
linkerd2-io = { path = "../../io", features = ["tokio-test"] }
2829
regex = "0.1"
2930
tokio = { version = "0.3", features = ["io-util", "net", "rt", "sync"]}
3031
tokio-test = "0.3"

linkerd/app/test/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ const DEFAULT_LOG: &'static str = "warn,\
5454
linkerd2_proxy_http=error,\
5555
linkerd2_proxy_transport=error";
5656

57-
pub fn trace_subscriber() -> (Dispatch, app_core::trace::Handle) {
57+
pub fn trace_subscriber(default_filter: &str) -> (Dispatch, app_core::trace::Handle) {
5858
use std::env;
5959
let log_level = env::var("LINKERD2_PROXY_LOG")
6060
.or_else(|_| env::var("RUST_LOG"))
61-
.unwrap_or_else(|_| DEFAULT_LOG.to_owned());
62-
env::set_var("RUST_LOG", &log_level);
63-
env::set_var("LINKERD2_PROXY_LOG", &log_level);
61+
.unwrap_or_else(|_| default_filter.to_owned());
6462
let log_format = env::var("LINKERD2_PROXY_LOG_FORMAT").unwrap_or_else(|_| "PLAIN".to_string());
6563
env::set_var("LINKERD2_PROXY_LOG_FORMAT", &log_format);
6664
// 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) {
7472
}
7573

7674
pub fn trace_init() -> tracing::dispatcher::DefaultGuard {
77-
let (d, _) = trace_subscriber();
75+
let (d, _) = trace_subscriber(DEFAULT_LOG);
7876
tracing::dispatcher::set_default(&d)
7977
}

0 commit comments

Comments
 (0)