refactor(examples): declutter scenario builders

This commit is contained in:
andrussal 2025-12-16 01:41:24 +01:00
parent c2ac7f4dc0
commit b188bd7364
2 changed files with 28 additions and 50 deletions

View File

@ -63,7 +63,6 @@ async fn main() {
} }
} }
#[rustfmt::skip]
async fn run_compose_case( async fn run_compose_case(
validators: usize, validators: usize,
executors: usize, executors: usize,
@ -78,35 +77,26 @@ async fn run_compose_case(
let chaos_min_delay = Duration::from_secs(CHAOS_MIN_DELAY_SECS) let chaos_min_delay = Duration::from_secs(CHAOS_MIN_DELAY_SECS)
.max(run_duration + Duration::from_secs(CHAOS_DELAY_HEADROOM_SECS)); .max(run_duration + Duration::from_secs(CHAOS_DELAY_HEADROOM_SECS));
let chaos_max_delay = let chaos_max_delay = Duration::from_secs(CHAOS_MAX_DELAY_SECS).max(chaos_min_delay);
Duration::from_secs(CHAOS_MAX_DELAY_SECS).max(chaos_min_delay);
let mut plan = ScenarioBuilder::topology_with(|t| { let mut plan = ScenarioBuilder::topology_with(|t| {
t.network_star() t.network_star().validators(validators).executors(executors)
.validators(validators)
.executors(executors)
}) })
.enable_node_control() .enable_node_control()
.chaos_with(|c| { .chaos_with(|c| {
c.restart() c.restart()
// Keep chaos restarts outside the test run window to avoid crash loops on restart. // Keep chaos restarts outside the test run window to avoid crash loops on restart.
.min_delay(chaos_min_delay) .min_delay(chaos_min_delay)
.max_delay(chaos_max_delay) .max_delay(chaos_max_delay)
.target_cooldown(Duration::from_secs(CHAOS_COOLDOWN_SECS)) .target_cooldown(Duration::from_secs(CHAOS_COOLDOWN_SECS))
.apply() .apply()
}) })
.wallets(TOTAL_WALLETS) .wallets(TOTAL_WALLETS)
.transactions_with(|txs| { .transactions_with(|txs| txs.rate(MIXED_TXS_PER_BLOCK).users(TRANSACTION_WALLETS))
txs.rate(MIXED_TXS_PER_BLOCK) .da_with(|da| da.channel_rate(DA_CHANNEL_RATE).blob_rate(DA_BLOB_RATE))
.users(TRANSACTION_WALLETS) .with_run_duration(run_duration)
}) .expect_consensus_liveness()
.da_with(|da| { .build();
da.channel_rate(DA_CHANNEL_RATE)
.blob_rate(DA_BLOB_RATE)
})
.with_run_duration(run_duration)
.expect_consensus_liveness()
.build();
let deployer = ComposeDeployer::new(); let deployer = ComposeDeployer::new();
info!("deploying compose stack"); info!("deploying compose stack");

View File

@ -39,12 +39,7 @@ async fn main() {
} }
} }
#[rustfmt::skip] async fn run_k8s_case(validators: usize, executors: usize, run_duration: Duration) -> Result<()> {
async fn run_k8s_case(
validators: usize,
executors: usize,
run_duration: Duration,
) -> Result<()> {
info!( info!(
validators, validators,
executors, executors,
@ -52,21 +47,14 @@ async fn run_k8s_case(
"building scenario plan" "building scenario plan"
); );
let mut plan = ScenarioBuilder::topology_with(|t| { let mut plan = ScenarioBuilder::topology_with(|t| {
t.network_star() t.network_star().validators(validators).executors(executors)
.validators(validators)
.executors(executors)
}) })
.wallets(TOTAL_WALLETS) .wallets(TOTAL_WALLETS)
.transactions_with(|txs| { .transactions_with(|txs| txs.rate(MIXED_TXS_PER_BLOCK).users(TRANSACTION_WALLETS))
txs.rate(MIXED_TXS_PER_BLOCK) .da_with(|da| da.blob_rate(DA_BLOB_RATE))
.users(TRANSACTION_WALLETS) .with_run_duration(run_duration)
}) .expect_consensus_liveness()
.da_with(|da| { .build();
da.blob_rate(DA_BLOB_RATE)
})
.with_run_duration(run_duration)
.expect_consensus_liveness()
.build();
let deployer = K8sDeployer::new(); let deployer = K8sDeployer::new();
info!("deploying k8s stack"); info!("deploying k8s stack");