2025-12-17 18:28:36 +01:00
|
|
|
use testing_framework_core::{
|
|
|
|
|
scenario::ObservabilityInputs, topology::generation::GeneratedTopology,
|
2025-12-10 10:11:45 +01:00
|
|
|
};
|
2025-12-17 18:28:36 +01:00
|
|
|
use tracing::info;
|
2025-12-10 10:11:45 +01:00
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
docker::ensure_docker_available,
|
2025-12-10 15:26:34 +01:00
|
|
|
errors::ComposeRunnerError,
|
|
|
|
|
infrastructure::environment::{
|
2025-12-17 18:28:36 +01:00
|
|
|
StackEnvironment, ensure_supported_topology, prepare_environment,
|
2025-12-10 10:11:45 +01:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pub struct DeploymentSetup {
|
|
|
|
|
descriptors: GeneratedTopology,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct DeploymentContext {
|
|
|
|
|
pub descriptors: GeneratedTopology,
|
|
|
|
|
pub environment: StackEnvironment,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl DeploymentSetup {
|
|
|
|
|
pub fn new(descriptors: &GeneratedTopology) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
descriptors: descriptors.clone(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn validate_environment(&self) -> Result<(), ComposeRunnerError> {
|
|
|
|
|
ensure_docker_available().await?;
|
|
|
|
|
ensure_supported_topology(&self.descriptors)?;
|
|
|
|
|
|
|
|
|
|
info!(
|
|
|
|
|
validators = self.descriptors.validators().len(),
|
|
|
|
|
executors = self.descriptors.executors().len(),
|
|
|
|
|
"starting compose deployment"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-17 18:28:36 +01:00
|
|
|
pub async fn prepare_workspace(
|
|
|
|
|
self,
|
|
|
|
|
observability: &ObservabilityInputs,
|
|
|
|
|
) -> Result<DeploymentContext, ComposeRunnerError> {
|
|
|
|
|
let environment = prepare_environment(
|
|
|
|
|
&self.descriptors,
|
|
|
|
|
observability.metrics_otlp_ingest_url.as_ref(),
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
2025-12-10 10:11:45 +01:00
|
|
|
|
|
|
|
|
info!(
|
|
|
|
|
compose_file = %environment.compose_path().display(),
|
|
|
|
|
project = environment.project_name(),
|
|
|
|
|
root = %environment.root().display(),
|
|
|
|
|
"compose workspace prepared"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Ok(DeploymentContext {
|
|
|
|
|
descriptors: self.descriptors,
|
|
|
|
|
environment,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|