diff --git a/.github/actions/install-essential-dependencies/action.yml b/.github/actions/install-essential-dependencies/action.yml index d6c5da96c1..f64b74ee16 100644 --- a/.github/actions/install-essential-dependencies/action.yml +++ b/.github/actions/install-essential-dependencies/action.yml @@ -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 diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 8a36af6024..2bbadae767 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -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: @@ -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 \ @@ -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: runs-on: ubuntu-22.04 @@ -229,6 +240,9 @@ 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 @@ -236,7 +250,7 @@ jobs: 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 \ diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 18af200dd5..d536197aee 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -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( diff --git a/test/generate_unittests.bzl b/test/generate_unittests.bzl index 4b37dd6fbc..8cfec78a71 100644 --- a/test/generate_unittests.bzl +++ b/test/generate_unittests.bzl @@ -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", "") @@ -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)