From b7e8821a237cdf08156f16a779e3f7f7bc431453 Mon Sep 17 00:00:00 2001 From: andrussal Date: Tue, 16 Dec 2025 03:28:23 +0100 Subject: [PATCH] refactor(compose-runner): name timeouts for compose port/restart --- testing-framework/runners/compose/src/docker/control.rs | 9 +++++++-- .../runners/compose/src/infrastructure/environment.rs | 3 ++- .../runners/compose/src/infrastructure/ports.rs | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/testing-framework/runners/compose/src/docker/control.rs b/testing-framework/runners/compose/src/docker/control.rs index cf37a32..9191a38 100644 --- a/testing-framework/runners/compose/src/docker/control.rs +++ b/testing-framework/runners/compose/src/docker/control.rs @@ -1,4 +1,7 @@ -use std::path::{Path, PathBuf}; +use std::{ + path::{Path, PathBuf}, + time::Duration, +}; use testing_framework_core::scenario::{DynError, NodeControlHandle}; use tokio::process::Command; @@ -6,6 +9,8 @@ use tracing::info; use crate::{docker::commands::run_docker_command, errors::ComposeRunnerError}; +const COMPOSE_RESTART_TIMEOUT: Duration = Duration::from_secs(120); + pub async fn restart_compose_service( compose_file: &Path, project_name: &str, @@ -25,7 +30,7 @@ pub async fn restart_compose_service( info!(service, project = project_name, compose_file = %compose_file.display(), "restarting compose service"); run_docker_command( command, - testing_framework_core::adjust_timeout(std::time::Duration::from_secs(120)), + testing_framework_core::adjust_timeout(COMPOSE_RESTART_TIMEOUT), description, ) .await diff --git a/testing-framework/runners/compose/src/infrastructure/environment.rs b/testing-framework/runners/compose/src/infrastructure/environment.rs index 2310107..2a6a894 100644 --- a/testing-framework/runners/compose/src/infrastructure/environment.rs +++ b/testing-framework/runners/compose/src/infrastructure/environment.rs @@ -31,6 +31,7 @@ use crate::{ }; const CFGSYNC_START_TIMEOUT: Duration = Duration::from_secs(180); +const COMPOSE_PORT_DISCOVERY_TIMEOUT: Duration = Duration::from_secs(30); const STACK_BRINGUP_MAX_ATTEMPTS: usize = 3; /// Paths and flags describing the prepared compose workspace. @@ -531,7 +532,7 @@ async fn resolve_service_port( .arg(container_port.to_string()) .current_dir(root); - let output = timeout(adjust_timeout(Duration::from_secs(30)), cmd.output()) + let output = timeout(adjust_timeout(COMPOSE_PORT_DISCOVERY_TIMEOUT), cmd.output()) .await .map_err(|_| ComposeRunnerError::PortDiscovery { service: service.to_owned(), diff --git a/testing-framework/runners/compose/src/infrastructure/ports.rs b/testing-framework/runners/compose/src/infrastructure/ports.rs index 8a26566..1d3e4b8 100644 --- a/testing-framework/runners/compose/src/infrastructure/ports.rs +++ b/testing-framework/runners/compose/src/infrastructure/ports.rs @@ -16,6 +16,8 @@ use crate::{ infrastructure::environment::StackEnvironment, }; +const COMPOSE_PORT_DISCOVERY_TIMEOUT: Duration = Duration::from_secs(30); + /// Host ports mapped for a single node. #[derive(Clone, Debug)] pub struct NodeHostPorts { @@ -100,7 +102,7 @@ async fn resolve_service_port( .arg(container_port.to_string()) .current_dir(environment.root()); - let output = timeout(adjust_timeout(Duration::from_secs(30)), cmd.output()) + let output = timeout(adjust_timeout(COMPOSE_PORT_DISCOVERY_TIMEOUT), cmd.output()) .await .map_err(|_| ComposeRunnerError::PortDiscovery { service: service.to_owned(),