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

Call setup_tracing_subscriber_for_test from shotover_process as well. #1489

Merged
merged 4 commits into from
Feb 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions test-helpers/src/docker_compose.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
use docker_compose_runner::*;
use std::{env, time::Duration};
use tracing_subscriber::fmt::TestWriter;

pub use docker_compose_runner::DockerCompose;

fn setup_tracing_subscriber_for_test_logic() {
tracing_subscriber::fmt()
.with_writer(TestWriter::new())
.with_env_filter("warn")
.try_init()
.ok();
}

pub fn docker_compose(file_path: &str) -> DockerCompose {
setup_tracing_subscriber_for_test_logic();
// Run setup here to ensure any test that calls this gets tracing
crate::test_tracing::setup_tracing_subscriber_for_test();

DockerCompose::new(&IMAGE_WAITERS, |_| {}, file_path)
}

Expand Down
1 change: 1 addition & 0 deletions test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod docker_compose;
pub mod metrics;
pub mod mock_cassandra;
pub mod shotover_process;
mod test_tracing;

use anyhow::{anyhow, Result};
use subprocess::{Exec, Redirection};
Expand Down
3 changes: 3 additions & 0 deletions test-helpers/src/shotover_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub struct ShotoverProcessBuilder {

impl ShotoverProcessBuilder {
pub fn new_with_topology(topology_path: &str) -> Self {
// Run setup here to ensure any test that calls this gets tracing
crate::test_tracing::setup_tracing_subscriber_for_test();

Self {
topology_path: topology_path.to_owned(),
config_path: None,
Expand Down
14 changes: 14 additions & 0 deletions test-helpers/src/test_tracing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use tracing::level_filters::LevelFilter;
use tracing_subscriber::EnvFilter;

pub fn setup_tracing_subscriber_for_test() {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env()
.unwrap(),
)
.try_init()
.ok();
}
Loading