From cbf79cdc8e2be93c1c6fd62013073cb917efbc3b Mon Sep 17 00:00:00 2001 From: Zack Winter <3457246+zackwintermdb@users.noreply.github.com> Date: Wed, 28 Jan 2026 10:29:22 -0800 Subject: [PATCH] SERVER-118037: Hydrate Unit Test Cache (#47094) GitOrigin-RevId: a11242a482722f6114d3c3f0b57cf6c263b8123f --- .bazelrc | 1 + .../tasks/compile_tasks.yml | 22 +++++++++++++++++++ evergreen/bazel_compile.sh | 7 +++++- evergreen/bazel_test.sh | 7 +++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 36b50af3bfd..21ae003da95 100644 --- a/.bazelrc +++ b/.bazelrc @@ -442,6 +442,7 @@ common:remote_unittest --cache_test_results=auto common:remote_unittest --dev_stacktrace=False common:remote_unittest --run_under=//bazel:test_wrapper common:remote_unittest --test_timeout=660 +common:remote_unittest --define GIT_COMMIT_HASH=nogitversion test:remote_unittest --test_tag_filters=mongo_unittest,-intermediate_debug,-incompatible_with_bazel_remote_test # Coverage diff --git a/etc/evergreen_yml_components/tasks/compile_tasks.yml b/etc/evergreen_yml_components/tasks/compile_tasks.yml index ecbcdcea8d3..51b6a4cf7cc 100644 --- a/etc/evergreen_yml_components/tasks/compile_tasks.yml +++ b/etc/evergreen_yml_components/tasks/compile_tasks.yml @@ -300,6 +300,27 @@ tasks: --keep_going --build_tag_filters=${bazel_filters_for_cache_hydration} + - name: hydrate_bazel_unit_tests + tags: + [ + "assigned_to_jira_team_devprod_build", + "bazel_cache_hydration", + "auxiliary", + ] + depends_on: + - name: version_expansions_gen + variant: generate-tasks-for-version + commands: + - func: "bazel test" + vars: + compiling_for_test: true + test_timeout_sec: 660 # Allow extra 60s for coredump on abort + no_mongo_version: true + targets: //src/mongo/... + bazel_args: >- + --config=remote_unittest + --keep_going + - name: run_bazel_clang_tidy tags: [ @@ -1314,6 +1335,7 @@ task_groups: - hydrate_bazel_profile_dbg - hydrate_bazel_profile_dbg_aubsan - hydrate_bazel_profile_dbg_tsan + - hydrate_bazel_unit_tests - <<: *compile_task_group_template name: hydrate_all_headers_TG diff --git a/evergreen/bazel_compile.sh b/evergreen/bazel_compile.sh index cdbfe389359..bb5e6229d14 100755 --- a/evergreen/bazel_compile.sh +++ b/evergreen/bazel_compile.sh @@ -117,8 +117,13 @@ LOCAL_ARG="$(bazel_evergreen_shutils::maybe_release_flag "$LOCAL_ARG")" # Ensure server is up and print PID bazel_evergreen_shutils::ensure_server_and_print_pid "$BAZEL_BINARY" +MONGO_VERSION_ARG="--define=MONGO_VERSION=${version}" +if [[ -n "${no_mongo_version}" ]]; then + MONGO_VERSION_ARG="" +fi + # Build flags line -ALL_FLAGS="--verbose_failures ${LOCAL_ARG} --define=MONGO_VERSION=${version} ${bazel_args:-} ${bazel_compile_flags:-} ${task_compile_flags:-} ${patch_compile_flags:-}" +ALL_FLAGS="--verbose_failures ${LOCAL_ARG} ${MONGO_VERSION_ARG} ${bazel_args:-} ${bazel_compile_flags:-} ${task_compile_flags:-} ${patch_compile_flags:-}" echo "${ALL_FLAGS}" >.bazel_build_flags # Save the entire bazel build invocation to attach to the task for re-running locally diff --git a/evergreen/bazel_test.sh b/evergreen/bazel_test.sh index 31a4c71b4f1..6dba17bdd1f 100644 --- a/evergreen/bazel_test.sh +++ b/evergreen/bazel_test.sh @@ -34,8 +34,13 @@ LOCAL_ARG="$(bazel_evergreen_shutils::maybe_release_flag "$LOCAL_ARG")" # Possibly scale test timeout and append to bazel_args bazel_evergreen_shutils::maybe_scale_test_timeout_and_append +MONGO_VERSION_ARG="--define=MONGO_VERSION=${version}" +if [[ -n "${no_mongo_version}" ]]; then + MONGO_VERSION_ARG="" +fi + # Build the shared flags and persist the --config subset -ALL_FLAGS="--verbose_failures ${LOCAL_ARG} --define=MONGO_VERSION=${version} ${bazel_args:-} ${bazel_compile_flags:-} ${task_compile_flags:-} ${patch_compile_flags:-}" +ALL_FLAGS="--verbose_failures ${LOCAL_ARG} ${MONGO_VERSION_ARG} ${bazel_args:-} ${bazel_compile_flags:-} ${task_compile_flags:-} ${patch_compile_flags:-}" echo "${ALL_FLAGS}" >.bazel_build_flags # to capture exit codes