Skip to content

Commit

Permalink
Call setup_tracing_subscriber_for_test from shotover_process as well. (
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Feb 21, 2024
1 parent 1e3b1d2 commit 891e5b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
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();
}

0 comments on commit 891e5b2

Please sign in to comment.