fix(coverage): mount .gcno files into ProxySQL container so gcov runtime resolves daemon coverage

Daemon-side coverage has been silently empty since gcov was first
wired up. The TAP cascade hits the right code paths and the tester
calls `PROXYSQL GCOV DUMP` after every test (proxysql-tester.py
line 880), and proxysql writes 226 .gcda files into /gcov. But every
single one of them lands with empty metadata:

  [error]: Missing 'current_working_directory' for data file:
  {'data_file': '/gcov/obj/MySQL_Query_Processor.gcda', 'files': []}
  [error]: Missing 'current_working_directory' for data file:
  {'data_file': '/gcov/obj/MySQL_Session.gcda',         'files': []}
  ... (x226)

fastcov gives up on every one of them. The resulting .info file has
zero `lib/*.cpp` SF: entries -- only the ~200 header files indirectly
pulled in by other sources. Codecov then reports
`lib/MySQL_Session.cpp`, `lib/MySQL_Monitor.cpp`,
`lib/MySQL_Protocol.cpp`, `lib/Admin_Handler.cpp`,
`lib/MySQL_Logger.cpp`, `lib/MySQL_PreparedStatement.cpp`,
`lib/ProxySQL_Cluster.cpp` and dozens more at **0% coverage** even
though they're the hottest paths in the daemon.

Root cause: the proxysql binary is built inside the build container
with the source bind-mounted at /opt/proxysql/ (docker-compose.yml
`- ./:/opt/proxysql/`). gcc embeds the .gcno paths into the binary as
`/opt/proxysql/{lib,src}/obj/X.gcno`. At runtime, gcov reads those
.gcno files at startup to populate per-translation-unit metadata that
later goes into the .gcda files written by __gcov_dump(). The
proxysql RUNTIME container has the binary but does NOT have the .gcno
files at /opt/proxysql/{lib,src}/obj/ -- the entire 'current_working
_directory' field of every .gcda comes out blank.

Fix: mount the .gcno files from the build cache into the proxysql
container at the compile-time path. The build cache restore already
puts them at ${WORKSPACE}/lib/obj/*.gcno and ${WORKSPACE}/src/obj/
*.gcno on the runner, so this is just two extra `-v ...:ro` mounts
on the docker run in start-proxysql-isolated.bash.

Always-on, gated on .gcno presence: for a non-coverage build, the
WORKSPACE has no .gcno files and the conditional adds nothing.

This is the missing piece behind every prior coverage attempt --
PR #5817 (lib-only unit tests) bypassed it by running tests in the
same container that built proxysql, PR #5818 (legacy-g2 TAP) hit
exactly this bug and quietly uploaded a near-empty .info that
Codecov merged with the unit-test data, masking the issue under a
reasonable-looking 15% aggregate.
feature/ci-codecov-tap-all-groups-callers
Rene Cannao 1 month ago
parent 30b2553398
commit ca90fb540b

@ -151,6 +151,34 @@ if [ "${PROXYSQL_LOAD_GENAI_PLUGIN:-0}" = "1" ]; then
echo ">>> Mounting genai plugin .so into ProxySQL container"
fi
# Mount .gcno files into the proxysql container at the compile-time path
# so gcov's runtime (invoked via the `PROXYSQL GCOV DUMP` admin command
# from the tester) can resolve the .gcda files it writes.
#
# The proxysql binary was compiled inside the build container with the
# source tree bind-mounted at /opt/proxysql/ (docker-compose.yml line:
# `- ./:/opt/proxysql/`), so .gcno paths embedded in the binary point to
# /opt/proxysql/{lib,src}/obj/X.gcno. Without these mounts the runtime
# .gcda files come out with an empty `current_working_directory` field
# and fastcov reports `files: []` for every one of them -- the bug that
# silently zeroed out daemon-side coverage for PR #5818 (only ~5,694
# lines / 27 files from `tap-legacy-g2` were ever real; everything else
# was missing).
#
# Always-on: harmless when the .gcno files aren't present (e.g.
# non-coverage builds) -- the conditional below just doesn't add
# anything to GCOV_MOUNTS.
GCOV_MOUNTS=""
if compgen -G "${WORKSPACE}/lib/obj/*.gcno" >/dev/null; then
GCOV_MOUNTS="${GCOV_MOUNTS} -v ${WORKSPACE}/lib/obj:/opt/proxysql/lib/obj:ro"
fi
if compgen -G "${WORKSPACE}/src/obj/*.gcno" >/dev/null; then
GCOV_MOUNTS="${GCOV_MOUNTS} -v ${WORKSPACE}/src/obj:/opt/proxysql/src/obj:ro"
fi
if [ -n "${GCOV_MOUNTS}" ]; then
echo ">>> Mounting .gcno files into ProxySQL container for gcov runtime resolution"
fi
# Simulator-backed TAP groups (aurora-sim, galera-sim, ...) export a
# CLUSTER_SIM_HOST_FILE pointing at a plain "hostname ip" list. Inject each
# entry as --add-host so ProxySQL's container /etc/hosts resolves the simulated
@ -177,6 +205,7 @@ docker run -d \
-v "${COVERAGE_DATA_DIR}:/gcov" \
${MYSQLX_PLUGIN_MOUNT} \
${GENAI_PLUGIN_MOUNT} \
${GCOV_MOUNTS} \
-e GCOV_PREFIX="/gcov" \
-e GCOV_PREFIX_STRIP="3" \
proxysql-ci-base:latest \

Loading…
Cancel
Save