gateway: TestMaxRPMGroupPrefersMemberWithRoom checks the route never queued, not a fixed 1s (#2520)
The test gave the second request's round trip 1s as a stand-in for "didn't
wait for A's minute", and a loaded machine went over it (1.13s) with the
routing right. It now reads the second request's route from the trace:
done, one try, to pb, Queued 0 (the trace's Queued holds the wait for
room in the minute too). The time bound stays as a backstop at half the
minute, and the minute is now 20s instead of 5s, so the bar is 10s:
nothing waits for it when the routing is right.
Based on ump45nose's patch, which read usage.Load's record. The review
found that record's Queued and Tries are 0 for a non-streaming request
even after a 20s wait (Queued is filled only when TTFT > 0), so only its
provider check carried weight; the trace's try carries the wait
(Queued:19984 in the hand-broken run). The patch's 2.5s bar was also
under this machine's 2.97s round trip with B held 1.2s.
What ran (worktree at origin/main 81313b912, sandbox HOME, go1.26.8
darwin/arm64, load ~270-300):
- Flake reproduced: main's test with B's minuteVendor late 1200ms:
"the second waited 2.969s", FAIL. The new test passes with it (3.57s)
and -count=3 without it.
- Broken by hand: ready() ignoring MaxRPM makes the group wait for A:
red on the vendor counts ("A saw 2, B 0"), and with that check turned
to a Logf, red on the trace check (one try to pa, Queued 19984).
- gofmt -l . clean; go vet -tags nogui ./... for darwin, linux, windows.
- set -o pipefail; go test -count=1 -timeout 45m ./...: 65 packages ok,
internal/gateway ok (1430s). internal/gui red on TestMainWindowCorners
(#1936) and, on a rerun of internal/gui alone, also
TestSetAnswersWhileDevinAndProvidersHang (#1375): filed load reds in a
package this commit doesn't touch.
Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
This commit is contained in:
@@ -264,7 +264,10 @@ func TestMaxRPMCountsRetriesAndCounts(t *testing.T) {
|
||||
// member with room first, as it does one whose slots are all out, rather
|
||||
// than wait.
|
||||
func TestMaxRPMGroupPrefersMemberWithRoom(t *testing.T) {
|
||||
shortMinute(t, 5*time.Second, time.Minute)
|
||||
// A long minute: nothing waits for it when the routing is right, and
|
||||
// half of it is far past a loaded machine's round trip (2.97s with
|
||||
// B held 1.2s, at load 270).
|
||||
shortMinute(t, 20*time.Second, time.Minute)
|
||||
fresh(t)
|
||||
a, b := &minuteVendor{}, &minuteVendor{}
|
||||
ua, ub := httptest.NewServer(a), httptest.NewServer(b)
|
||||
@@ -304,8 +307,28 @@ func TestMaxRPMGroupPrefersMemberWithRoom(t *testing.T) {
|
||||
if len(a.times()) != 1 || len(b.times()) != 1 {
|
||||
t.Fatalf("second: A saw %d, B %d; want B, A having no room", len(a.times()), len(b.times()))
|
||||
}
|
||||
if d := time.Since(began); d > time.Second {
|
||||
t.Fatalf("the second waited %s", d)
|
||||
// It went to B without standing in A's minute: its route has one
|
||||
// try, B's, that queued for neither a slot nor room in a minute. This
|
||||
// is the state the round trip's time stood in for; a fixed 1s bar on
|
||||
// that time went red on a loaded machine with the routing right
|
||||
// (#2520).
|
||||
var r Route
|
||||
for end := time.Now().Add(10 * time.Second); ; time.Sleep(10 * time.Millisecond) {
|
||||
s.trace.mu.Lock()
|
||||
r = *s.trace.routes[len(s.trace.routes)-1]
|
||||
r.Tries = append([]Try{}, r.Tries...)
|
||||
s.trace.mu.Unlock()
|
||||
if r.Done || time.Now().After(end) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !r.Done || len(r.Tries) != 1 || r.Tries[0].ID != "pb" || r.Tries[0].Queued != 0 {
|
||||
t.Fatalf("second: done %v, tries %+v; want one try to B that never queued", r.Done, r.Tries)
|
||||
}
|
||||
// A wait for A's minute would be the whole of it (20s): half of it
|
||||
// leaves room on both sides.
|
||||
if d := time.Since(began); d > rpmWindow/2 {
|
||||
t.Fatalf("the second took %s, as long as a wait for A's %s minute", d, rpmWindow)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user