2026-03-07 09:25:54 +01:00
|
|
|
use std::time::Duration;
|
2026-03-02 11:19:55 +01:00
|
|
|
|
2026-03-06 14:24:27 +01:00
|
|
|
use anyhow::{Error, Result, anyhow};
|
2026-03-02 11:19:55 +01:00
|
|
|
use lb_ext::{CoreBuilderExt as _, LbcComposeDeployer, LbcExtEnv, ScenarioBuilder};
|
2026-03-07 08:04:15 +01:00
|
|
|
use testing_framework_core::scenario::{Deployer as _, Runner};
|
2026-03-06 13:31:03 +01:00
|
|
|
use testing_framework_runner_compose::{ComposeDeploymentMetadata, ComposeRunnerError};
|
2026-03-02 11:19:55 +01:00
|
|
|
|
2026-03-07 08:04:15 +01:00
|
|
|
#[tokio::test]
|
|
|
|
|
#[ignore = "requires Docker and mutates compose runtime state"]
|
|
|
|
|
async fn compose_attach_mode_queries_node_api_opt_in() -> Result<()> {
|
|
|
|
|
let managed = ScenarioBuilder::deployment_with(|d| d.with_node_count(1))
|
|
|
|
|
.with_run_duration(Duration::from_secs(5))
|
|
|
|
|
.build()?;
|
|
|
|
|
|
2026-03-07 09:17:10 +01:00
|
|
|
let managed_deployer = LbcComposeDeployer::default();
|
2026-03-07 08:04:15 +01:00
|
|
|
let (_managed_runner, metadata): (Runner<LbcExtEnv>, ComposeDeploymentMetadata) =
|
2026-03-07 09:17:10 +01:00
|
|
|
match managed_deployer.deploy_with_metadata(&managed).await {
|
2026-03-07 08:04:15 +01:00
|
|
|
Ok(result) => result,
|
|
|
|
|
Err(ComposeRunnerError::DockerUnavailable) => return Ok(()),
|
|
|
|
|
Err(error) => return Err(Error::new(error)),
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-08 14:03:50 +01:00
|
|
|
let attach_source = metadata
|
|
|
|
|
.existing_cluster()
|
|
|
|
|
.map_err(|err| anyhow!("{err}"))?;
|
2026-03-07 08:04:15 +01:00
|
|
|
let attached = ScenarioBuilder::deployment_with(|d| d.with_node_count(1))
|
|
|
|
|
.with_run_duration(Duration::from_secs(5))
|
2026-03-08 13:57:15 +01:00
|
|
|
.with_existing_cluster(attach_source)
|
2026-03-07 08:04:15 +01:00
|
|
|
.build()?;
|
|
|
|
|
|
2026-03-07 09:17:10 +01:00
|
|
|
let attached_deployer = LbcComposeDeployer::default();
|
|
|
|
|
let attached_runner: Runner<LbcExtEnv> = match attached_deployer.deploy(&attached).await {
|
2026-03-07 08:04:15 +01:00
|
|
|
Ok(runner) => runner,
|
|
|
|
|
Err(ComposeRunnerError::DockerUnavailable) => return Ok(()),
|
|
|
|
|
Err(error) => return Err(Error::new(error)),
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-07 08:32:31 +01:00
|
|
|
attached_runner
|
|
|
|
|
.wait_network_ready()
|
|
|
|
|
.await
|
|
|
|
|
.map_err(|err| anyhow!("compose attached runner readiness failed: {err}"))?;
|
|
|
|
|
|
2026-03-07 08:04:15 +01:00
|
|
|
if attached_runner.context().node_clients().is_empty() {
|
|
|
|
|
return Err(anyhow!("compose attach resolved no node clients"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for node_client in attached_runner.context().node_clients().snapshot() {
|
|
|
|
|
node_client.consensus_info().await.map_err(|err| {
|
|
|
|
|
anyhow!(
|
|
|
|
|
"attached node api query failed at {}: {err}",
|
|
|
|
|
node_client.base_url()
|
|
|
|
|
)
|
|
|
|
|
})?;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|