From adcac9042992b908fe62b887f6bdd82c2c29f13f Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sat, 18 Nov 2023 16:36:06 -0500 Subject: [PATCH] Make the test timeout configurable from an environment variable These can be slower when running the amd64 Docker images on an arm64 host. --- compiler/base/orchestrator/src/coordinator.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/base/orchestrator/src/coordinator.rs b/compiler/base/orchestrator/src/coordinator.rs index d3601e381..f9d8cea8b 100644 --- a/compiler/base/orchestrator/src/coordinator.rs +++ b/compiler/base/orchestrator/src/coordinator.rs @@ -2846,6 +2846,14 @@ mod tests { Ok(()) } + static TIMEOUT: Lazy = Lazy::new(|| { + let millis = env::var("TESTS_TIMEOUT_MS") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(5000); + Duration::from_millis(millis) + }); + trait TimeoutExt: Future + Sized { #[allow(clippy::type_complexity)] fn with_timeout( @@ -2854,8 +2862,7 @@ mod tests { tokio::time::Timeout, fn(Result) -> Self::Output, > { - tokio::time::timeout(Duration::from_millis(5000), self) - .map(|v| v.expect("The operation timed out")) + tokio::time::timeout(*TIMEOUT, self).map(|v| v.expect("The operation timed out")) } }