test(coverage): drive pool, telemetry, ctxkeys to >=95%#21
Closed
mastermanas805 wants to merge 1 commit into
Closed
test(coverage): drive pool, telemetry, ctxkeys to >=95%#21mastermanas805 wants to merge 1 commit into
mastermanas805 wants to merge 1 commit into
Conversation
Coverage after:
- internal/pool 99.3% (was 26.3%)
- internal/telemetry 100% (was 80.4%)
- internal/ctxkeys [no statements; const-only]
pool/
Adds manager_db_test.go gated on TEST_DATABASE_URL. Each test uses a
per-test schema (search_path=pooltest_*) so a shared CI postgres isn't
polluted across test/suite runs. Mock backends mirror the production
Backend interfaces (compile-time _ = assertions) and run zero-latency
so the integration tests stay fast.
Covered:
Start, Shutdown, migrate (incl. idempotency + exec-failure), Claim
(empty + hit + decrypt-error + scan-error), Stats (empty + populated
+ query-failure), fillPool (top-up + at-target + target=0 +
count-failure), provisionOneItem (success + backend-error +
insert-failure), provisionItemsConcurrently (backend-failure logged
+ needed<=0), provisionOneItemBackend (all 4 happy paths + unknown
type + encrypt-error per type), triggerRefill (coalesce-when-full),
run (ticker arm + refillCh arm), NewWithConfig (factory).
One tiny production-code change: extract `runTickInterval` as a
package-level var so a unit test can shrink it from 30s -> 50ms to
exercise the ticker arm of the run select without a 30s sleep.
Production behaviour unchanged.
telemetry/
Adds NR-license-header path, sentinel-key collapse, plaintext endpoint,
OTEL_SERVICE_NAME override, :443 TLS, http:// scheme forces plaintext,
whitespace endpoint, exporter-construction failure (NUL in endpoint
triggers url.Parse error), shutdown-with-cancelled-ctx, and
resource.New failure via an injected `newResource` var (the only
feasible way to exercise the defensive fallback without modifying OTel
SDK internals).
ctxkeys/
Round-trip, empty-means-anonymous, no-string-collision, nested
override, and iota-stability guard. Package has no statements so
coverage is vacuously 100%; tests guard the public contract.
ci/
coverage.yml gains a postgres:16-alpine service container + sets
TEST_DATABASE_URL. The pool integration tests skip cleanly when the
var is unset so contributors without a local postgres still see green
`go test ./...`. Same pattern as api/coverage.yml and
worker/coverage.yml. Comment block updated to reflect the new policy.
Verified: gate green, race clean, no flakes across 3 consecutive runs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
Author
|
Superseded by #27 (pool+root+circuit+telemetry to ≥95%; merged). |
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.
Summary
internal/poolfrom 26.3% -> 99.3%,internal/telemetryfrom 80.4% -> 100%,internal/ctxkeysto vacuously 100% (const-only package).coverage.ymlso CI exercises the full surface; tests skip cleanly when TEST_DATABASE_URL is unset.Production-code changes (minimal)
pool.runTickIntervalextracted as a package-privatevarso a unit test can shrink the maintenance-loop tick from 30s -> 50ms. Production cadence unchanged.telemetry.newResourceis a package-privatevaraliasingresource.New. Lets a test force the defensiveresource_failedfallback without touching OTel SDK internals.Test plan
make gategreen (build + vet +go test ./... -short -count=1)go test -race -count=1clean on all three packagesgo test -count=1x3 — no flakes🤖 Generated with Claude Code