]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: deflake TestTransportPersistConnLeak on macOS
authorRuss Cox <rsc@golang.org>
Mon, 12 Oct 2020 15:56:15 +0000 (11:56 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 12 Oct 2020 17:22:19 +0000 (17:22 +0000)
On a loaded system, sometimes connections don't work out.
Ignore those in TestTransportPersistConnLeak to avoid flakes.

For #33585.

Change-Id: Ic07057532dc0ea5115d6ec49c3c29099a9382295
Reviewed-on: https://go-review.googlesource.com/c/go/+/261538
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Russ Cox <rsc@golang.org>

src/net/http/transport_test.go

index a1c9e822b472a4950fda761863cb5cf770c94cb2..b15200728265dd8ff73c5ae146f3358347d07f16 100644 (file)
@@ -1701,7 +1701,7 @@ func TestTransportPersistConnLeak(t *testing.T) {
                        res, err := c.Get(ts.URL)
                        didReqCh <- true
                        if err != nil {
-                               t.Errorf("client fetch error: %v", err)
+                               t.Logf("client fetch error: %v", err)
                                failed <- true
                                return
                        }
@@ -1715,17 +1715,15 @@ func TestTransportPersistConnLeak(t *testing.T) {
                case <-gotReqCh:
                        // ok
                case <-failed:
-                       close(unblockCh)
-                       return
+                       // Not great but not what we are testing:
+                       // sometimes an overloaded system will fail to make all the connections.
                }
        }
 
        nhigh := runtime.NumGoroutine()
 
        // Tell all handlers to unblock and reply.
-       for i := 0; i < numReq; i++ {
-               unblockCh <- true
-       }
+       close(unblockCh)
 
        // Wait for all HTTP clients to be done.
        for i := 0; i < numReq; i++ {