mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-21 13:37:14 +02:00
test: fix variants-retry-after HTTP-date flake (TODOS P2)
toUTCString() truncates to whole seconds, so a +3000ms Retry-After date could mean an effective wait of ~2001ms — flaking against the 2500ms assertion floor ~1-2 in 9 runs under suite load. +4000ms puts the truncation floor at 3001ms with the assertion floor safely below it. Pulled forward from U4 because the free-tests lane is now a required check and this flake would randomly block PRs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
d5fed59adf
commit
97cb10714e
@@ -78,7 +78,12 @@ describe("generateVariant Retry-After handling", () => {
|
||||
|
||||
test("HTTP-date: honors a future date with no extra leading exponential", async () => {
|
||||
const calls: CallRecord[] = [];
|
||||
const future = new Date(Date.now() + 3000).toUTCString();
|
||||
// toUTCString() truncates to whole seconds: a +3000ms date could mean an
|
||||
// effective wait as low as ~2001ms, which flaked against a 2500ms floor
|
||||
// under suite load (~1-2 in 9 runs — the TODOS P2 flake). +4000ms makes
|
||||
// the truncation floor 3001ms; the assertion floor sits safely below it
|
||||
// and the ceiling stays wide enough for a loaded scheduler.
|
||||
const future = new Date(Date.now() + 4000).toUTCString();
|
||||
const fetchFn = makeStubFetch([rateLimited(future), successResponse()], calls);
|
||||
|
||||
const result = await generateVariant(
|
||||
@@ -88,8 +93,8 @@ describe("generateVariant Retry-After handling", () => {
|
||||
expect(result.success).toBe(true);
|
||||
expect(calls.length).toBe(2);
|
||||
const gap = calls[1].ts - calls[0].ts;
|
||||
expect(gap).toBeGreaterThanOrEqual(2500);
|
||||
expect(gap).toBeLessThan(4500);
|
||||
expect(gap).toBeGreaterThanOrEqual(2900);
|
||||
expect(gap).toBeLessThan(5500);
|
||||
});
|
||||
|
||||
test("invalid Retry-After (alphanumeric): falls through to exponential", async () => {
|
||||
|
||||
Reference in New Issue
Block a user