gateway test: a turn on Codex's own sign-in counts its hold in Send and Wait together

TestCodexOwnSignInTellsWhereItsTimeWent went red in a full run at
3438b7bd9 on the magpie-desktop WSL box (Linux, busy):
  timing {... Send:4 Wait:196.9 Head:202.1} for a 200ms hold
The fake backend starts its hold once it has read the body, and that can
come before the client's WroteRequest fires, so up to Send of the hold is
counted in Send, not Wait. The test now wants Send+Wait to cover the hold
and Wait at least half of it (the vendor's wait is still where the time
goes), and Head past Wait, as before. Test only; nettrace is unchanged.

Run (wsl-run, magpie-desktop): go test -count=30 -run
'TestCodexOwnSignInTellsWhereItsTimeWent$' ./internal/gateway ok.
Broken by hand: Wait divided by 4 in nettrace.go: red ("Wait:50.375 ...
for a 200ms hold").

Not tried: injecting the WroteRequest delay itself; the cause is read
from nettrace.go (Send = gotConn to wrote, Wait = wrote to first byte).
This commit is contained in:
yetone
2026-11-19 01:02:38 +08:00
parent 91e8146727
commit d048939daa
+5 -1
View File
@@ -1360,8 +1360,12 @@ func TestCodexOwnSignInTellsWhereItsTimeWent(t *testing.T) {
if n == nil {
t.Fatal("no timing for a turn on Codex's own sign-in")
}
// The backend starts its hold once it has read the body, which can be
// before the client's WroteRequest fires: the hold is in Send and Wait
// together, and most of it in Wait (on a busy Linux box, Send 4 and
// Wait 196.9 for a 200ms hold).
holdMs := float64(hold.Milliseconds())
if n.Asks != 1 || n.Wait < holdMs-1 || n.Head < n.Wait {
if n.Asks != 1 || n.Send+n.Wait < holdMs-1 || n.Wait < holdMs/2 || n.Head < n.Wait {
t.Fatalf("timing %+v for a %v hold", *n, hold)
}
}