Skip to content

Commit 7da2564

Browse files
committed
try this
1 parent 4db2ce4 commit 7da2564

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

opentelemetry-otlp/tests/integration_test/src/test_utils.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,22 @@ fn upsert_empty_file(path: &str) -> File {
128128
/// suite shutting down!
129129
///
130130
pub fn stop_collector_container() {
131-
// This is a bit heinous. We get called after tokio has shutdown, but testcontainers
132-
// needs an async runtime to shutdown, so we create a temporary new one just for this
133-
// purpose.
131+
// This is a bit heinous. We don't have an async runtime left when
132+
// we hit this call, so we can't use the async methods on the testcontainers
133+
// interface to shutdown.
134+
// We _need_ to do this here, because otherwise we have no "all the tests in the module
135+
// were complete" hook.
136+
//
134137
// https://github.com/testcontainers/testcontainers-rs/issues/707
135138
otel_debug!(name: "stop_collector_container");
136-
tokio::runtime::Runtime::new()
137-
.unwrap()
138-
.block_on(stop_it())
139-
.expect("Couldn't create runtime to shutdown");
140-
}
141139

142-
async fn stop_it() -> Result<()> {
143-
if let Some(container) = COLLECTOR_ARC
144-
.get()
145-
.and_then(|arc_lock| arc_lock.lock().unwrap().take())
146-
{
147-
container.stop().await?;
148-
otel_debug!(name: "stop_collector_container::stopped");
140+
if let Some(mutex_option_arc) = COLLECTOR_ARC.get() {
141+
let guard = mutex_option_arc.lock().unwrap();
142+
if let Some(container_arc) = &*guard {
143+
std::process::Command::new("docker")
144+
.args(["container", "rm", "-f", container_arc.id()])
145+
.output()
146+
.expect("failed to stop testcontainer");
147+
}
149148
}
150-
Ok(())
151149
}

0 commit comments

Comments
 (0)