Skip to content

Commit 8b5db48

Browse files
committed
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 <[email protected]> Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Nicholas Husin <[email protected]> Reviewed-by: Nicholas Husin <[email protected]> TryBot-Bypass: Damien Neil <[email protected]>
1 parent 94616da commit 8b5db48

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/net/http/clientconn_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,10 @@ func TestClientConnReserveAndConsume(t *testing.T) {
286286
synctest.Wait()
287287

288288
// State hook should be called, either to report the
289-
// connection availability increasing or the connection closing.
290-
if got, want := stateHookCalls, 1; got != want {
291-
t.Errorf("connection state hook calls: %v, want %v", got, want)
289+
// connection availability increasing or the connection closing,
290+
// or both.
291+
if stateHookCalls == 0 {
292+
t.Errorf("connection state hook calls: %v, want >1", stateHookCalls)
292293
}
293294

294295
if test.h1Closed && (mode == http1Mode || mode == https1Mode) {

0 commit comments

Comments
 (0)