| @@ -1,27 +1,48 @@ |
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | | 2 | |
| | 3 | set -u |
| | 4 | |
| | 5 | : $ZED_SERVER_URL |
| | 6 | : $ZED_CLIENT_SECRET_TOKEN |
| | 7 | |
| 3 | # Compile the tests first | 8 | # Compile the tests first |
| 4 | mkdir -p target | 9 | mkdir -p target |
| 5 | cargo test --release --package collab --no-run | 10 | cargo test --release --lib --package collab --no-run |
| 6 | if [[ $? != 0 ]]; then | 11 | if [[ $? != 0 ]]; then |
| 7 | echo "Build failed" | 12 | echo "Build failed" |
| 8 | exit 1 | 13 | exit 1 |
| 9 | fi | 14 | fi |
| 10 | | 15 | |
| 11 | set -eu | | |
| 12 | | | |
| 13 | LOG_FILE=target/randomized-tests.log | 16 | LOG_FILE=target/randomized-tests.log |
| 14 | export SAVE_PLAN=target/test-plan.json | 17 | export SAVE_PLAN=target/test-plan.json |
| 15 | export OPERATIONS=200 | 18 | export OPERATIONS=200 |
| 16 | export ITERATIONS=10000 | 19 | export ITERATIONS=100000 |
| 17 | export SEED=$(od -A n -N 8 -t u8 /dev/urandom | xargs) | 20 | export SEED=$(od -A n -N 8 -t u8 /dev/urandom | xargs) |
| 18 | | 21 | |
| 19 | cargo test --release --package collab random -- --nocapture 2> >(tee $LOG_FILE) | 22 | echo "Starting seed: ${SEED}" |
| | 23 | |
| | 24 | cargo test --release --lib --package collab random 2>&1 > $LOG_FILE |
| 20 | if [[ $? == 0 ]]; then | 25 | if [[ $? == 0 ]]; then |
| 21 | echo "Tests passed" | 26 | echo "Tests passed" |
| 22 | exit 0 | 27 | exit 0 |
| 23 | fi | 28 | fi |
| 24 | | 29 | |
| 25 | # If the tests failed, find the failing seed in the logs | 30 | # If the tests failed, find the failing seed in the logs |
| 26 | failing_seed=$(grep "failing seed" $LOG_FILE | cut -d: -f2 | xargs) | 31 | commit=$(git rev-parse HEAD) |
| 27 | echo "Tests failed. seed: $failing_seed" | 32 | failing_seed=$(grep "failing seed" $LOG_FILE | tail -n1 | cut -d: -f2 | xargs) |
| | 33 | failing_plan=$(cat $SAVE_PLAN) |
| | 34 | request="{ |
| | 35 | \"seed\": \"${failing_seed}\", |
| | 36 | \"commit\": \"${commit}\", |
| | 37 | \"token\": \"${ZED_CLIENT_SECRET_TOKEN}\", |
| | 38 | \"plan\": ${failing_plan} |
| | 39 | }" |
| | 40 | |
| | 41 | echo "Reporting test failure." |
| | 42 | echo $request |
| | 43 | |
| | 44 | curl \ |
| | 45 | -X POST \ |
| | 46 | -H "Content-Type: application/json" \ |
| | 47 | -d "${request}" \ |
| | 48 | "${ZED_SERVER_URL}/api/randomized_test_failure" |