From d048939daa2c070277a16bf41ed9f17edd9ddec5 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 19 Nov 2026 01:02:38 +0800 Subject: [PATCH] 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). --- internal/gateway/codex_backend_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/gateway/codex_backend_test.go b/internal/gateway/codex_backend_test.go index 874f9149b..1aabd5842 100644 --- a/internal/gateway/codex_backend_test.go +++ b/internal/gateway/codex_backend_test.go @@ -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) } }