Skip to content

Commit

Permalink
Fixes #1092: Configure timeout for reading from docker logs when drop…
Browse files Browse the repository at this point in the history
…ping LogPrinter (#1093)
  • Loading branch information
jiridanek authored Jun 5, 2023
1 parent 9f269fd commit 6055594
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/testcontainers/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ use futures::stream::{Fuse};
use futures::{select, Stream, stream};
use tokio::task::JoinHandle;

// how long to wait to print remaining container logs
const DRAIN_LOGS_TIMEOUT: Duration = Duration::from_secs(5);

// https://hub.docker.com/r/summerwind/h2spec
pub(crate) const H2SPEC_IMAGE: &str = "summerwind/h2spec:2.6.0"; // do not prefix with `docker.io/`, docker won't find it
// https://nixery.dev/
Expand All @@ -46,7 +49,9 @@ pub(crate) struct LogPrinter {
impl Drop for LogPrinter {
fn drop(&mut self) {
for task in self.tasks.drain(..).rev() {
let result = futures::executor::block_on(task);
println!("Finalizing LogPrinter");
let result = futures::executor::block_on(
tokio::time::timeout(DRAIN_LOGS_TIMEOUT, task));
println!("Finalized LogPrinter {:?}", result);
}
}
Expand Down

0 comments on commit 6055594

Please sign in to comment.