From f1a3199e555584022bf8149e691ac92d79f77cb6 Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Mon, 5 Oct 2026 01:27:14 +0200 Subject: [PATCH] KV routing tests wait for both replicas to be scraped: a replica not yet heard from is passed over, and the test was racing that Co-Authored-By: Claude Opus 5.5 (1M context) --- internal/router/kvroute_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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.