From: Bryan C. Mills Date: Tue, 4 Apr 2023 18:49:23 +0000 (-0400) Subject: net/http: drop client address comparison in TestTransportRemovesDeadIdleConnections X-Git-Tag: go1.21rc1~1039 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a8ca653892a470daf065b7669061d6ce1b4ff2e9;p=gostls13.git net/http: drop client address comparison in TestTransportRemovesDeadIdleConnections Since the first client connection is explicitly closed before making the second request, we cannot in general assume that the second request uses a different port (it is equally valid to open the new connection on the same port as the old one that was closed). Fixes #59438. Change-Id: I52d5fe493bd8b1b49270d3996d2019d38d375ce9 Reviewed-on: https://go-review.googlesource.com/c/go/+/482175 Auto-Submit: Bryan Mills Reviewed-by: Damien Neil Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot --- diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index 9465b93b11..268b0a4776 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -741,7 +741,7 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) { c := ts.Client() tr := c.Transport.(*Transport) - doReq := func(name string) string { + doReq := func(name string) { // Do a POST instead of a GET to prevent the Transport's // idempotent request retry logic from kicking in... res, err := c.Post(ts.URL, "", nil) @@ -756,10 +756,10 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) { if err != nil { t.Fatalf("%s: %v", name, err) } - return string(slurp) + t.Logf("%s: ok (%q)", name, slurp) } - first := doReq("first") + doReq("first") keys1 := tr.IdleConnKeysForTesting() ts.CloseClientConnections() @@ -776,10 +776,7 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) { return true }) - second := doReq("second") - if first == second { - t.Errorf("expected a different connection between requests. got %q both times", first) - } + doReq("second") } // Test that the Transport notices when a server hangs up on its