perf(#6060): make CreateWithRetry sleep injectable for tests - #6066
Conversation
Add an exported RetrySleep variable (defaulting to time.Sleep) to the sandbox package and use it in CreateWithRetry's backoff loop. Tests can replace it with a no-op to skip real delays. Update usePreScriptStub in prescript_run_test.go to override RetrySleep, eliminating ~15s of real sleep from the two affected tests (TestRunAgent_NoPreScript_StillRelaysSkippedFalse and TestRunAgent_PreScriptNoSkip_ProceedsToSandboxAndRelaysFalse). Note: pre-commit could not run in the sandbox (network error during hook environment setup). The post-script runs it authoritatively. Closes #6060
|
🤖 Finished Review · ✅ Success · Started 7:55 PM UTC · Completed 8:06 PM UTC Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Looks good to me Previous runReviewFindingsLow
Previous run (2)ReviewFindingsLow
Labels: PR modifies sandbox retry infrastructure (internal/sandbox/sandbox.go) |
codecov/patch was failing because the RetrySleep injection point added in this PR wasn't exercised by any test in the sandbox package itself (the cli package test that uses it doesn't count toward sandbox.go's coverage since go test ./... doesn't use -coverpkg=./...). Add a test that drives CreateWithRetry through multiple failed attempts and asserts on the backoff durations passed to RetrySleep. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ralph Bean <rbean@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 8:47 PM UTC · Completed 8:58 PM UTC Commit: |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 10:26 PM UTC · Completed 10:35 PM UTC Commit: |
Rename the exported injectable var from RetrySleep to RetrySleepFn to match the established XxxFn suffix convention used elsewhere in the codebase (BuildWASMFn, CopyWASMExecFn, WranglerWhoamiFn). Simplify the doc comment to use the "Override in tests to..." pattern consistent with those declarations. Addresses review feedback on #6066
🔧 Fix agent — iteration 1 (human-triggered)Addressed 2 review findings: renamed RetrySleep to RetrySleepFn to match the codebase XxxFn naming convention (ralphbean nit), and simplified the doc comment to match the established 'Override in tests to...' pattern (bot finding). All tests pass. Fixed (2):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 10:37 PM UTC · Completed 10:47 PM UTC Commit: |
|
🤖 Finished Retro · ✅ Success · Started 5:38 PM UTC · Completed 5:55 PM UTC Commit: |
Retro: PR #6066 — make CreateWithRetry sleep injectable for testsPipeline: Issue #6060 → triage (4 min) → code (12 min) → review → human review → Timeline
What went well
What the human caught that the agent missedThe review agent identified The root cause is that the Existing-issue evidence (proposals skipped)
Autonomy readinessThe review agent's findings fully covered the doc-comment style issue and correctly filtered a false positive — solid performance. The single human finding was a non-blocking naming nit. If the Proposals filed
|
Summary
RetrySleepvariable tointernal/sandbox/sandbox.go(defaults totime.Sleep) and replace the hardcodedtime.Sleep(backoff)call inCreateWithRetrywithRetrySleep(backoff)sandbox.RetrySleepwith a no-op inusePreScriptStub(test helper ininternal/cli/prescript_run_test.go), so the two tests that exercise the sandbox-creation failure/retry path no longer sleep for ~15s eachTestRunAgent_NoPreScript_StillRelaysSkippedFalseandTestRunAgent_PreScriptNoSkip_ProceedsToSandboxAndRelaysFalse) now complete in < 0.1sTest plan
go test ./internal/sandbox/... -race— all sandbox tests passgo test ./internal/cli/... -run 'TestRunAgent_PreScript|TestRunAgent_NoPreScript|TestRunPreScript' -race— all pre-script tests passgo vet ./internal/sandbox/... ./internal/cli/...— no issuesCloses #6060
Post-script verification
agent/6060-sandbox-retry-sleep)483ad9bd31407310940d21003a6cfe1b6b52b5c8..HEAD)