Skip to content

Commit f745aa4

Browse files
authored
test(supervisor-network): isolate metadata OCSF capture (#4318)
Signed-off-by: Gordon Sim <gsim@redhat.com>
1 parent fe3942f commit f745aa4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎crates/openshell-supervisor-network/src/google_cloud_metadata.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,29 @@ mod tests {
402402
};
403403
use tracing_subscriber::prelude::*;
404404

405+
const CHILD: &str = "OPENSHELL_TEST_GCP_METADATA_OCSF_CHILD";
406+
// Tracing callsite interest is process-wide, so concurrent tests with
407+
// other subscribers can disable this thread's capture. Run the capture
408+
// in an isolated process while keeping the same test executable.
409+
if std::env::var_os(CHILD).is_none() {
410+
let output = std::process::Command::new(std::env::current_exe().unwrap())
411+
.args([
412+
"--exact",
413+
"google_cloud_metadata::tests::metadata_events_include_response_for_ocsf18",
414+
"--nocapture",
415+
])
416+
.env(CHILD, "1")
417+
.output()
418+
.unwrap();
419+
let stdout = String::from_utf8_lossy(&output.stdout);
420+
assert!(
421+
output.status.success() && stdout.contains("1 passed"),
422+
"{stdout}\n{}",
423+
String::from_utf8_lossy(&output.stderr)
424+
);
425+
return;
426+
}
427+
405428
let schema = load_class_schema("http_activity");
406429
for (method, path, headers, expected_code, expected_activity_id) in [
407430
("GET", PATH_TOKEN, flavor_headers(), 200, 3),

0 commit comments

Comments
 (0)