diff options
author | Michael Fraenkel <michael.fraenkel@gmail.com> | 2019-05-02 22:59:27 -0400 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-05-03 15:58:50 +0000 |
commit | 0a4d352992606d3becebfa0cdac392827039b49d (patch) | |
tree | 3735a6a24c8d71345d20076d33ed6b8117cc5dcc /src/net/http/transport_test.go | |
parent | 2c67cdf7cf59a685f3a5e705b6be85f32285acec (diff) | |
download | go-0a4d352992606d3becebfa0cdac392827039b49d.tar.gz go-0a4d352992606d3becebfa0cdac392827039b49d.zip |
net/http: fix TestTransportMaxConnsPerHost flakes
The testcase created a race between the close of the current connection
and the client grabbing a connection for the next request. The client
may receive the current connection which may be closed during its use.
We can have the trasnport close all idle connections thereby forcing the
client to receive a new connection.
Closing idle connections did not handle cleaning up host connection
counts for http/2. We will now decrement the host connection count for
http/2 connections.
Fixes #31784
Change-Id: Iefc0d0d7ed9fa3acd8b4f42004f1579fc1de63fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/174950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/transport_test.go')
-rw-r--r-- | src/net/http/transport_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index cf2bbe1189..9de2fdab66 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -22,7 +22,6 @@ import ( "fmt" "go/token" "internal/nettrace" - "internal/testenv" "io" "io/ioutil" "log" @@ -592,7 +591,7 @@ func TestTransportMaxConnsPerHostIncludeDialInProgress(t *testing.T) { func TestTransportMaxConnsPerHost(t *testing.T) { defer afterTest(t) - testenv.SkipFlaky(t, 31784) + h := HandlerFunc(func(w ResponseWriter, r *Request) { _, err := w.Write([]byte("foo")) if err != nil { @@ -666,6 +665,7 @@ func TestTransportMaxConnsPerHost(t *testing.T) { } (<-connCh).Close() + tr.CloseIdleConnections() doReq() expected++ |