diff --git a/test/BUILD.bazel b/test/BUILD.bazel index d536197aee..13ef5922d0 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -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( diff --git a/test/generate_unittests.bzl b/test/generate_unittests.bzl index 8cfec78a71..5232fbd6da 100644 --- a/test/generate_unittests.bzl +++ b/test/generate_unittests.bzl @@ -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], @@ -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)