Repository navigation
test(gcp): keep fixture pricing tests off ambient cloud credentials - #444
Conversation
|
Warning Review limit reached
This review includes 8 billable files and costs up to $2.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 5 minutes for your next included review. View limit details
Comment |
|
@coderabbitai review |
|
Independent review verdict: CLEAN at 96bad3eReviewer: fresh Claude agent (Sonnet, high effort), not the author. The PR body was treated as a claim. Coordinator: claude-cc-reviewer. Blocking findings: none. What was checked:
Non-blocking: detection relies on the production log text "failed to create billing service". A reworded message would silence it, which the body already discloses. Gate:
|
|
CI on
|
Delta review: CLEAN at 21efb76Same independent reviewer, delta
The verdict covers 21efb76. Merge waits on CI being green at this head. (claude-cc-reviewer) |
|
CI is green on head |
Five Cloud SQL, Memorystore and Compute Engine fixture tests reached the real Cloud Billing client, so they used a developer's ambient Application Default Credentials and could send catalog requests. They now inject the existing MockBillingService. A shared TestMain guard in the four billing packages points ADC at a nonexistent file and fails the package if any test still logs a real billing-client creation, since production swallows that error and the test would otherwise pass silently. Closes #406 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gosec G104 flagged the unchecked os.Setenv. If the guard cannot point ADC away from real credentials, running the tests would risk using them, so Run now reports the variable and returns 1 before m.Run. Refs #406 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21efb76 to
1454b9b
Compare
|
Rebased onto main (server-side |
Summary
Some GCP fixture tests built a resource and then ran the real converter into
getOrCreateBillingService. When no billing fake was injected, the Cloud Billing client was built from the developer's ambient Application Default Credentials (ADC), so the test could send real catalog requests. Production logs that client-creation error and swallows it, so these tests still passed.Tests fixed. Five tests now inject the existing
MockBillingServicethroughSetBillingService. Their outcome is unchanged: pricing is reported as unknown, with no network use.TestCloudSQLClient_GetRecommendations_WithMock,TestCloudSQLClient_ConvertGCPRecommendationTestMemorystoreClient_GetRecommendations_WithMockClient,TestMemorystoreClient_ConvertGCPRecommendationTestGetRecommendationsStringMemoryAmountEndToEndThe issue named three of these; the guard below found the other two.
Guard. New package
providers/gcp/internal/billingguard, called from aTestMainin the four billing packages: cloudsql, memorystore, cloudstorage and computeengine.GOOGLE_APPLICATION_CREDENTIALSat a nonexistent file. Bothcloud.google.com/go/authandx/oauth2/googlethen hard-fail and never fall back to the HOME gcloud file or the metadata server.GCE_METADATA_HOSTand pointsCLOUDSDK_CONFIGat a nonexistent directory.Limitations:
Closes #406
Verification (macOS, Go 1.26.9)
(cd providers/gcp && GOWORK=off go test -race -short ./...): all packages ok, both with the normal environment and with ambient credentials disabled.make build,make vet: pass. golangci-lint v2.10.1 (CI pin): 0 issues.gofmtclean.pricing unavailable for redis-1 ... failed to create billing service: open /nonexistent/billingguard-no-adc.json. cloudstorage is clean.54328065.Nothing was run against a real account.
🤖 Generated with Claude Code