Skip to content

Commit 7ac059f

Browse files
author
healthy-pod
committed
ci: pass custom timeout to testrace in CI
In #86363, we added a timeout to tests at the test binary level. Tests running with `--config=race` however use a custom timeout, different from the original default values set by bazel based on the test size. This patch propagates those custom values to testrace in CI. Release justification: Non-production code changes Release note: None
1 parent 7a3edae commit 7ac059f

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ info --ui_event_filters=-WARNING
3434

3535
build:race --@io_bazel_rules_go//go/config:race "--test_env=GORACE=halt_on_error=1 log_path=stdout" --test_sharding_strategy=disabled
3636
test:test --test_env=TZ=
37+
# Note: these timeout values are used indirectly in `build/teamcity/cockroach/ci/tests/testrace_impl.sh`.
38+
# If those values are updated, the script should be updated accordingly.
3739
test:race --test_timeout=1200,6000,18000,72000
3840

3941
# CI should always run with `--config=ci` or `--config=cinolint`.

build/teamcity/cockroach/ci/tests/testrace_impl.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -xeuo pipefail
66
# packages are expected to be formatted as go-style, e.g. ./pkg/cmd/bazci.
77

88
bazel build //pkg/cmd/bazci --config=ci
9+
size_to_timeout=("small:1200" "medium:6000" "large:18000" "enormous:72000")
910
for pkg in "$@"
1011
do
1112
# Query to list all affected tests.
@@ -14,19 +15,26 @@ do
1415
then
1516
pkg="$pkg:all"
1617
fi
17-
tests=$(bazel query "kind(go_test, $pkg)" --output=label)
1818

19-
# Run affected tests.
20-
for test in $tests
19+
for kv in "${size_to_timeout[@]}";
2120
do
22-
if [[ ! -z $(bazel query "attr(tags, \"broken_in_bazel\", $test)") ]]
23-
then
24-
echo "Skipping test $test as it is broken in bazel"
25-
continue
26-
fi
27-
$(bazel info bazel-bin --config=ci)/pkg/cmd/bazci/bazci_/bazci -- test --config=ci --config=race "$test" \
28-
--test_env=COCKROACH_LOGIC_TESTS_SKIP=true \
29-
--test_env=GOMAXPROCS=8
21+
size="${kv%%:*}"
22+
timeout="${kv#*:}"
23+
go_timeout=$(($timeout - 5))
24+
tests=$(bazel query "attr(size, $size, kind("go_test", tests($pkg)))" --output=label)
25+
# Run affected tests.
26+
for test in $tests
27+
do
28+
if [[ ! -z $(bazel query "attr(tags, \"broken_in_bazel\", $test)") ]]
29+
then
30+
echo "Skipping test $test as it is broken in bazel"
31+
continue
32+
fi
33+
$(bazel info bazel-bin --config=ci)/pkg/cmd/bazci/bazci_/bazci -- test --config=ci --config=race "$test" \
34+
--test_env=COCKROACH_LOGIC_TESTS_SKIP=true \
35+
--test_env=GOMAXPROCS=8 \
36+
--test_arg=-test.timeout="${go_timeout}s"
37+
done
3038
done
3139
done
3240

0 commit comments

Comments
 (0)