github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/teamcity-stress.sh (about) 1 #!/usr/bin/env bash 2 3 set -euo pipefail 4 5 source "$(dirname "${0}")/teamcity-support.sh" 6 7 run export BUILDER_HIDE_GOPATH_SRC=1 8 run mkdir -p artifacts 9 definitely_ccache 10 11 env=( 12 "GITHUB_API_TOKEN=$GITHUB_API_TOKEN" 13 "BUILD_VCS_NUMBER=$BUILD_VCS_NUMBER" 14 "TC_BUILD_ID=$TC_BUILD_ID" 15 "TC_SERVER_URL=$TC_SERVER_URL" 16 "TC_BUILD_BRANCH=$TC_BUILD_BRANCH" 17 "COCKROACH_NIGHTLY_STRESS=true" 18 "PKG=$PKG" 19 "GOFLAGS=${GOFLAGS:-}" 20 "TAGS=${TAGS:-}" 21 "STRESSFLAGS=${STRESSFLAGS:-}" 22 "TZ=America/New_York" 23 ) 24 25 build/builder.sh env "${env[@]}" bash <<'EOF' 26 set -euxo pipefail 27 go install ./pkg/cmd/github-post 28 29 # We're going to run stress, pipe its output to test2json to add a bit of 30 # structure, then pipe that to our github-post script which creates issues for 31 # failed tests. 32 # Note that we don't stream the results into test2json, as the tool generally 33 # expects. We don't stream because we want the failing stress output to make it 34 # to Team City's build log (i.e. to the stdout of this file). 35 # The streaming would be meaningless for the purposes of the timing information 36 # recorded by test2json because stress captures the test output and prints it 37 # all at once. github-post compensates for this. 38 # TODO(andrei): Something we could do is teach the `make stress` target (or a 39 # new target) to pass the test2son invocation to the `go test -exec` flag (note 40 # that test2json knows how to take a test binary and flags). This way we could 41 # get rid of some logic specific to supporting stress output in github-post. 42 # But then the problem would be that the TC build log would contain json, which 43 # is not the most readable. So I guess we'd also need a json2test tool to strip 44 # the json and go back to raw logs. 45 # 46 # We've set pipefail, so the exit status is going to come from stress if there 47 # are test failures. 48 # Use an `if` so that the `-e` option doesn't stop the script on error. 49 if ! stdbuf -oL -eL \ 50 make stress PKG="$PKG" TESTTIMEOUT=40m GOFLAGS="$GOFLAGS" TAGS="$TAGS" STRESSFLAGS="-maxruns 100 -maxtime 1h -maxfails 1 -stderr $STRESSFLAGS" 2>&1 \ 51 | tee artifacts/stress.log; then 52 exit_status=${PIPESTATUS[0]} 53 go tool test2json -t -p "${PKG}" < artifacts/stress.log | github-post 54 exit $exit_status 55 fi 56 57 EOF