zed/script/randomized-test-ci

51 lines
1.1 KiB
Text
Raw Normal View History

#!/bin/bash
set -u
: $ZED_SERVER_URL
: $ZED_CLIENT_SECRET_TOKEN
# Compile the tests first
mkdir -p target
cargo test --release --lib --package collab --no-run
if [[ $? != 0 ]]; then
echo "Build failed"
exit 1
fi
LOG_FILE=target/randomized-tests.log
MIN_PLAN=target/test-plan.min.json
export SAVE_PLAN=target/test-plan.json
export OPERATIONS=200
export ITERATIONS=100000
export SEED=$(od -A n -N 8 -t u8 /dev/urandom | xargs)
echo "Starting seed: ${SEED}"
cargo test --release --lib --package collab random 2>&1 > $LOG_FILE
if [[ $? == 0 ]]; then
echo "Tests passed"
exit 0
fi
failing_seed=$(script/randomized-test-minimize $SAVE_PLAN $MIN_PLAN)
# If the tests failed, find the failing seed in the logs
commit=$(git rev-parse HEAD)
failing_plan=$(cat $MIN_PLAN)
request="{
\"seed\": \"${failing_seed}\",
\"commit\": \"${commit}\",
\"token\": \"${ZED_CLIENT_SECRET_TOKEN}\",
\"plan\": ${failing_plan}
}"
echo "Reporting test failure."
echo $request
curl \
-X POST \
-H "Content-Type: application/json" \
-d "${request}" \
"${ZED_SERVER_URL}/api/randomized_test_failure"