github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/teamcity-testrace.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -euo pipefail
     4  
     5  source "$(dirname "${0}")/teamcity-support.sh"
     6  
     7  tc_prepare
     8  
     9  export TMPDIR=$PWD/artifacts/testrace
    10  mkdir -p "$TMPDIR"
    11  
    12  tc_start_block "Determine changed packages"
    13  if tc_release_branch; then
    14    pkgspec=./pkg/...
    15    echo "On release branch ($TC_BUILD_BRANCH), so running testrace on all packages ($pkgspec)"
    16  else
    17    pkgspec=$(changed_go_pkgs)
    18    if [[ $(echo "$pkgspec" | wc -w) -gt 10 ]]; then
    19      echo "PR #$TC_BUILD_BRANCH changed many packages; skipping race detector tests"
    20      exit 0
    21    elif [[ -z "$pkgspec" ]]; then
    22      echo "PR #$TC_BUILD_BRANCH has no changed packages; skipping race detector tests"
    23      exit 0
    24    fi
    25    if [[ $pkgspec == *"./pkg/sql/opt"* ]]; then
    26      # If one opt package was changed, run all opt packages (the optimizer puts
    27      # various checks behind the race flag to keep them out of release builds).
    28      echo "$pkgspec" | sed 's$./pkg/sql/opt/[^ ]*$$g'
    29      pkgspec=$(echo "$pkgspec" | sed 's$./pkg/sql/opt[^ ]*$$g')
    30      pkgspec="$pkgspec ./pkg/sql/opt/..."
    31    fi
    32    echo "PR #$TC_BUILD_BRANCH has changed packages; running race detector tests on $pkgspec"
    33  fi
    34  tc_end_block "Determine changed packages"
    35  
    36  tc_start_block "Compile C dependencies"
    37  # Buffer noisy output and only print it on failure.
    38  run build/builder.sh make -Otarget c-deps GOFLAGS=-race &> artifacts/race-c-build.log || (cat artifacts/race-c-build.log && false)
    39  rm artifacts/race-c-build.log
    40  tc_end_block "Compile C dependencies"
    41  
    42  maybe_stress "stressrace"
    43  
    44  # Expect the timeout to come from the TC environment.
    45  TESTTIMEOUT=${TESTTIMEOUT:-45m}
    46  
    47  for pkg in $pkgspec; do
    48    tc_start_block "Run ${pkg} under race detector"
    49    run_json_test build/builder.sh env \
    50      COCKROACH_LOGIC_TESTS_SKIP=true \
    51      stdbuf -oL -eL \
    52      make testrace \
    53      GOTESTFLAGS=-json \
    54      PKG="$pkg" \
    55      TESTTIMEOUT="${TESTTIMEOUT}" \
    56      TESTFLAGS="-v $TESTFLAGS" \
    57      ENABLE_ROCKSDB_ASSERTIONS=1 \
    58      ENABLE_LIBROACH_ASSERTIONS=1
    59    tc_end_block "Run ${pkg} under race detector"
    60  done