Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f652f9

Browse files
gabriele-0201pepyakin
authored andcommittedJan 20, 2025··
feat(torture):optional checks after commit & crash
1 parent 715bb03 commit 6f652f9

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
@@ -202,6 +202,10 @@ pub struct Workload {
202202
/// Data collected to evaluate the average commit time.
203203
tot_commit_time: u64,
204204
n_successfull_commit: u64,
205+
/// Whether to ensure the correct application of the changest after every commit.
206+
ensure_changeset: bool,
207+
/// Whether to ensure the correctness of the state after every crash.
208+
ensure_snapshot: bool,
205209
}
206210

207211
impl Workload {
@@ -240,6 +244,8 @@ impl Workload {
240244
bitbox_seed,
241245
tot_commit_time: 0,
242246
n_successfull_commit: 0,
247+
ensure_changeset: workload_params.ensure_changeset,
248+
ensure_snapshot: workload_params.ensure_snapshot,
243249
}
244250
}
245251

@@ -322,6 +328,10 @@ impl Workload {
322328
rr: &comms::RequestResponse,
323329
changeset: &Vec<KeyValueChange>,
324330
) -> anyhow::Result<()> {
331+
if !self.ensure_changeset {
332+
return Ok(());
333+
}
334+
325335
for change in changeset {
326336
match change {
327337
KeyValueChange::Insert(key, value)
@@ -400,6 +410,10 @@ impl Workload {
400410
rr: &comms::RequestResponse,
401411
changeset: &Vec<KeyValueChange>,
402412
) -> anyhow::Result<()> {
413+
if !self.ensure_changeset {
414+
return Ok(());
415+
}
416+
403417
// Given a reverted changeset, we need to ensure that each modified/deleted key
404418
// is equal to its previous state and that each new key is not avaible.
405419
for change in changeset {
@@ -435,6 +449,10 @@ impl Workload {
435449
}
436450

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

0 commit comments

Comments
 (0)
Please sign in to comment.