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

Three bugs fixed:

1. Test suite timeout: add Client.RetryBaseDelayMs/RetryMaxDelayMs config
   fields (env CLIENT_RETRY_BASE_DELAY_MS/CLIENT_RETRY_MAX_DELAY_MS,
   defaults 500ms/10s). Tests override to 10ms so retry exhaustion
   completes in ms instead of ~25s per request. Suite runs in ~35s.

2. effectiveCircuitBackoff float overflow: on amd64, float64(+Inf) cast
   to int64 gives MinInt64 not MaxInt64, so the < base guard fired and
   returned base instead of the 24h sanity ceiling. Fix: check
   math.IsInf/math.IsNaN before the cast.

3. TestStartHTTPProxy_ErrorHandlerConfigured bypassed the TestSuite
   retry-delay override; now sets/restores the fields explicitly.

Co-authored-by: lukaszraczylo <[email protected]>
This commit is contained in:
copilot-swe-agent[bot]
2026-08-14 16:00:50 +00:00
committed by GitHub
co-authored by lukaszraczylo
parent 8d1518b961
commit 99f0c844f0
+4 -6
View File
@@ -958,14 +958,12 @@ func performProxyRequestWithEnhancedRetries(c fiber.Ctx, proxyURL string, backen
}
if backendUnhealthy {
// Backend is known to be unhealthy, fail fast
// Circuit breaker should handle this, so reduce retries
// Backend is known to be unhealthy; fail fast with fewer attempts.
// The circuit breaker should handle it, so the max delay matches
// the normal path (avoids invisible behaviour differences).
attempts = 3
initialDelay = time.Duration(baseDelayMs) * time.Millisecond
maxDelayTime = time.Duration(maxDelayMs/2) * time.Millisecond
if maxDelayTime < initialDelay {
maxDelayTime = initialDelay
}
maxDelayTime = time.Duration(maxDelayMs) * time.Millisecond
} else {
// Normal retry strategy
attempts = 7