gateway: TestSingleProviderOwnPatienceWins's 429 cases don't race a scaled keepHeldAfter
The full suite at f3c4d7b7a went red once on the off case: "agent got
200, upstream asked 1 times; want 429, asked 1". scaled() sets
keepHeldAfter to 20ms, so on a busy machine the upstream's 429 came after
the held stream had already sent its 200 and SSE comments, and the 429
went to the agent inside the stream. The product's keepHeldAfter is 15s;
the off and shorter cases test the user's Patience, not keep-alive, so
they now hold keepHeldAfter at a minute. The longer case (want 200) keeps
the scaled one.
Run:
- with a 60ms sleep injected in busyUpstream.ServeHTTP: off and shorter
red on the old test, exactly CI's message; green with this change.
- without it: -count=20 -run '^TestSingleProviderOwnPatienceWins$'
./internal/gateway ok (11.0s). gofmt clean.
Test-only change; nothing else run for it.
This commit is contained in:
@@ -293,6 +293,12 @@ func TestSingleProviderOwnPatienceWins(t *testing.T) {
|
||||
}}
|
||||
s := busyProviderWaiting(t, u, c.patience)
|
||||
scaled(t, c.byDefault)
|
||||
if c.want != 200 {
|
||||
// the 429 is the agent's status, however long a busy
|
||||
// machine takes to have it: past a scaled keepHeldAfter
|
||||
// the stream's 200 went first, and the 429 in it
|
||||
keepHeldAfter = time.Minute
|
||||
}
|
||||
gw := httptest.NewServer(s.Handler())
|
||||
t.Cleanup(gw.Close)
|
||||
// a failure ends the request with the test, not when a pause
|
||||
|
||||
Reference in New Issue
Block a user