Skip to content

Commit

Permalink
Merge #98834
Browse files Browse the repository at this point in the history
98834: ci: attempt to shard huge test targets more r=rickystewart a=healthy-pod

This code change attempts to shard some test
targets that could benefit from more sharding. It
also splits unit tests in TeamCity into two runs:
ccl unit tests, and non-ccl unit tests. The current
build config will be used to run non-ccl unit tests.
The new build config will be used for ccl tests (those
under `pkg/ccl`). This cuts unit tests wall time by
half while keeping machine time almost the same.

Release note: None
Epic: none

Co-authored-by: healthy-pod <[email protected]>
  • Loading branch information
craig[bot] and healthy-pod committed Mar 23, 2023
2 parents 4e5316a + 69921eb commit 384c55d
Show file tree
Hide file tree
Showing 106 changed files with 228 additions and 47 deletions.
12 changes: 12 additions & 0 deletions build/teamcity/cockroach/ci/tests/unit_tests_ccl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"

source "$dir/teamcity-support.sh" # For $root
source "$dir/teamcity-bazel-support.sh" # For run_bazel

tc_start_block "Run unit tests"
BAZEL_SUPPORT_EXTRA_DOCKER_ARGS="-e TC_BUILD_BRANCH -e GITHUB_API_TOKEN -e BUILD_VCS_NUMBER -e TC_BUILD_ID -e TC_SERVER_URL -e TC_BUILDTYPE_ID -e GITHUB_REPO" run_bazel build/teamcity/cockroach/ci/tests/unit_tests_ccl_impl.sh
tc_end_block "Run unit tests"
20 changes: 20 additions & 0 deletions build/teamcity/cockroach/ci/tests/unit_tests_ccl_impl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -xeuo pipefail

dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"

source "$dir/teamcity-support.sh" # for 'tc_release_branch'

bazel build //pkg/cmd/bazci --config=ci

EXTRA_PARAMS=""

if tc_release_branch; then
# enable up to 2 retries (3 attempts, worst-case) per test executable to report flakes but only on release branches (i.e., not staging)
EXTRA_PARAMS=" --flaky_test_attempts=3"
fi

$(bazel info bazel-bin --config=ci)/pkg/cmd/bazci/bazci_/bazci -- test --config=cinolint -c fastbuild \
//pkg:ccl_tests \
--profile=/artifacts/profile.gz $EXTRA_PARAMS
2 changes: 1 addition & 1 deletion build/teamcity/cockroach/ci/tests/unit_tests_impl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ if tc_release_branch; then
fi

$(bazel info bazel-bin --config=ci)/pkg/cmd/bazci/bazci_/bazci -- test --config=cinolint -c fastbuild \
//pkg:small_tests //pkg:medium_tests //pkg:large_tests //pkg:enormous_tests \
//pkg:small_non_ccl_tests //pkg:medium_non_ccl_tests //pkg:large_non_ccl_tests //pkg:enormous_non_ccl_tests \
--profile=/artifacts/profile.gz $EXTRA_PARAMS
22 changes: 18 additions & 4 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3378,9 +3378,20 @@ test_suite(
)

test_suite(
name = "small_tests",
name = "ccl_tests",
tags = [
"-broken_in_bazel",
"ccl_test",
"-integration",
],
tests = ALL_TESTS,
)

