Skip to content

Rewrite coverage test execution to use new Go workspace functions#21145

Open
ivanvc wants to merge 1 commit intoetcd-io:mainfrom
ivanvc:update-coverage-tests-to-use-new-functions
Open

Rewrite coverage test execution to use new Go workspace functions#21145
ivanvc wants to merge 1 commit intoetcd-io:mainfrom
ivanvc:update-coverage-tests-to-use-new-functions

Conversation

@ivanvc
Copy link
Member

@ivanvc ivanvc commented Jan 15, 2026

Use the new test functions, simplify generating the coverage files, and
merge at a single level by generating fewer coverage files.

Part of: #18409

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ivanvc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ivanvc
Copy link
Member Author

ivanvc commented Jan 15, 2026

/test pull-etcd-coverage-report

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.05%. Comparing base (0e97115) to head (f0aab33).

Additional details and impacted files

see 276 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #21145      +/-   ##
==========================================
- Coverage   68.47%   68.05%   -0.42%     
==========================================
  Files         429      449      +20     
  Lines       35291    37913    +2622     
==========================================
+ Hits        24165    25802    +1637     
- Misses       9733    10701     +968     
- Partials     1393     1410      +17     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e97115...f0aab33. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ivanvc ivanvc force-pushed the update-coverage-tests-to-use-new-functions branch from db6be2f to 627126c Compare January 31, 2026 01:18
@ivanvc
Copy link
Member Author

ivanvc commented Jan 31, 2026

/test pull-etcd-coverage-report

@ivanvc ivanvc mentioned this pull request Jan 31, 2026
40 tasks
Comment on lines -256 to -262
function not_test_packages {
for m in $(modules); do
if [[ $m =~ .*/etcd/tests/v3 ]]; then continue; fi
if [[ $m =~ .*/etcd/v3 ]]; then continue; fi
echo "${m}/..."
done
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this function was only used by the coverage pass. So, I moved this to inside the coverage function, updating how we get the modules, and removing the confusing name "not_test_packages": https://github.com/etcd-io/etcd/pull/21145/files#diff-52afcc694c0ff8ff253441f42ff44d6b4734fe30ae9070f2ba07a668a10e7baaR296-R303

Comment on lines -308 to -317
function merge_cov {
log_callout "[$(date)] Merging coverage files ..."
coverdir="${1}"
for d in "${coverdir}"/*/; do
d=${d%*/} # remove the trailing "/"
merge_cov_files "${d}" "${d}.coverprofile" &
done
wait
merge_cov_files "${coverdir}" "${coverdir}/all.coverprofile"
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Because of how we execute the go tests now, there's no need to merge multi-directory-level coverage files. In the end, we only have four coverage files: unit, integration, integration v2 store, and integration cluster proxy. So, this is simplified in https://github.com/etcd-io/etcd/pull/21145/files#diff-52afcc694c0ff8ff253441f42ff44d6b4734fe30ae9070f2ba07a668a10e7baaR322

Comment on lines -242 to -254
function pkg_to_coverprofileflag {
local prefix="${1}"
local pkgs="${2}"
local pkgs_normalized
prefix_normalized=$(echo "${prefix}" | tr "./ " "__+")
if [ "${pkgs}" == "./..." ]; then
pkgs_normalized="all"
else
pkgs_normalized=$(echo "${pkgs}" | tr "./ " "__+")
fi
mkdir -p "${coverdir}/${prefix_normalized}"
echo -n "-coverprofile=${coverdir}/${prefix_normalized}/${pkgs_normalized}.coverprofile"
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Refer to: https://github.com/etcd-io/etcd/pull/21145/files#r2761487207. We no longer need this complex function, as we can set the coverprofile filename during test execution.

Comment on lines -362 to +327
sed --in-place -E "s|go.etcd.io/etcd/api/v3/|api/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/client/v3/|client/v3/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/client/pkg/v3|client/pkg/v3/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/etcdctl/v3/|etcdctl/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/etcdutl/v3/|etcdutl/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/pkg/v3/|pkg/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/server/v3/|server/|g" "${cover_out_file}" || true
sed --in-place -E "s|go.etcd.io/etcd/(.*)/v3|\1|g" "${cover_out_file}" || true
Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a simplification (and consolidation) of the sed command.

@ivanvc ivanvc force-pushed the update-coverage-tests-to-use-new-functions branch from 627126c to aa04491 Compare February 3, 2026 23:37
@ivanvc
Copy link
Member Author

ivanvc commented Feb 3, 2026

/retitle Rewrite coverage test execution to use new Go workspace functions

@k8s-ci-robot k8s-ci-robot changed the title [WIP] rewrite coverage test execution Rewrite coverage test execution to use new Go workspace functions Feb 3, 2026
@ivanvc ivanvc marked this pull request as ready for review February 3, 2026 23:38
@ivanvc
Copy link
Member Author

ivanvc commented Feb 4, 2026

Please note that the error in the CI job is due to the cache test flake. Even though it failed, the report is correctly generated, as reported by CodeCov (#21145 (comment))

@ivanvc ivanvc force-pushed the update-coverage-tests-to-use-new-functions branch from aa04491 to d2257af Compare February 6, 2026 20:25
@ivanvc
Copy link
Member Author

ivanvc commented Feb 6, 2026

/retest

Use the new test functions, simplify generating the coverage files and
merge at a single level by generating less coverage files.

Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the update-coverage-tests-to-use-new-functions branch from d2257af to f0aab33 Compare February 8, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants