mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
Add *_with helpers for DSL blocks and apply to examples
This commit is contained in:
parent
c0555ca347
commit
7e544c8838
@ -49,22 +49,23 @@ async fn run_compose_case(
|
||||
.executors(executors)
|
||||
})
|
||||
.enable_node_control()
|
||||
.chaos()
|
||||
.restart()
|
||||
// Keep chaos restarts outside the test run window to avoid crash loops on restart.
|
||||
.min_delay(Duration::from_secs(120))
|
||||
.max_delay(Duration::from_secs(180))
|
||||
.target_cooldown(Duration::from_secs(240))
|
||||
.apply()
|
||||
.chaos_with(|c| {
|
||||
c.restart()
|
||||
// Keep chaos restarts outside the test run window to avoid crash loops on restart.
|
||||
.min_delay(Duration::from_secs(120))
|
||||
.max_delay(Duration::from_secs(180))
|
||||
.target_cooldown(Duration::from_secs(240))
|
||||
.apply()
|
||||
})
|
||||
.wallets(TOTAL_WALLETS)
|
||||
.transactions()
|
||||
.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
.apply()
|
||||
.da()
|
||||
.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
.apply()
|
||||
.transactions_with(|txs| {
|
||||
txs.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
})
|
||||
.da_with(|da| {
|
||||
da.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
})
|
||||
.with_run_duration(run_duration)
|
||||
.expect_consensus_liveness()
|
||||
.build();
|
||||
|
||||
@ -45,14 +45,14 @@ async fn run_k8s_case(
|
||||
.executors(executors)
|
||||
})
|
||||
.wallets(TOTAL_WALLETS)
|
||||
.transactions()
|
||||
.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
.apply()
|
||||
.da()
|
||||
.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
.apply()
|
||||
.transactions_with(|txs| {
|
||||
txs.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
})
|
||||
.da_with(|da| {
|
||||
da.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
})
|
||||
.with_run_duration(run_duration)
|
||||
.expect_consensus_liveness()
|
||||
.build();
|
||||
|
||||
@ -53,14 +53,14 @@ async fn run_local_case(
|
||||
.executors(executors)
|
||||
})
|
||||
.wallets(TOTAL_WALLETS)
|
||||
.transactions()
|
||||
.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
.apply()
|
||||
.da()
|
||||
.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
.apply()
|
||||
.transactions_with(|txs| {
|
||||
txs.rate(MIXED_TXS_PER_BLOCK)
|
||||
.users(TRANSACTION_WALLETS)
|
||||
})
|
||||
.da_with(|da| {
|
||||
da.channel_rate(1)
|
||||
.blob_rate(1)
|
||||
})
|
||||
.with_run_duration(run_duration)
|
||||
.expect_consensus_liveness()
|
||||
.build();
|
||||
|
||||
@ -35,8 +35,18 @@ non_zero_rate_fn!(blob_rate_checked, "blob rate must be non-zero");
|
||||
pub trait ScenarioBuilderExt<Caps>: Sized {
|
||||
/// Configure a transaction flow workload.
|
||||
fn transactions(self) -> TransactionFlowBuilder<Caps>;
|
||||
/// Configure a transaction flow workload via closure.
|
||||
fn transactions_with(
|
||||
self,
|
||||
f: impl FnOnce(TransactionFlowBuilder<Caps>) -> TransactionFlowBuilder<Caps>,
|
||||
) -> CoreScenarioBuilder<Caps>;
|
||||
/// Configure a data-availability workload.
|
||||
fn da(self) -> DataAvailabilityFlowBuilder<Caps>;
|
||||
/// Configure a data-availability workload via closure.
|
||||
fn da_with(
|
||||
self,
|
||||
f: impl FnOnce(DataAvailabilityFlowBuilder<Caps>) -> DataAvailabilityFlowBuilder<Caps>,
|
||||
) -> CoreScenarioBuilder<Caps>;
|
||||
#[must_use]
|
||||
/// Attach a consensus liveness expectation.
|
||||
fn expect_consensus_liveness(self) -> Self;
|
||||
@ -50,10 +60,24 @@ impl<Caps> ScenarioBuilderExt<Caps> for CoreScenarioBuilder<Caps> {
|
||||
TransactionFlowBuilder::new(self)
|
||||
}
|
||||
|
||||
fn transactions_with(
|
||||
self,
|
||||
f: impl FnOnce(TransactionFlowBuilder<Caps>) -> TransactionFlowBuilder<Caps>,
|
||||
) -> CoreScenarioBuilder<Caps> {
|
||||
f(self.transactions()).apply()
|
||||
}
|
||||
|
||||
fn da(self) -> DataAvailabilityFlowBuilder<Caps> {
|
||||
DataAvailabilityFlowBuilder::new(self)
|
||||
}
|
||||
|
||||
fn da_with(
|
||||
self,
|
||||
f: impl FnOnce(DataAvailabilityFlowBuilder<Caps>) -> DataAvailabilityFlowBuilder<Caps>,
|
||||
) -> CoreScenarioBuilder<Caps> {
|
||||
f(self.da()).apply()
|
||||
}
|
||||
|
||||
fn expect_consensus_liveness(self) -> Self {
|
||||
self.with_expectation(ConsensusLiveness::default())
|
||||
}
|
||||
@ -185,12 +209,24 @@ impl<Caps> DataAvailabilityFlowBuilder<Caps> {
|
||||
pub trait ChaosBuilderExt: Sized {
|
||||
/// Entry point into chaos workloads.
|
||||
fn chaos(self) -> ChaosBuilder;
|
||||
/// Configure chaos via closure.
|
||||
fn chaos_with(
|
||||
self,
|
||||
f: impl FnOnce(ChaosBuilder) -> CoreScenarioBuilder<NodeControlCapability>,
|
||||
) -> CoreScenarioBuilder<NodeControlCapability>;
|
||||
}
|
||||
|
||||
impl ChaosBuilderExt for CoreScenarioBuilder<NodeControlCapability> {
|
||||
fn chaos(self) -> ChaosBuilder {
|
||||
ChaosBuilder { builder: self }
|
||||
}
|
||||
|
||||
fn chaos_with(
|
||||
self,
|
||||
f: impl FnOnce(ChaosBuilder) -> CoreScenarioBuilder<NodeControlCapability>,
|
||||
) -> CoreScenarioBuilder<NodeControlCapability> {
|
||||
f(self.chaos())
|
||||
}
|
||||
}
|
||||
|
||||
/// Chaos workload builder root.
|
||||
@ -202,6 +238,12 @@ pub struct ChaosBuilder {
|
||||
}
|
||||
|
||||
impl ChaosBuilder {
|
||||
/// Finish without adding a chaos workload.
|
||||
#[must_use]
|
||||
pub fn apply(self) -> CoreScenarioBuilder<NodeControlCapability> {
|
||||
self.builder
|
||||
}
|
||||
|
||||
/// Configure a random restarts chaos workload.
|
||||
#[must_use]
|
||||
pub fn restart(self) -> ChaosRestartBuilder {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user