Skip to content
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
13 changes: 13 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ generate_unittests(
per_test_tags = {
"brpc_redis_unittest.cpp": ["external", "local"],
},
# brpc_channel_unittest packs dozens of timing-sensitive TEST_F (backup
# request, retry/backoff, timeouts) into one binary whose cumulative
# real-time waits exceed Bazel's default per-test 300s (size=medium) limit
# on contended CI runners, causing TIMEOUT failures. Raise its limit to
# size=large (900s).
#
# NB: do NOT shard this binary. Its TEST_F share fixed loopback endpoints
# and global state; running shards as parallel processes makes a
# "connection should be refused" test observe another shard's live server
# on the same port and fail. size=large is the only safe lever here.
per_test_size = {
"brpc_channel_unittest.cpp": "large",
},
)

refresh_compile_commands(
Expand Down
19 changes: 18 additions & 1 deletion test/generate_unittests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

def generate_unittests(name, srcs, deps, copts, linkopts = [], data = [], per_test_tags = {}):
def generate_unittests(
name,
srcs,
deps,
copts,
linkopts = [],
data = [],
per_test_tags = {},
per_test_size = {}):
tests = []
for s in srcs:
ut_name = s.replace(".cpp", "")
# per_test_size raises Bazel's per-test timeout for a specific file
# ("large" = 900s vs the default medium = 300s), for binaries whose
# cumulative real-time waits would otherwise blow the limit on
# contended CI runners.
kwargs = {}
size = per_test_size.get(s)
if size != None:
kwargs["size"] = size
native.cc_test(
name = ut_name,
srcs = [s],
Expand All @@ -29,6 +45,7 @@ def generate_unittests(name, srcs, deps, copts, linkopts = [], data = [], per_te
# pass, and "local" runs them outside the sandbox so the PATH-located
# server binary is visible and loopback works.
tags = per_test_tags.get(s, []),
**kwargs
)
tests.append(":" + ut_name)

Expand Down
Loading