Run Bazel tests in parallel in CI - #3482
Open
wasphin wants to merge 8 commits into
Open
Conversation
Contributor
|
LGTM |
wasphin
marked this pull request as draft
August 24, 2026 15:01
wasphin
force-pushed
the
optimize-ci-bazel-tests
branch
7 times, most recently
from
September 5, 2026 16:21
2ff532b to
d0a517c
Compare
Run the channel and SSL test binaries exclusively. They rely on strict timing or process-wide networking state and can fail when competing with parallel test processes.
Limit fallback restoration to caches produced by the same CI job. The broad fallback could restore a cache from a different compiler or protobuf setup, which produced no hits while consuming transfer time and cache capacity.
wasphin
force-pushed
the
optimize-ci-bazel-tests
branch
from
September 6, 2026 16:10
198adf3 to
c719de6
Compare
wasphin
marked this pull request as ready for review
September 6, 2026 16:44
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are targeted to CI scheduling and test robustness, and the updated test patterns (ephemeral ports, exclusive tags, FlagSaver) are consistent with existing repository practices.
Pull request overview
This PR improves Bazel CI throughput and stability by running unit tests with bounded parallelism and by hardening a set of tests against shared-runner resource conflicts (fixed ports, global flags, and networking state), while also tightening Bazel disk-cache restoration so fallbacks don’t pull incompatible artifacts.
Changes:
- Update Linux Bazel CI jobs to run tests with
--test_output=errorsand--local_test_jobs=3, and scope disk-cache fallback restores to the same job. - Tag timing-/network-global-state-sensitive Bazel tests as
exclusive, and markbrpc_protobuf_json_unittestaslarge. - Make several tests more parallel-safe by using ephemeral ports (
Start(0, ...)) and by explicitly scoping gflag mutations withGFLAGS_NAMESPACE::FlagSaver.
File summaries
| File | Description |
|---|---|
| test/endpoint_unittest.cpp | Uses an ephemeral server port and validates against the actual bound address to avoid port collisions under parallel test runs. |
| test/BUILD.bazel | Adds exclusive tags for contention-sensitive tests and marks a protobuf JSON test as large for CI-timeout alignment. |
| test/brpc_server_unittest.cpp | Avoids fixed ports and scopes FLAGS_max_body_size mutation to the test via FlagSaver. |
| test/brpc_interceptor_unittest.cpp | Switches to ephemeral server port and connects via listen_address() to prevent conflicts. |
| test/brpc_http_rpc_protocol_unittest.cpp | Switches HTTP expect test to an ephemeral port using server.listen_address(). |
| .github/workflows/ci-linux.yml | Runs Bazel unit tests with bounded local concurrency and error-only output across GCC/Clang Bazel test jobs. |
| .github/actions/setup-build-cache/action.yml | Restricts Bazel disk-cache restore-keys to per-job caches to avoid restoring incompatible archives. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: resolve
Problem Summary:
The Bazel unit-test jobs run independent test binaries serially or without an
explicit concurrency limit. This makes the jobs unnecessarily slow, while
unrestricted concurrency exposes tests that rely on timing, fixed ports, or
process-wide networking state to resource contention.
The Bazel disk-cache fallback can also restore an archive produced by a
different compiler or protobuf configuration. Such an archive consumes cache
transfer time and capacity without producing cache hits.
What is changed and the side effects?
Changed:
--test_output=errorsand--local_test_jobs=3.state exclusively, while keeping independent test binaries parallel.
message tests to avoid conflicts with other processes.
its existing runtime under CI contention.
same CI job.
Side effects:
test concurrency to avoid overloading GitHub-hosted runners.
unchanged; this updates CI scheduling and test robustness.
Check List: