History

Report randomized test failures to zed.dev, to create issues in linear

Max Brunsfeld committed 3 years ago

Commit 5c3da911 parent c3295462 files · +31 −8Browse files

Showing the changes to script (1 of 2 files). Show all

Unified · Split

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