Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make integration tests shut up #771

Merged
merged 1 commit into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}