Extract randomized test CI process into a script

This commit is contained in:
Max Brunsfeld 2023-04-14 14:25:55 -07:00
parent 253411bfd0
commit c329546570
3 changed files with 30 additions and 12 deletions

View file

@ -14,8 +14,6 @@ env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
OPERATIONS: 200
ITERATIONS: 10000
jobs: jobs:
tests: tests:
@ -40,12 +38,5 @@ jobs:
clean: false clean: false
submodules: 'recursive' submodules: 'recursive'
- name: Select seed - name: Run randomized tests
run: | run: script/randomized-test-ci
set -eu
seed=$(od -A n -N 8 -t u8 /dev/urandom | xargs)
echo "seed: ${seed}"
echo "SEED=${seed}" >> $GITHUB_ENV
- name: Run tests
run: cargo test --release --package collab random

View file

@ -76,7 +76,7 @@ pub fn run_test(
let seed = atomic_seed.load(SeqCst); let seed = atomic_seed.load(SeqCst);
if is_randomized { if is_randomized {
dbg!(seed); eprintln!("seed = {seed}");
} }
let deterministic = executor::Deterministic::new(seed); let deterministic = executor::Deterministic::new(seed);

27
script/randomized-test-ci Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# Compile the tests first
mkdir -p target
cargo test --release --package collab --no-run
if [[ $? != 0 ]]; then
echo "Build failed"
exit 1
fi
set -eu
LOG_FILE=target/randomized-tests.log
export SAVE_PLAN=target/test-plan.json
export OPERATIONS=200
export ITERATIONS=10000
export SEED=$(od -A n -N 8 -t u8 /dev/urandom | xargs)
cargo test --release --package collab random -- --nocapture 2> >(tee $LOG_FILE)
if [[ $? == 0 ]]; then
echo "Tests passed"
exit 0
fi
# If the tests failed, find the failing seed in the logs
failing_seed=$(grep "failing seed" $LOG_FILE | cut -d: -f2 | xargs)
echo "Tests failed. seed: $failing_seed"