From: Russ Cox Date: Mon, 12 Oct 2020 15:56:15 +0000 (-0400) Subject: net/http: deflake TestTransportPersistConnLeak on macOS X-Git-Tag: go1.16beta1~783 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=373695727b8975d20168ca0d6ae338f98a4a079a;p=gostls13.git net/http: deflake TestTransportPersistConnLeak on macOS 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 Reviewed-by: Dmitri Shuralyov TryBot-Result: Go Bot Trust: Russ Cox --- diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index a1c9e822b4..b152007282 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -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++ {