8000 ci: Go code coverage from unit and e2e tests, reported to coveralls.io by Slach · Pull Request #2183 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

ci: Go code coverage from unit and e2e tests, reported to coveralls.io - #2183

Open
Slach wants to merge 3 commits into
0.28.0from
operator-coverage
Open

Slach wants to merge 3 commits into
0.28.0from
operator-coverage

Conversation

@Slach
@Slach Slach commented Dec 2, 2026 •
Copy link
Copy Markdown
Collaborator

What

Collect Go code coverage from both the unit tests and the e2e suite and report the merged result to coveralls.io. Modeled on clickhouse-backup's setup: -cover binaries, GOCOVERDIR, go tool covdata, and parallel Coveralls jobs.

How

  • Instrumented build: GO_COVER=yes (env, or the Docker build-arg GO_COVER) builds operator and metrics-exporter with -cover -covermode=atomic. The build scripts now build the cmd/* package instead of main.go, so profiles carry module import paths.
  • Counter flushing (pkg/util/coverage): Go writes coverage only on a clean exit, and e2e tests kill operator pods all the time. So instrumented binaries with GOCOVERDIR set flush counters every 10s (WriteCountersDir + ClearCounters, so the files add up exactly) and once more on shutdown. Without -cover or GOCOVERDIR this is a no-op.
  • e2e: E2E_COVERAGE=yes injects a node hostPath with a per-pod GOCOVERDIR into the local-build operator Deployment. Release images installed by the upgrade tests are left alone.
    • tests/e2e/coverage.sh reset prepares the hostPath, and collect fetches it and merges it into a text profile.
    • Binaries that the tests run directly on the host (the FIPS host-run checks) get GOCOVERDIR too. This avoids the warning: GOCOVERDIR not set line in their output, and their coverage is collected as well.
  • Local report: dev/run_coverage_report.sh prints the unit, e2e and combined totals.
  • CI (run_tests.yaml):
    • Unit and e2e profiles are uploaded as parallel Coveralls jobs (flag-name unit / e2e).
    • A separate coverage job merges them with parallel-finished.
    • Every Coveralls step uses fail-on-error: false.
  • README: Coveralls badge.

Local results (orbstack, POOL_SIZE=16)

coverage
unit 51.6%
e2e 71.8%
combined 77.2%
  • Unit tests (-race): green.
  • e2e: 126/130 scenarios passed. The 4 failures (test_030001, test_030011, test_030015, test_030017) are FIPS host-run tests. They execute the extracted linux binaries on the host, which cannot work on macOS (Exec format error, no readelf), so they are expected to pass on the Linux runner.

Needs attention

  • Coveralls already accepts the uploads (the first unit upload created https://coveralls.io/builds/83422972). Commit statuses / PR comments from Coveralls need a repo admin to sign in to coveralls.io with GitHub and click Claim on the repo settings page.
  • run_tests now also runs on push to master, so the badge gets the default branch's coverage. With empty inputs a push run behaves like a PR run (all tests, with retries).
  • coverage.sh uses busybox:1.36 for its helper pod, which minikube in CI pulls from Docker Hub.

🤖 Generated with Claude Code

Slach and others added 3 commits December 2, 2026 14:39
…alls.io

- pkg/util/coverage: binaries built with -cover flush counters to GOCOVERDIR
  every 10s (WriteCountersDir + ClearCounters) and on shutdown, since operator
  and metrics-exporter pods are often killed by e2e tests.
- GO_COVER=yes (env / docker build-arg) builds with -cover -covermode=atomic;
  build the cmd package instead of main.go so profiles carry module paths.
- E2E_COVERAGE=yes injects a node hostPath + per-pod GOCOVERDIR into the local
  operator Deployment; tests/e2e/coverage.sh reset|collect fetches and merges it.
  Host-run binaries get GOCOVERDIR too (no "GOCOVERDIR not set" warning).
- dev/run_coverage_report.sh prints unit, e2e and combined totals locally.
- run_tests.yaml uploads unit and e2e profiles as parallel coveralls jobs and
  finishes the build in a separate job; README gets the coveralls badge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er coverage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coveralls
coveralls commented Dec 2, 2026 •
Copy link
Copy Markdown
A4D7

Coverage Report for CI Build 46856494850

Warning

No base build found for commit 9d4a636 on 0.28.0.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 76.294%

Details

  • Patch coverage: 12 uncovered changes across 1 file (27 of 39 lines covered, 69.23%).

Uncovered Changes

File Changed Covered %
pkg/util/coverage/coverage.go 33 21 63.64%
Total (3 files) 39 27 69.23%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 43226
Covered Lines: 32979
Line Coverage: 76.29%
Coverage Strength: 103965.91 hits per line

💛 - Coveralls

@Slach
Slach requested review from alex-zaitsev and denisok December 2, 2026 10:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0