Skip to content

Commit a526f84

Browse files
gabriele-0201pepyakin
authored andcommitted
feat(torture):optional checks after commit & crash
1 parent d4b26ec commit a526f84

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

torture/src/supervisor/cli.rs

+10
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ pub struct WorkloadParams {
7070
#[clap(value_parser=clap::value_parser!(u8).range(0..=100))]
7171
#[arg(long = "workload-commit-crash")]
7272
pub crash: u8,
73+
74+
/// Whether to ensure the correct application of the changest after every commit.
75+
#[clap(default_value = "false")]
76+
#[arg(long = "ensure-changeset")]
77+
pub ensure_changeset: bool,
78+
79+
/// Whether to ensure the correctness of the state after every crash.
80+
#[clap(default_value = "false")]
81+
#[arg(long = "ensure-snapshot")]
82+
pub ensure_snapshot: bool,
7383
}

torture/src/supervisor/workload.rs

+18
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ pub struct Workload {
204204
/// Data collected to evaluate the average commit time [ns].
205205
tot_commit_time: u64,
206206
n_successfull_commit: u64,
207+
/// Whether to ensure the correct application of the changest after every commit.
208+
ensure_changeset: bool,
209+
/// Whether to ensure the correctness of the state after every crash.
210+
ensure_snapshot: bool,
207211
}
208212

209213
impl Workload {
@@ -242,6 +246,8 @@ impl Workload {
242246
bitbox_seed,
243247
tot_commit_time: 0,
244248
n_successfull_commit: 0,
249+
ensure_changeset: workload_params.ensure_changeset,
250+
ensure_snapshot: workload_params.ensure_snapshot,
245251
}
246252
}
247253

@@ -324,6 +330,10 @@ impl Workload {
324330
rr: &comms::RequestResponse,
325331
changeset: &Vec<KeyValueChange>,
326332
) -> anyhow::Result<()> {
333+
if !self.ensure_changeset {
334+
return Ok(());
335+
}
336+
327337
for change in changeset {
328338
match change {
329339
KeyValueChange::Insert(key, value)
@@ -402,6 +412,10 @@ impl Workload {
402412
rr: &comms::RequestResponse,
403413
changeset: &Vec<KeyValueChange>,
404414
) -> anyhow::Result<()> {
415+
if !self.ensure_changeset {
416+
return Ok(());
417+
}
418+
405419
// Given a reverted changeset, we need to ensure that each modified/deleted key
406420
// is equal to its previous state and that each new key is not available.
407421
for change in changeset {
@@ -437,6 +451,10 @@ impl Workload {
437451
}
438452

439453
async fn ensure_snapshot_validity(&self, rr: &comms::RequestResponse) -> anyhow::Result<()> {
454+
if !self.ensure_snapshot {
455+
return Ok(());
456+
}
457+
440458
for (i, (key, expected_value)) in (self.state.committed.state.iter()).enumerate() {
441459
let value = rr.send_request_query(*key).await?;
442460
if &value != expected_value {

0 commit comments

Comments
 (0)