test_suite(
name = "small_non_ccl_tests",
tags = [
"-broken_in_bazel",
"-ccl_test",
"-flaky",
"-integration",
"small",
Expand All @@ -3389,9 +3400,10 @@ test_suite(
)

test_suite(
name = "medium_tests",
name = "medium_non_ccl_tests",
tags = [
"-broken_in_bazel",
"-ccl_test",
"-flaky",
"-integration",
"medium",
Expand All @@ -3400,9 +3412,10 @@ test_suite(
)

test_suite(
name = "large_tests",
name = "large_non_ccl_tests",
tags = [
"-broken_in_bazel",
"-ccl_test",
"-flaky",
"-integration",
"large",
Expand All @@ -3411,9 +3424,10 @@ test_suite(
)

test_suite(
name = "enormous_tests",
name = "enormous_non_ccl_tests",
tags = [
"-broken_in_bazel",
"-ccl_test",
"-flaky",
"-integration",
"enormous",
Expand Down
3 changes: 2 additions & 1 deletion pkg/ccl/backupccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ go_test(
args = ["-test.timeout=3595s"],
data = glob(["testdata/**"]) + ["//c-deps:libgeos"],
embed = [":backupccl"],
shard_count = 16,
shard_count = 48,
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/blobs",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/backupdest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ go_test(
"main_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
":backupdest",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/backupinfo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ go_test(
"manifest_handling_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
":backupinfo",
"//pkg/base",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/backuprand/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_test(
],
args = ["-test.timeout=295s"],
data = ["//c-deps:libgeos"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/backupresolver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ go_test(
],
args = ["-test.timeout=295s"],
embed = [":backupresolver"],
tags = ["ccl_test"],
deps = [
"//pkg/ccl",
"//pkg/ccl/storageccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/baseccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go_test(
srcs = ["encryption_spec_test.go"],
args = ["-test.timeout=55s"],
embed = [":baseccl"],
tags = ["ccl_test"],
deps = ["//pkg/util/leaktest"],
)

Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/benchccl/rttanalysisccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_test(
args = ["-test.timeout=3595s"],
data = glob(["testdata/**"]),
shard_count = 16,
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/bench/rttanalysis",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ go_test(
args = ["-test.timeout=3595s"],
embed = [":changefeedccl"],
shard_count = 16,
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/blobs",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/cdceval/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ go_test(
],
args = ["-test.timeout=295s"],
embed = [":cdceval"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl/changefeedccl/cdcevent",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/cdcevent/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ go_test(
],
args = ["-test.timeout=295s"],
embed = [":cdcevent"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl/changefeedccl/cdctest",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/cdctest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ go_test(
],
args = ["-test.timeout=55s"],
embed = [":cdctest"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/cdcutils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_test(
srcs = ["throttle_test.go"],
args = ["-test.timeout=295s"],
embed = [":cdcutils"],
tags = ["ccl_test"],
deps = [
"//pkg/ccl/changefeedccl/changefeedbase",
"//pkg/settings/cluster",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/changefeedbase/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ go_test(
srcs = ["options_test.go"],
args = ["-test.timeout=295s"],
embed = [":changefeedbase"],
tags = ["ccl_test"],
deps = [
"//pkg/util/leaktest",
"//pkg/util/log",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/kvevent/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ go_test(
],
args = ["-test.timeout=295s"],
embed = [":kvevent"],
tags = ["ccl_test"],
deps = [
"//pkg/jobs/jobspb",
"//pkg/keys",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/kvfeed/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ go_test(
],
args = ["-test.timeout=55s"],
embed = [":kvfeed"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/schemafeed/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ go_test(
args = ["-test.timeout=295s"],
data = glob(["testdata/**"]),
embed = [":schemafeed"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cliccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ go_test(
],
args = ["-test.timeout=295s"],
embed = [":cliccl"],
tags = ["ccl_test"],
deps = [
"//pkg/build",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cloudccl/amazon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"s3_connection_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cloudccl/azure/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"main_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cloudccl/cloudprivilege/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"privileges_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cloudccl/externalconn/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_test(
],
args = ["-test.timeout=295s"],
data = glob(["testdata/**"]),
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl/backupccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/cloudccl/gcp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"main_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/importerccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_test(
"//c-deps:libgeos",
"//pkg/sql/importer:testdata",
],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/build/bazel",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/jobsccl/jobsprotectedtsccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"main_test.go",
],
args = ["-test.timeout=295s"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/jwtauthccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ go_test(
],
args = ["-test.timeout=55s"],
embed = [":jwtauthccl"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/kvccl/kvfollowerreadsccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ go_test(
args = ["-test.timeout=295s"],
data = glob(["testdata/**"]),
embed = [":kvfollowerreadsccl"],
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/kvccl/kvtenantccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ go_test(
args = ["-test.timeout=895s"],
embed = [":kvtenantccl"],
shard_count = 16,
tags = ["ccl_test"],
deps = [
"//pkg/base",
"//pkg/ccl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ go_test(
"//pkg/sql/opt/exec/execbuilder:testdata", # keep
],
shard_count = 4,
tags = ["cpu:2"],
tags = [
"ccl_test",
"cpu:2",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
7 changes: 5 additions & 2 deletions pkg/ccl/logictestccl/tests/3node-tenant/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ go_test(
"//pkg/sql/logictest:testdata", # keep
"//pkg/sql/opt/exec/execbuilder:testdata", # keep
],
shard_count = 16,
tags = ["cpu:2"],
shard_count = 48,
tags = [
"ccl_test",
"cpu:2",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/logictestccl/tests/5node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ go_test(
"//pkg/ccl/logictestccl:testdata", # keep
],
shard_count = 5,
tags = ["cpu:3"],
tags = [
"ccl_test",
"cpu:3",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/logictestccl/tests/fakedist-disk/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ go_test(
"//pkg/ccl/logictestccl:testdata", # keep
],
shard_count = 5,
tags = ["cpu:2"],
tags = [
"ccl_test",
"cpu:2",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/logictestccl/tests/fakedist-vec-off/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ go_test(
"//pkg/ccl/logictestccl:testdata", # keep
],
shard_count = 5,
tags = ["cpu:2"],
tags = [
"ccl_test",
"cpu:2",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/logictestccl/tests/fakedist/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ go_test(
"//pkg/ccl/logictestccl:testdata", # keep
],
shard_count = 6,
tags = ["cpu:2"],
tags = [
"ccl_test",
"cpu:2",
],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
Expand Down
Loading

0 comments on commit 384c55d

Please sign in to comment.