65 lines
1.8 KiB
Rust
Raw Normal View History

2026-02-02 07:19:22 +01:00
use testing_framework_core::{scenario::ObservabilityInputs, topology::DeploymentDescriptor};
use tracing::info;
2025-12-10 10:11:45 +01:00
use crate::{
docker::ensure_docker_available,
2026-02-02 07:19:22 +01:00
env::ComposeDeployEnv,
2025-12-10 15:26:34 +01:00
errors::ComposeRunnerError,
infrastructure::environment::{
StackEnvironment, ensure_supported_topology, prepare_environment,
2025-12-10 10:11:45 +01:00
},
};
2026-02-02 07:19:22 +01:00
pub struct DeploymentSetup<'a, E: ComposeDeployEnv> {
descriptors: &'a E::Deployment,
2025-12-10 10:11:45 +01:00
}
2026-02-02 07:19:22 +01:00
pub struct DeploymentContext<'a, E: ComposeDeployEnv> {
pub descriptors: &'a E::Deployment,
2025-12-10 10:11:45 +01:00
pub environment: StackEnvironment,
}
2026-02-02 07:19:22 +01:00
impl<'a, E: ComposeDeployEnv> DeploymentSetup<'a, E> {
pub fn new(descriptors: &'a E::Deployment) -> Self {
Self { descriptors }
2025-12-10 10:11:45 +01:00
}
pub async fn validate_environment(&self) -> Result<(), ComposeRunnerError> {
ensure_docker_available().await?;
2026-02-02 07:19:22 +01:00
ensure_supported_topology::<E>(self.descriptors)?;
2025-12-10 10:11:45 +01:00
2026-02-02 07:19:22 +01:00
log_deployment_start(self.descriptors.node_count());
2025-12-10 10:11:45 +01:00
Ok(())
}
pub async fn prepare_workspace(
self,
observability: &ObservabilityInputs,
2026-02-02 07:19:22 +01:00
) -> Result<DeploymentContext<'a, E>, ComposeRunnerError> {
let metrics_otlp_ingest_url = observability.metrics_otlp_ingest_url.as_ref();
let environment =
prepare_environment::<E>(self.descriptors, metrics_otlp_ingest_url).await?;
2025-12-10 10:11:45 +01:00
2026-02-02 07:19:22 +01:00
log_workspace_prepared(&environment);
2025-12-10 10:11:45 +01:00
Ok(DeploymentContext {
descriptors: self.descriptors,
environment,
})
}
}
2026-02-02 07:19:22 +01:00
fn log_deployment_start(nodes: usize) {
info!(nodes, "starting compose deployment");
}
fn log_workspace_prepared(environment: &StackEnvironment) {
info!(
compose_file = %environment.compose_path().display(),
project = environment.project_name(),
root = %environment.root().display(),
"compose workspace prepared"
);
}