Skip to content

Commit

Permalink
Merge pull request #1104 from spacejam/tyler_small_crash_test_cleanup
Browse files Browse the repository at this point in the history
Extract crash chance constant
  • Loading branch information
spacejam authored Jun 20, 2020
2 parents 95f528b + e60187f commit 621f53e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/test_crash_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const BATCHES_DIR: &str = "crash_batches";
const ITER_DIR: &str = "crash_iter";
const TX_DIR: &str = "crash_tx";

const CRASH_CHANCE: u32 = 250;

fn main() {
common::setup_logger();

Expand Down Expand Up @@ -266,14 +268,14 @@ fn run_batches() {
}
}

fn run_child_process(test_name: &str, chance: u32) -> Child {
fn run_child_process(test_name: &str) -> Child {
let bin = env::current_exe().expect("could not get test binary path");

env::set_var(TEST_ENV_VAR, test_name);

Command::new(bin)
.env(TEST_ENV_VAR, test_name)
.env("SLED_CRASH_CHANCE", chance.to_string())
.env("SLED_CRASH_CHANCE", CRASH_CHANCE.to_string())
.spawn()
.expect(&format!(
"could not spawn child process for {} test",
Expand Down Expand Up @@ -301,7 +303,7 @@ fn test_crash_recovery() {
cleanup(dir);

for _ in 0..N_TESTS {
let mut child = run_child_process(dir, 200);
let mut child = run_child_process(dir);

child
.wait()
Expand All @@ -318,7 +320,7 @@ fn test_crash_batches() {
cleanup(dir);

for _ in 0..N_TESTS {
let mut child = run_child_process(dir, 200);
let mut child = run_child_process(dir);

child
.wait()
Expand All @@ -335,7 +337,7 @@ fn concurrent_crash_iter() {
cleanup(dir);

for _ in 0..N_TESTS {
let mut child = run_child_process(dir, 200);
let mut child = run_child_process(dir);

child
.wait()
Expand All @@ -352,7 +354,7 @@ fn concurrent_crash_transactions() {
cleanup(dir);

for _ in 0..N_TESTS {
let mut child = run_child_process(dir, 200);
let mut child = run_child_process(dir);

child
.wait()
Expand Down

0 comments on commit 621f53e

Please sign in to comment.