diff --git a/internal/router/kvroute_test.go b/internal/router/kvroute_test.go index a45b79ae..5b7b8674 100644 --- a/internal/router/kvroute_test.go +++ b/internal/router/kvroute_test.go @@ -9,6 +9,7 @@ import ( "strings" "sync/atomic" "testing" + "time" "github.com/prometheus/client_golang/prometheus/testutil" @@ -95,7 +96,27 @@ func kvRouter(t *testing.T, tier1 bool) (*Router, *kvFakeVLLM, *kvFakeVLLM) { other.RoutingProfile = "chat" cfg.Models = []catalog.Model{m, other} cfg.Router.Prefix.Enabled = tier1 - return newTestRouter(t, cfg), a, b + rt := newTestRouter(t, cfg) + // Both scraped before anything is sent: a replica not yet heard from is + // passed over while another has been, which is admission's rule and not + // what these tests are about. + deadline := time.Now().Add(3 * time.Second) + for { + fresh := 0 + for _, sn := range rt.reg.Snapshots("m") { + if !sn.Stale { + fresh++ + } + } + if fresh == 2 { + break + } + if time.Now().After(deadline) { + t.Fatal("the replicas were never scraped") + } + time.Sleep(10 * time.Millisecond) + } + return rt, a, b } // longPrompt is long enough for several blocks of sixteen.