Skip to content

test(provisioner): real-backend gRPC round-trips for Mongo/Queue/Storage (Wave 4)#47

Merged
mastermanas805 merged 2 commits into
masterfrom
test/server-mongo-queue-storage-roundtrip
Jun 4, 2026
Merged

test(provisioner): real-backend gRPC round-trips for Mongo/Queue/Storage (Wave 4)#47
mastermanas805 merged 2 commits into
masterfrom
test/server-mongo-queue-storage-roundtrip

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

What

Closes the remaining cells of the provisioner gRPC × backend matrix (INTEGRATION-COVERAGE-PLAN §2.3 / Wave 4). Postgres + Redis server-layer round-trips already shipped (#45, #46); this PR adds the real-backend Provision → assert artifact → Deprovision → assert-gone lifecycle for the three remaining backends — Mongo, Queue (NATS), Storage (MinIO/S3) — all driven through the genuine gRPC handlers (ProvisionResource/DeprovisionResource/GetStorageBytes/RegradeResource), not fakes.

Inventory (before → after)

RPC × Backend Before After
Provision/Deprovision/Regrade × postgres EXISTS (#45/#46) EXISTS
Provision/Deprovision × redis EXISTS (#45/#46) EXISTS
Provision/StorageBytes/Deprovision × mongo GAP (fakes only) EXISTS — real createUser/dropUser/dropDatabase + dbStats
Provision/Deprovision × queue (NATS) GAP EXISTS — real NATS health-check provision, no-op deprovision
GetStorageBytes × storage (MinIO) GAP EXISTS — real PutObject → measured bytes → delete → 0
GetStorageBytes × queue (=0), Regrade skip × mongo/queue untested EXISTS

Provisioner RPC surface = ProvisionResource, DeprovisionResource, GetStorageBytes, RegradeResource (proto provisioner/v1). Storage Provision/Deprovision are intentionally API-side; the provisioner only meters storage.

Tests added (internal/server/server_live_roundtrip_mqs_test.go)

  • Mongo: provision creates usr_/db_ on real MongoDB; GetStorageBytes reads real dbStats (>0 after seeding a 4KB doc); Deprovision runs real dropUser/dropDatabase (truehomie DROP-incident class); 2nd Deprovision is a clean idempotent no-op; Regrade(mongo) asserts the documented skip path.
  • Queue (NATS): provision passes the real :8222/healthz monitor check + returns nats:// URL + subject prefix; GetStorageBytes(queue)=0 (message-metered); Deprovision is the shared-backend no-op, idempotent; Regrade skip.
  • Storage (MinIO): object-walk accounting — empty prefix=0, after a real PutObject=exact byte count (8192), after delete=0.

All env-gated: skip cleanly under go test -short (the deploy gate); run for real when backend env is present.

CI (.github/workflows/coverage.yml)

Added a NATS service container (JetStream + monitor :8222) and a MinIO docker run step (services can't pass server /data), plus env wiring TEST_NATS_HOST / TEST_MINIO_* / CUSTOMER_MONGO_AUTH_URL so the new tests execute. Mongo was already provided.

Integration-only coverage (touched package)

internal/server with all backends wired: 99.2% of statements. The five exercised handlers (provisionMongo, provisionQueue, GetStorageBytes, DeprovisionResource, RegradeResource) are all 100%. Method: go test ./internal/server/ -coverpkg=./internal/server/... -coverprofile=… -count=1 per the PLAN's mechanism C. The ≥80 integration floor is computed after subtracting the lines in the new INTEGRATION-COVERAGE-EXCLUSIONS.md (only k8s dedicated-backend boot wiring + cmd/ entrypoints — genuinely unreachable without a live kube-apiserver / forking the binary).

Verification

Ran all 8 server round-trip tests against real mongo/nats/minio/postgres/redis containers locally — all PASS. Failing-then-passing confirmed (mutated the storage expected-byte literal and the mongo >0 assert → both FAIL as expected, restored → PASS). Gate green: make gate (build + vet + go test ./... -short).

Bug found

None. The destroy/regrade paths for all three backends behaved correctly and idempotently end-to-end (relevant to the truehomie DROP-incident class — no partial-cleanup leak observed).

🤖 Generated with Claude Code

…age (Wave 4)

Closes the remaining cells of the provisioner gRPC × backend matrix
(INTEGRATION-COVERAGE-PLAN §2.3 / Wave 4). Postgres + Redis server-layer
round-trips already shipped (#45, #46); this adds the real-backend
Provision → assert artifact → Deprovision → assert-gone lifecycle for the
three remaining backends, all driven through the genuine gRPC handlers
(breaker wrapping, tier routing, mapError, response shaping):

- Mongo: ProvisionResource creates usr_/db_ on a real MongoDB, GetStorageBytes
  reads real dbStats (>0 after seeding), DeprovisionResource runs the real
  dropUser/dropDatabase (truehomie DROP-incident class), second Deprovision is
  a clean idempotent no-op, and Regrade(mongo) asserts the documented skip path.
- Queue (NATS): ProvisionResource passes the real NATS monitor health check and
  returns nats:// URL + subject prefix, GetStorageBytes(queue)=0 (message-metered),
  Deprovision is the shared-backend no-op, idempotent.
- Storage (MinIO/S3): GetStorageBytes object-walk — empty prefix=0, after a real
  PutObject=exact byte count, after delete=0. (Storage Provision/Deprovision are
  API-side; provisioner only meters.)

All tests env-gated (skip cleanly under `go test -short`, the deploy gate; run
for real when the backend env is present). CI: added NATS service container +
MinIO docker-run step + the TEST_NATS_HOST / TEST_MINIO_* / CUSTOMER_MONGO_AUTH_URL
env wiring to coverage.yml so they execute (mongo was already provided).

Verified locally against real mongo/nats/minio containers: all 8 server
round-trip tests PASS; integration-only coverage for internal/server = 99.2%
(provisionMongo/provisionQueue/GetStorageBytes/DeprovisionResource/RegradeResource
all 100%). No bug found in the destroy/regrade paths. Added
INTEGRATION-COVERAGE-EXCLUSIONS.md documenting the ≥80 floor method + the only
genuinely-unreachable lines (k8s dedicated-backend boot wiring, cmd/ entrypoints).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 enabled auto-merge (squash) June 4, 2026 16:55
The minimal nats:2 image has no wget/curl/nc, so the service-container
--health-cmd ('wget ... :8222/healthz') could never pass — GitHub Actions
marked the container unhealthy and aborted the coverage job before any test
ran (NATS logged 'Server is ready'). Mirror the MinIO pattern: docker run
nats:2 -js -m 8222 + a runner-side curl wait on /healthz. Unblocks #47.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 69ad7f2 into master Jun 4, 2026
12 checks passed
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.

1 participant