provider: TestPluginPicksComeBackWithTheirList waits for the full list to be taken, not a fixed 200ms (#3051)

After sending the full list, the test waited 200ms for "not asked
again" and then read the picks. Under load KeepPluginsListed hadn't
taken the list yet, so the picks still read [pool-a pool-b], set aside
[qoder/claude-x kiro/claude-y]: red in the v0.1.1303 full suite and at
load ~400 before. It now polls Find until the picks are back (10s
bar), failing if the loop asks again meanwhile, then checks for 100ms
that it isn't asked again soon. Waiting for the state is ggbdpq's
idea on #3051.

Run: a 300ms sleep injected into the fake relist before it caches the
answer: the old test red 3 of 3 with the same message
(plugin_delisted_test.go:130), the new one green (2.74s). Without it:
go test -race -count=20 -run TestPluginPicksComeBackWithTheirList ok;
gofmt -l clean.
This commit is contained in:
yetone
2026-10-21 04:16:29 +08:00
parent 5daea73c6e
commit c922225f13
+18 -5
View File
@@ -116,14 +116,27 @@ func TestPluginPicksComeBackWithTheirList(t *testing.T) {
}
answers <- full
// the loop takes the full list in its own time (a fixed 200ms read
// the picks before it had, under load: #3051), so wait for its state
want := []string{"pool-a", "pool-b", "qoder/claude-x", "kiro/claude-y"}
for deadline := time.Now().Add(10 * time.Second); ; {
select {
case <-asked:
t.Fatal("asked again soon after a list that left nothing out")
case <-time.After(10 * time.Millisecond):
}
if p, err = Find("our-free-model"); err != nil {
t.Fatal(err)
}
if slices.Equal(p.Models, want) && len(p.Delisted) == 0 || time.Now().After(deadline) {
break
}
}
// and with the list taken, it isn't asked for again soon
select {
case <-asked:
t.Fatal("asked again soon after a list that left nothing out")
case <-time.After(200 * time.Millisecond):
}
p, err = Find("our-free-model")
if err != nil {
t.Fatal(err)
case <-time.After(100 * time.Millisecond):
}
if !slices.Equal(p.Models, []string{"pool-a", "pool-b", "qoder/claude-x", "kiro/claude-y"}) || len(p.Delisted) != 0 {
t.Fatalf("full list again: picks %v, set aside %v", p.Models, p.Delisted)