mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-03 18:55:33 +00:00
1bc46567f5
PveHttpClientLockRetryTests set GuestLockRetry's retry budget via reflection on a private field with no production writer, and scripted two lock failures to land inside a 400ms window. A cold or loaded CI runner's first-attempt JIT and scheduling could burn past 400ms before the second attempt started, failing the test though the retry itself was correct (#134). GuestLockRetry.ExecuteAsync gains an internal overload that takes the inter-attempt delay as a Func<TimeSpan, Task>; the public overload keeps defaulting to Task.Delay, so production behaviour (45s window, budget/4 capped at 2s) is unchanged. PveHttpClient gains a matching internal constructor seam (window, handler, delay), replacing the reflection the tests used for both the private HttpClient and the retry window. Tests now pass a no-op delay, so the retry loop's real elapsed time drops to microseconds and the production 45s window can never be exhausted by runner speed. Two tests pin that production still waits for real: one records the delay invocations through the internal seam and asserts the computed interval, the other drives the public overload with a small window and asserts wall-clock time actually advances. Both were mutation-tested against a no-op-default regression and fail without the fix. The give-up test was renamed (PutAsync_DoesNotReissueWhenTheRetryWindowIsAlreadySpent) to describe what TimeSpan.Zero actually proves: the client never attempts a reissue once the budget reads spent, not a multi-attempt exhaustion sequence — a review finding on the original name. Out of scope, noted for follow-up: GuestLockRetryTests.cs's synchronous Execute() tests still use a 400ms ShortWindow with real Thread.Sleep, which is the same flake shape on the sync path; Execute() has no delay seam. PveHttpClientTimeoutTests.cs and PveHttpClientFormEncodingTests.cs still reflect on the private _httpClient field, which the new handler seam could also retire. Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>