From 8b5db48db11f6ec075fd1ea528a5d611579c3a0d Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Mon, 1 Dec 2025 12:28:19 -0800 Subject: [PATCH] net/http: deflake TestClientConnReserveAndConsume This test includes an assertion that a client conn's state hook is called exactly once, but some of the test cases can result in two events occurring: A request completes and a connection closes. Change the assertion to just check that the hook is called at least once. Fixes #76480 Change-Id: Ie1438581b072b10623eb3d5fe443294a639c9853 Reviewed-on: https://go-review.googlesource.com/c/go/+/725601 Commit-Queue: Damien Neil Auto-Submit: Damien Neil Reviewed-by: Nicholas Husin Reviewed-by: Nicholas Husin TryBot-Bypass: Damien Neil --- src/net/http/clientconn_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/net/http/clientconn_test.go b/src/net/http/clientconn_test.go index e46f6e6a51..03d47939aa 100644 --- a/src/net/http/clientconn_test.go +++ b/src/net/http/clientconn_test.go @@ -286,9 +286,10 @@ func TestClientConnReserveAndConsume(t *testing.T) { synctest.Wait() // State hook should be called, either to report the - // connection availability increasing or the connection closing. - if got, want := stateHookCalls, 1; got != want { - t.Errorf("connection state hook calls: %v, want %v", got, want) + // connection availability increasing or the connection closing, + // or both. + if stateHookCalls == 0 { + t.Errorf("connection state hook calls: %v, want >1", stateHookCalls) } if test.h1Closed && (mode == http1Mode || mode == https1Mode) { -- 2.52.0