perf(#6059): make LiveGCFClient poll delay injectable for tests - #6062
Conversation
Add a pollDelay field to LiveGCFClient that defaults to time.After. WaitForOperation, waitForIAMOperation, and waitForCloudRunOperation now use this injectable function instead of calling time.After directly. Tests inject an immediate-return function to avoid real 5-second (or 2-3 second) sleeps during polling loops. The "completes on second poll" sub-test of TestLiveGCFClient_WaitForOperation previously took ~5s and now completes in <10ms. Three UpdateServiceEnvVars polling tests that exercised waitForCloudRunOperation are also updated. Note: golangci-lint was not available in the sandbox. pre-commit failed due to sandbox network policy (git fetch blocked). go vet and gofmt passed. Closes #6059
|
🤖 Finished Review · ✅ Success · Started 7:51 PM UTC · Completed 8:05 PM UTC Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ReviewFindingsLow
Labels: PR modifies GCF dispatch polling infrastructure and is primarily a test performance improvement |
|
🤖 Finished Retro · ✅ Success · Started 5:58 PM UTC · Completed 6:13 PM UTC Commit: |
Retro: PR #6062 — make LiveGCFClient poll delay injectable for testsTimeline
What went well
Coverage gap — main findingThe code agent introduced a This is already addressed. #2810 ("Code agent should validate patch coverage meets repo threshold before opening PR") was implemented via PR #6138 and closed today (Aug 13). That PR added coverage verification guidance to AGENTS.md, Evidence for existing open issues
No new proposalsAll identified improvement opportunities are tracked by existing open issues. The main finding (missing coverage verification) was addressed by #2810 just today. This retro provides supporting evidence for the existing issues listed above rather than novel findings. |
Summary
pollDelayfield toLiveGCFClient(defaults totime.After) so tests can bypass real sleeps in operation-polling loopsWaitForOperation,waitForIAMOperation, andwaitForCloudRunOperationto use the injectable delayTestLiveGCFClient_WaitForOperation/completes_on_second_polland 3UpdateServiceEnvVarspolling sub-tests)Testing
go test ./internal/dispatch/gcf/... -v— all tests pass (0.164s total, down from ~8s+ with real sleeps)go vet ./internal/dispatch/gcf/...— cleangofmt— cleanscan-secrets— cleanNotes
iamRetryDelayin this packageCloses #6059
Post-script verification
agent/6059-gcf-injectable-poll-delay)483ad9bd31407310940d21003a6cfe1b6b52b5c8..HEAD)