2025-12-10 10:11:45 +01:00
|
|
|
use testing_framework_core::topology::generation::GeneratedTopology;
|
|
|
|
|
use tracing::info;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
errors::ComposeRunnerError,
|
2025-12-10 15:26:34 +01:00
|
|
|
infrastructure::{
|
|
|
|
|
environment::StackEnvironment,
|
|
|
|
|
ports::{HostPortMapping, ensure_remote_readiness_with_ports},
|
|
|
|
|
},
|
|
|
|
|
lifecycle::readiness::{ensure_executors_ready_with_ports, ensure_validators_ready_with_ports},
|
2025-12-10 10:11:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pub struct ReadinessChecker;
|
|
|
|
|
|
|
|
|
|
impl ReadinessChecker {
|
|
|
|
|
pub async fn wait_all(
|
|
|
|
|
descriptors: &GeneratedTopology,
|
|
|
|
|
host_ports: &HostPortMapping,
|
|
|
|
|
environment: &mut StackEnvironment,
|
|
|
|
|
) -> Result<(), ComposeRunnerError> {
|
|
|
|
|
info!(
|
|
|
|
|
ports = ?host_ports.validator_api_ports(),
|
|
|
|
|
"waiting for validator HTTP endpoints"
|
|
|
|
|
);
|
|
|
|
|
if let Err(err) =
|
|
|
|
|
ensure_validators_ready_with_ports(&host_ports.validator_api_ports()).await
|
|
|
|
|
{
|
|
|
|
|
environment.fail("validator readiness failed").await;
|
2025-12-11 10:08:49 +01:00
|
|
|
tracing::warn!(error = ?err, "validator readiness failed");
|
2025-12-10 10:11:45 +01:00
|
|
|
return Err(err.into());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info!(
|
|
|
|
|
ports = ?host_ports.executor_api_ports(),
|
|
|
|
|
"waiting for executor HTTP endpoints"
|
|
|
|
|
);
|
|
|
|
|
if let Err(err) = ensure_executors_ready_with_ports(&host_ports.executor_api_ports()).await
|
|
|
|
|
{
|
|
|
|
|
environment.fail("executor readiness failed").await;
|
2025-12-11 10:08:49 +01:00
|
|
|
tracing::warn!(error = ?err, "executor readiness failed");
|
2025-12-10 10:11:45 +01:00
|
|
|
return Err(err.into());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info!("waiting for remote service readiness");
|
|
|
|
|
if let Err(err) = ensure_remote_readiness_with_ports(descriptors, host_ports).await {
|
|
|
|
|
environment.fail("remote readiness probe failed").await;
|
2025-12-11 10:08:49 +01:00
|
|
|
tracing::warn!(error = ?err, "remote readiness probe failed");
|
2025-12-10 10:11:45 +01:00
|
|
|
return Err(err.into());
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 09:00:14 +01:00
|
|
|
info!("compose readiness checks passed");
|
2025-12-10 10:11:45 +01:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|