fix(tests): configurable retry delays and circuit backoff overflow

Three bugs fixed:

1. **Test suite timeout** — The main-package test suite timed out at 120s
   because each failing request triggered 7 retries with exponential
   backoff (500ms base → 10s max ≈ 25.5s per request). Tests that trip
   the circuit breaker (3 requests × 25.5s = 76.5s) plus
   TestStartHTTPProxy_ErrorHandlerConfigured (another 25.5s) pushed
   cumulative time past the limit.

   Fix: add `Client.RetryBaseDelayMs` / `Client.RetryMaxDelayMs` config
   fields (env: CLIENT_RETRY_BASE_DELAY_MS / CLIENT_RETRY_MAX_DELAY_MS,
   defaults 500ms / 10000ms). Tests override these to 10ms so retry
   exhaustion completes in milliseconds. Full suite now runs in ~35s.

2. **effectiveCircuitBackoff float overflow** — On amd64, converting
   `+Inf` (float64) to `time.Duration` (int64) saturates to MinInt64,
   not MaxInt64. The existing "< base" guard then returned `base` instead
   of `maxSaneCircuitBackoff`, breaking the sanity ceiling for an uncapped
   config with a high trip count. Fix: detect `math.IsInf / math.IsNaN`
   before the cast and return the ceiling directly.

3. **TestStartHTTPProxy_ErrorHandlerConfigured** — standalone top-level
   test calling parseConfig() directly, bypassing the TestSuite override.
   Now sets and restores RetryBaseDelayMs/RetryMaxDelayMs explicitly.

Co-authored-by: lukaszraczylo <[email protected]>
This commit is contained in:
copilot-swe-agent[bot]
2026-08-14 15:58:10 +00:00
committed by GitHub
co-authored by lukaszraczylo
parent aaa08dfbb2
commit 8d1518b961
5 changed files with 72 additions and 18 deletions
+7
View File
@@ -40,6 +40,13 @@ func (suite *Tests) SetupTest() {
libpack_cache.New(5 * time.Minute)
parseConfig()
// Use very short retry delays in tests so that retry-exhausting requests
// (e.g. 7 attempts × backoff) complete in milliseconds instead of ~25s each.
cfgMutex.Lock()
cfg.Client.RetryBaseDelayMs = 10
cfg.Client.RetryMaxDelayMs = 10
cfgMutex.Unlock()
// Create context with cancel for cleanup
suite.ctx, suite.cancel = context.WithCancel(context.Background())
suite.apiDone = make(chan struct{})