Given tests: order arrivals by limiter state instead of sleeps (limiter, spread, cancel-while-queued)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,7 @@ hosts = ["alpha"]
|
||||
default_model = "shared"
|
||||
`, alpha)
|
||||
go func() { drain(r.post("/r/v1/chat/completions", conversation(1, 1))) }() // holds the one slot
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
waitUntil(t, func() bool { return r.lim.InFlight("alpha", "shared") == 1 })
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 150*time.Millisecond)
|
||||
defer cancel()
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, r.front.URL+"/r/v1/chat/completions", strings.NewReader(conversation(2, 1)))
|
||||
|
||||
@@ -70,9 +70,9 @@ func TestDifferentConversationsSpreadByFreeSlots(t *testing.T) {
|
||||
for i := 1; i <= 2; i++ {
|
||||
wg.Add(1)
|
||||
go func(i int) { defer wg.Done(); drain(r.post("/r/v1/chat/completions", conversation(i, 1))) }(i)
|
||||
time.Sleep(50 * time.Millisecond) // arrive one after the other so both pick beta (10 > 2)
|
||||
// arrive one after the other so both pick beta (10 > 2): wait until beta holds i slots
|
||||
waitUntil(t, func() bool { return r.lim.InFlight("beta", "shared") == i })
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
// …so a third conversation starting now is sent to alpha (beta has 0 free slots, alpha 2).
|
||||
resp := r.post("/r/v1/chat/completions", conversation(3, 1))
|
||||
drain(resp)
|
||||
|
||||
Reference in New Issue
Block a user