mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
use testing_framework_core::topology::generation::GeneratedTopology;
|
|
use tracing::{debug, info};
|
|
|
|
use crate::{
|
|
errors::ComposeRunnerError,
|
|
infrastructure::{
|
|
environment::StackEnvironment,
|
|
ports::{HostPortMapping, discover_host_ports},
|
|
},
|
|
};
|
|
|
|
pub struct PortManager;
|
|
|
|
impl PortManager {
|
|
pub async fn prepare(
|
|
environment: &mut StackEnvironment,
|
|
descriptors: &GeneratedTopology,
|
|
) -> Result<HostPortMapping, ComposeRunnerError> {
|
|
debug!("resolving host ports for compose services");
|
|
match discover_host_ports(environment, descriptors).await {
|
|
Ok(mapping) => {
|
|
info!(
|
|
validator_ports = ?mapping.validator_api_ports(),
|
|
executor_ports = ?mapping.executor_api_ports(),
|
|
prometheus_port = environment.prometheus_port(),
|
|
"resolved container host ports"
|
|
);
|
|
Ok(mapping)
|
|
}
|
|
Err(err) => {
|
|
environment
|
|
.fail("failed to determine container host ports")
|
|
.await;
|
|
Err(err)
|
|
}
|
|
}
|
|
}
|
|
}
|