feat(coverage): static test-coverage estimate for last9-otel-setup.sh#24
Open
prathamesh-sonpatki wants to merge 4 commits into
Open
feat(coverage): static test-coverage estimate for last9-otel-setup.sh#24prathamesh-sonpatki wants to merge 4 commits into
prathamesh-sonpatki wants to merge 4 commits into
Conversation
…p.sh Runtime line coverage (kcov) is unusable here: kcov's bash instrumentation is Linux-only and does not propagate to the grandchild `bash "$SCRIPT"` processes the test suites spawn (confirmed 0 lines even on ubuntu under ptrace; kcov was also dropped from ubuntu-24.04 repos). Instead, estimate coverage statically. tests/coverage-report.py builds the script's function call graph (command- position matching, with strings and comments stripped so names inside echo/log text are not counted as calls), seeds it with the functions the test suites actually drive — the always-run prelude, the install/monitoring/events handlers exercised by the layer-2 e2e modes, and every function named in the test files — takes the transitive closure, and reports function-level and line-weighted coverage plus the untested list. main() is counted as executed but not traversed, so its untested uninstall and help/examples branches are not wrongly credited. Current estimate: 84% of functions, 78% of lines. Untested: the four uninstall paths, tolerations-on-monitoring, operator detection, deployment-mode switch, and the no-arg examples screen. - run.sh gains a `coverage` entrypoint (`--min N` available for an optional gate) - integration.yml gains a report-only `coverage` job that writes the % and the untested list to the GitHub job summary - tests/test_coverage_report.py guards the call-graph model Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ines Adds characterization tests for every function the coverage analyzer flagged untested, raising last9-otel-setup.sh coverage from 84%/78% to 100%/100%. - tests/integration/uninstall.bats: drives all four uninstall paths (uninstall_opentelemetry/_all/_last9_monitoring/_events_agent) through the entry point with stubbed helm/kubectl/sleep; `yes | tr -d '\n'` answers the interactive y/N prompts. Covers the real uninstall branch, the cancel branch, and the not-installed branch. - tests/unit.bats: update_deployment_mode (daemonset→deployment, logsCollection off, filelog commented + missing-file error), apply_tolerations_to_monitoring_values (awk/sed fallback so no yq needed in CI, incl. default node-exporter tolerations), detect_existing_prometheus_operator (found/not-found/own-namespace), show_examples. - helm stub: SIMULATE_INSTALLED makes `helm list` report releases so uninstall takes the real path; new no-op sleep stub keeps uninstall tests fast. - coverage-report.py: count uninstall.bats; fix the call-graph matcher to treat `if/elif/while/until <fn>` as a call (it missed `if detect_existing_prometheus_operator`). Analyzer now surfaces two genuinely dead functions (defined, no caller anywhere in the script): apply_tolerations_to_monitoring_values and detect_host_platform. The CI summary now lists both untested and dead-code functions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ov-integration-coverage
Main added tests/test_install_operator.py and new script functions; include the new test file so its coverage is credited. last9-otel-setup.sh stays at 100% function / 100% line coverage (now 2772 lines, 22 directly-tested); apply_tolerations_to_monitoring_values and detect_host_platform remain dead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a real, repeatable test-coverage estimate for
last9-otel-setup.sh(the 2945-line, 50-function central script), surfaced locally and in CI.Closes FDE-209.
Why not kcov
The original plan was kcov runtime line coverage. Proven unworkable during implementation:
ubuntu-latest)bash "$SCRIPT"the test suites spawnWhat shipped instead — static call-graph coverage
tests/coverage-report.py— builds the function call graph (command-position matching; strings/comments stripped so names insideecho/logtext aren't counted as calls), seeds from what the tests actually drive (always-run prelude + install/monitoring/events handlers exercised by the layer-2 e2e modes + every function named in the test files), takes the transitive closure.mainis counted as executed but not traversed, so its untested uninstall and help/examples branches aren't wrongly credited.tests/test_coverage_report.py— 10 guard tests for the model.run.sh coverage— local entrypoint (--min Nfor an optional gate).integration.yml— report-onlycoveragejob writing the % + untested list to the job summary.Result
84% of functions / 78% of lines (42/50). Untested: the four uninstall paths (303 lines), tolerations-on-monitoring, operator detection, deployment-mode switch, and the no-arg examples screen.
Verification
analyzer self-tests 10/10 · bats 38/38 · python adopt tests pass · no regressions.
🤖 Generated with Claude Code