From 373695727b8975d20168ca0d6ae338f98a4a079a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 12 Oct 2020 11:56:15 -0400 Subject: [PATCH] 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 --- src/net/http/transport_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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++ { -- 2.50.0