tests: two waits that went red at load 80–100 leave room: the reasoning relay is timed by the vendor's clock, otel waits a minute for its export
Both went red in full runs of go test ./... on a machine at load 80–100.
Neither is a fault in what they test.
- TestChatReasoningRelayedAsItComes: "first thought after 924ms" against a
700ms bound from before the request, while the thought still came ~1s
ahead of the text. The bound timed the gateway's start, not the relay.
slowThinker now records when it wrote each event. The test checks that
the first thought reached the client before the vendor wrote the text.
That is the guarantee, and a slow start no longer counts against it.
- plugins/otel TestOnExportsOffSendsNothing waited 10s for the first export.
It now waits a minute, as other waits for a plugin's first work do.
Run: go test -count=5 for the relay test, all ok. Broken by hand:
refusesAfterThinking returns true, so the reasoning is held as Claude's is.
The test went red ("reached the client 489µs after the vendor wrote the
text"). Full go test ./... ran with the middleware point commit before this
one (see its body).
This commit is contained in:
@@ -34,32 +34,31 @@ func TestChatReasoningRelayedAsItComes(t *testing.T) {
|
||||
gw := httptest.NewServer(New().Handler())
|
||||
t.Cleanup(gw.Close)
|
||||
|
||||
start := time.Now()
|
||||
res, err := http.Post(gw.URL+"/v1/chat/completions", "application/json",
|
||||
strings.NewReader(`{"model":"wb/deepseek-v4.1-flash","stream":true,"reasoning_effort":"max","messages":[{"role":"user","content":"hi"}]}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
var firstThought, firstText time.Time
|
||||
var firstThought time.Time
|
||||
rd := bufio.NewReader(res.Body)
|
||||
for {
|
||||
ln, err := rd.ReadString('\n')
|
||||
if firstThought.IsZero() && strings.Contains(ln, `"reasoning_content":"hmm"`) {
|
||||
firstThought = time.Now()
|
||||
}
|
||||
if firstText.IsZero() && strings.Contains(ln, `"content":"done"`) {
|
||||
firstText = time.Now()
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if firstThought.IsZero() || firstText.IsZero() {
|
||||
t.Fatal("no reasoning or no text reached the client")
|
||||
if firstThought.IsZero() {
|
||||
t.Fatal("no reasoning reached the client")
|
||||
}
|
||||
// the first thought is sent 200ms in, the text a second after it
|
||||
if firstThought.Sub(start) > 700*time.Millisecond || firstText.Sub(firstThought) < 700*time.Millisecond {
|
||||
t.Fatalf("reasoning held: first thought after %v, %v before the text", firstThought.Sub(start), firstText.Sub(firstThought))
|
||||
<-up.done
|
||||
// by the vendor's own clock, so a slow start under load doesn't count:
|
||||
// the first thought reaches the client before the vendor has even
|
||||
// written the text, a second after it
|
||||
if text := up.sent[6]; !firstThought.Before(text) {
|
||||
t.Fatalf("reasoning held: the first thought reached the client %v after the vendor wrote the text", firstThought.Sub(text))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ type slowThinker struct {
|
||||
events []string
|
||||
gap time.Duration
|
||||
done chan time.Time
|
||||
sent []time.Time // when each event was written; read after done
|
||||
}
|
||||
|
||||
func (s *slowThinker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -28,6 +29,7 @@ func (s *slowThinker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
for _, ev := range s.events {
|
||||
io.WriteString(w, ev+"\n\n")
|
||||
f.Flush()
|
||||
s.sent = append(s.sent, time.Now())
|
||||
time.Sleep(s.gap)
|
||||
}
|
||||
s.done <- time.Now()
|
||||
|
||||
@@ -53,11 +53,13 @@ func TestOnExportsOffSendsNothing(t *testing.T) {
|
||||
rt := pluginrt.New([]pluginrt.Manifest{manifest(t)})
|
||||
defer rt.Stop()
|
||||
// seen is every model the collector got until want came, or "" when it
|
||||
// didn't within 10s (the first export prices its rows, which loads the
|
||||
// catalog)
|
||||
// didn't within a minute. The first export prices its rows, which loads
|
||||
// the catalog: 10s wasn't enough on a machine at load 100 (the full
|
||||
// suite). Waiting longer costs a passing run nothing, and "off sends
|
||||
// nothing" doesn't hang on it: what came before model-again is checked.
|
||||
seen := func(want string) string {
|
||||
var got strings.Builder
|
||||
deadline := time.After(10 * time.Second)
|
||||
deadline := time.After(time.Minute)
|
||||
for {
|
||||
select {
|
||||
case b := <-received:
|
||||
|
||||
Reference in New Issue
Block a user