Skip to content

Commit

Permalink
Make the test timeout configurable from an environment variable
Browse files Browse the repository at this point in the history
These can be slower when running the amd64 Docker images on an arm64
host.
  • Loading branch information
shepmaster committed Nov 19, 2023
1 parent 562db32 commit c386146
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ jobs:
- name: Run orchestrator unit tests
env:
TESTS_MAX_CONCURRENCY: 3
TESTS_TIMEOUT_MS: 30000
run: chmod +x ./server/unit_tests_orchestrator && ./server/unit_tests_orchestrator
- name: Run ui unit tests
run: chmod +x ./server/unit_tests_ui && ./server/unit_tests_ui
Expand Down
1 change: 1 addition & 0 deletions ci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ workflows:
- name: "Run orchestrator unit tests"
env:
TESTS_MAX_CONCURRENCY: 3
TESTS_TIMEOUT_MS: 30000
run: |-
chmod +x ./server/unit_tests_orchestrator && ./server/unit_tests_orchestrator
Expand Down
11 changes: 9 additions & 2 deletions compiler/base/orchestrator/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,14 @@ mod tests {
Ok(())
}

static TIMEOUT: Lazy<Duration> = 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(
Expand All @@ -2854,8 +2862,7 @@ mod tests {
tokio::time::Timeout<Self>,
fn(Result<Self::Output, tokio::time::error::Elapsed>) -> 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"))
}
}

Expand Down

0 comments on commit c386146

Please sign in to comment.