Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: attempt to shard huge test targets more #98834

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not maintain the small, medium, large, enormous categories for CCL tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Because we don't use them, we can easily add them if we need to though.

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions:

  • How does shard count interact with cpu:2 (or cpu:1 in other cases)?
  • Why change some to 48 but not others?

Copy link
Contributor Author

@healthy-pod healthy-pod Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change some to 48 but not others?

We upload bazel trace profile to artifacts on each unit tests run. I looked at some runs, found targets that had large shards or bottle-necking the process, and sharded them more. Mainly, logictests, backupccl, schemachangerccl, kvserver. If a logictests package has less than 48 tests, it gets n number of shards where n is the number of tests.

How does shard count interact with cpu:2 (or cpu:1 in other cases)?

Good question. Looking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does shard count interact with cpu:2 (or cpu:1 in other cases)?

Each shard gets n cores if cpu:n is used. I tried to play with it but didn't notice any changes so preferred to keep it unchanged.

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