]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: deflake TestClientConnReserveAndConsume
authorDamien Neil <dneil@google.com>
Mon, 1 Dec 2025 20:28:19 +0000 (12:28 -0800)
committerDamien Neil <dneil@google.com>
Mon, 1 Dec 2025 21:35:16 +0000 (13:35 -0800)
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 <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
TryBot-Bypass: Damien Neil <dneil@google.com>

src/net/http/clientconn_test.go

index e46f6e6a5133a7b31d3dfcdeef12fae6900959a3..03d47939aab6685f7e554422fb1d9ad2929891af 100644 (file)
@@ -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) {