|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright 2025 The Cockroach Authors. |
| 4 | +# |
| 5 | +# Use of this software is governed by the CockroachDB Software License |
| 6 | +# included in the /LICENSE file. |
| 7 | + |
| 8 | +set -euxo pipefail |
| 9 | + |
| 10 | +# These are provided as variables to test the script locally. |
| 11 | +BAZEL_CONFIG="${BAZEL_CONFIG:-ci}" |
| 12 | +ARTIFACTS_DIR="${ARTIFACTS_DIR:-/artifacts}" |
| 13 | + |
| 14 | +# TEST_PACKAGE_TARGETS is a space-separated list of package containing the |
| 15 | +# tests in test_to_run. |
| 16 | +export TEST_PACKAGE_TARGETS="//pkg/kv/kvnemesis:kvnemesis_test" |
| 17 | + |
| 18 | +# tests_to_run is a hand-curated list of tests that we want to run more often |
| 19 | +# under stress. |
| 20 | +# |
| 21 | +# PLEASE KEEP THIS LIST SHORT. |
| 22 | +declare -a tests_to_run=( |
| 23 | + "TestKVNemesisMultiNode" |
| 24 | + "TestKVNemesisMultiNode_BufferedWritesLockDurabilityUpgrades" |
| 25 | +) |
| 26 | + |
| 27 | +test_exists() { |
| 28 | + git grep -q "func ${1}(" |
| 29 | +} |
| 30 | + |
| 31 | +# This builds a filter string in the form of ^(TestName1|TestName2|...)$ to |
| 32 | +# ensure that we are only running the tests in the tests_to_run array. |
| 33 | +test_filter="^(" |
| 34 | +sep="" |
| 35 | +for t in "${tests_to_run[@]}"; do |
| 36 | + # We look for this test somewhere in the repository so we can fail the test if |
| 37 | + # someone changes the name of a test without updating this file. |
| 38 | + if ! test_exists "$t"; then |
| 39 | + echo "could not find test ${t}" |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + |
| 43 | + test_filter="${test_filter}${sep}${t}" |
| 44 | + sep="|" |
| 45 | +done |
| 46 | +test_filter="${test_filter})\$" |
| 47 | + |
| 48 | +export RUNS_PER_TEST=1000 |
| 49 | +export TEST_ARGS="--test_timeout=25200 --runs_per_test $RUNS_PER_TEST" |
| 50 | + |
| 51 | +mkdir -p $ARTIFACTS_DIR |
| 52 | + |
| 53 | +bazel build //pkg/cmd/bazci |
| 54 | + |
| 55 | +BAZEL_BIN=$(bazel info bazel-bin) |
| 56 | + |
| 57 | +exit_status=0 |
| 58 | +$BAZEL_BIN/pkg/cmd/bazci/bazci_/bazci -- test $TEST_PACKAGE_TARGETS \ |
| 59 | + --config=$BAZEL_CONFIG \ |
| 60 | + --test_env TC_SERVER_URL \ |
| 61 | + $TEST_ARGS \ |
| 62 | + --test_filter="$test_filter" \ |
| 63 | + || exit_status=$? |
| 64 | + |
| 65 | +exit $exit_status |
0 commit comments