gateway: the live reasoning fixture allows the time its first event really took
TestLiveVisibleReasoningFixture set start to now minus the event's at_ms and then called see, which reads the clock again. Any time between the two lands in the measured start, so on macOS CI (run 43530452364,e730a14dc) it read 6790 where the fixture says 6789. The test now records the time before setting start, and accepts the fixture's at_ms up to the milliseconds that really passed during the first see. Run on mica, at this change onf1f34d624: - The test -count=20: ok. go vet -tags nogui ./internal/gateway: ok. -run 'Reasoning|TTFT|FirstToken' ./internal/gateway: ok. gofmt clean. - Broken by hand: - The old test with a 3ms sleep before see: red, 6792/6789. The new one with the same sleep: ok. - ttft.go setting reasoning on every event, so the first is lost: the new test is red (0/6789). - Not run: the whole gateway package or the full suite; this changes one test's bound only.
This commit is contained in:
@@ -366,14 +366,22 @@ func TestLiveVisibleReasoningFixture(t *testing.T) {
|
||||
if err = json.Unmarshal(b, &sample); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// see reads the wall clock after start is set, so the first event lands
|
||||
// at its at_ms plus however long that took: a millisecond more on a busy
|
||||
// machine (6790/6789 on macOS CI), so the bound is what really passed.
|
||||
f := firstToken{}
|
||||
for _, e := range sample.Events {
|
||||
var slack int64
|
||||
for i, e := range sample.Events {
|
||||
delta, _ := json.Marshal(e.Delta)
|
||||
f.start = time.Now().Add(-time.Duration(e.At) * time.Millisecond)
|
||||
set := time.Now()
|
||||
f.start = set.Add(-time.Duration(e.At) * time.Millisecond)
|
||||
f.see([]byte(`data: {"choices":[{"delta":{"reasoning_content":` + string(delta) + `}}]}` + "\n\n"))
|
||||
if i == 0 {
|
||||
slack = time.Since(set).Milliseconds() + 1
|
||||
}
|
||||
}
|
||||
if f.reasoningMs(provider.Chat) != sample.Events[0].At {
|
||||
t.Fatalf("live reasoning fixture lost its start: %d/%d", f.reasoningMs(provider.Chat), sample.Events[0].At)
|
||||
if got, at := f.reasoningMs(provider.Chat), sample.Events[0].At; got < at || got > at+slack {
|
||||
t.Fatalf("live reasoning fixture lost its start: %d/%d (+%d ms passing)", got, at, slack)
|
||||
}
|
||||
// its 731 ms came after a 6.8 s wait, which tells no speed: under a
|
||||
// second after a wait over four times longer reads as a reply let go
|
||||
|
||||
Reference in New Issue
Block a user