Skip to content
Open
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
4 changes: 3 additions & 1 deletion .github/actions/install-essential-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ runs:
steps:
- run: ulimit -c unlimited -S && sudo bash -c "echo 'core.%e.%p' > /proc/sys/kernel/core_pattern"
shell: bash
- run: sudo apt-get update && sudo apt-get install -y git g++ make libssl-dev libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev
- run: sudo apt-get update && sudo apt-get install -y git g++ make libssl-dev libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev redis-server mysql-server
shell: bash
- run: redis-server --version && mysqld --version
shell: bash
18 changes: 16 additions & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Install redis-server/mysql-server so the integration tests that fork a
# real server (e.g. brpc_redis_unittest) actually run under bazel instead
# of skipping. Same shared action the make-based unittest jobs use.
- uses: ./.github/actions/install-essential-dependencies
- run: bazel test //test/...

gcc-compile-with-bazel-all-options:
Expand Down Expand Up @@ -160,6 +164,9 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Install redis-server/mysql-server so the forked-server integration tests
# actually run under bazel (see gcc-unittest-with-bazel).
- uses: ./.github/actions/install-essential-dependencies
- run: |
bazel test --test_output=streamed \
--action_env=CC=clang \
Expand Down Expand Up @@ -217,7 +224,11 @@ jobs:
- name: run tests
run: |
cd test
sh ./run_tests.sh
# The redis integration tests (sanity/keys_with_spaces/incr_and_decr/by_components/auth)
# fork a real redis-server and connect after a fixed 50ms wait; under ASan redis starts
# too slowly, so they flake here (connection refused). Skip just those under ASan; the
# redis codec/server tests still run, and the full suite runs in clang-unittest.
GTEST_FILTER='-RedisTest.sanity:RedisTest.keys_with_spaces:RedisTest.incr_and_decr:RedisTest.by_components:RedisTest.auth' sh ./run_tests.sh

clang-unittest-bazel-with-babylon-and-new-pb:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do clang-unittest-bazel-with-babylon-and-new-pb, clang-unittest-with-bazel and gcc-unittest-with-bazel also require Redis server to be installed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good question. gcc-unittest-with-bazel, clang-unittest-with-bazel and clang-unittest-bazel-with-babylon-and-new-pb don't use the install-essential-dependencies action, so this change doesn't install Redis/MySQL in them. The Redis client tests there continue to self-skip when redis-server is absent — the same behaviour as before this PR. If you'd like those bazel jobs to exercise the live-server tests as well, I'm happy to add it in a follow-up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's necessary.

runs-on: ubuntu-22.04
Expand All @@ -229,14 +240,17 @@ jobs:
USE_BAZEL_VERSION: "8.3.1"
steps:
- uses: actions/checkout@v2
# Install redis-server/mysql-server so the forked-server integration tests
# actually run under bazel (see gcc-unittest-with-bazel).
- uses: ./.github/actions/install-essential-dependencies
- name: Override protobuf version for testing
run: |
sed -i -E "s/(bazel_dep\(name = ['\"]protobuf['\"], version = ['\"])[^'\"]+/\1${TEST_PROTOBUF_VERSION}/" MODULE.bazel
echo "After override:"
grep -E "bazel_dep\(name = ['\"]protobuf['\"]" MODULE.bazel
grep -qE "bazel_dep\(name = ['\"]protobuf['\"], version = ['\"]${TEST_PROTOBUF_VERSION}['\"]" MODULE.bazel \
|| { echo "ERROR: failed to override protobuf version in MODULE.bazel to ${TEST_PROTOBUF_VERSION}"; exit 1; }
- run: |
- run: |
bazel test --action_env=CC=clang \
--define with_babylon_counter=true \
--define with_babylon_counter=true \
Expand Down
8 changes: 8 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ generate_unittests(
data = [
":test_runfiles_root_data",
],
# brpc_redis_unittest forks a real redis-server located via PATH. Tag it
# "external" so bazel always re-runs it (never serves a cached pass that
# actually skipped) and "local" so it runs outside the sandbox, where the
# apt-installed redis-server is visible and loopback works. The CI bazel
# jobs install redis-server via the install-essential-dependencies action.
per_test_tags = {
"brpc_redis_unittest.cpp": ["external", "local"],
},
)

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

def generate_unittests(name, srcs, deps, copts, linkopts = [], data = []):
def generate_unittests(name, srcs, deps, copts, linkopts = [], data = [], per_test_tags = {}):
tests = []
for s in srcs:
ut_name = s.replace(".cpp", "")
Expand All @@ -24,6 +24,11 @@ def generate_unittests(name, srcs, deps, copts, linkopts = [], data = []):
deps = deps,
linkopts = linkopts,
data = data,
# Integration tests that fork a real server binary (e.g. redis-server)
# need extra tags: "external" forces a real run instead of a cached
# 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, []),
)
tests.append(":" + ut_name)

Expand Down