test(metering): e2e usage invariants + integration-job coverage upload - #55
Merged
Conversation
The integration job ran mix test bare, so integration/external-only modules (Hyper.Metering.Usage among them) uploaded zero coverage. Wrap the run in coveralls.json and upload under a new 'integration' Codecov flag; Codecov merges flags into the combined report.
stop_image_vm must leave a positive Usage.total: the Meter stops first and flushes before the cgroup is removed. Also pins row well-formedness (start < end, cpu_usec > 0, node attribution) and that total/3 over a range covering all window_starts reproduces the lifetime total.
A recreated cgroup resets cpu.stat; if the accumulator went negative instead of re-baselining, every flush would be refused and total/1 would stay nil. Assert a positive lifetime total after crash+stop.
Pins the moduledoc's never-double-count claim: half-open total/3 ranges whose cuts land exactly on window_starts must sum to total/1.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
A periodic flush landing before the SIGKILL made the bare positive-total assertion pass even with a broken post-crash re-baseline. Snapshot the total before stop and require the teardown flush to strictly grow it.
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.
Codecov reported zero coverage on
lib/hyper/metering/usage.ex. The gap was in coverage collection, not tests:test/hyper/metering/usage_test.exsalready runs in CI'sintegrationjob, but only theelixirjob uploaded coverage — and it excludes:external/:integration.Changes
integrationjob now runsmix coveralls.json --only integration --only externaland uploadscover/excoveralls.jsonunder a newintegrationCodecov flag (registered incodecov.yml; Codecov merges flags into the combined report).stop_image_vm/1,Usage.total/1is non-nil and positive (proves the Meter-last-child teardown flush end-to-end); everyvm_usagerow is well-formed (window_start < window_end,cpu_usec > 0, node attribution);total/3over a half-open range covering allwindow_starts reproduces the lifetime total.Usage.total/1is positive — if the accumulator went negative on the recreated cgroup's counter reset instead of re-baselining, every flush would be refused and the total would stay nil.total/3ranges with cuts exactly ONwindow_starts partition the lifetime total (the never-double-count billing claim; mutation-verified — both<=/<and>=/>boundary mutants fail the test).Coverage triage (per CLAUDE.md)
Declined at test level: the
rescueclause inUsage.insert/1(Postgrex.Error/DBConnection.ConnectionError→{:error, e}). Exercising it requires injecting a Postgres connection fault into the shared app Repo — fault-injection infrastructure disproportionate to two lines. The consumer-side contract (the Meter keeps accrued time and retries when the sink errors) is what protects billing.