Skip to content

Commit

Permalink
net/http: add tracing to TestTransportReuseConnection_Gzip_*
Browse files Browse the repository at this point in the history
These tests are flaky; add some additional logging in hopes
it will aid in debugging.

For #53373

Change-Id: I971a2815f50932a9700ef8c2f684c5416951e6de
Reviewed-on: https://go-review.googlesource.com/c/go/+/432375
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
neild committed Sep 21, 2022
1 parent e246cf6 commit 4412230
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/net/http/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4429,8 +4429,19 @@ func testTransportReuseConnection_Gzip(t *testing.T, chunked bool) {
defer ts.Close()
c := ts.Client()

trace := &httptrace.ClientTrace{
GetConn: func(hostPort string) { t.Logf("GetConn(%q)", hostPort) },
GotConn: func(ci httptrace.GotConnInfo) { t.Logf("GotConn(%+v)", ci) },
PutIdleConn: func(err error) { t.Logf("PutIdleConn(%v)", err) },
ConnectStart: func(network, addr string) { t.Logf("ConnectStart(%q, %q)", network, addr) },
ConnectDone: func(network, addr string, err error) { t.Logf("ConnectDone(%q, %q, %v)", network, addr, err) },
}
ctx := httptrace.WithClientTrace(context.Background(), trace)

for i := 0; i < 2; i++ {
res, err := c.Get(ts.URL)
req, _ := NewRequest("GET", ts.URL, nil)
req = req.WithContext(ctx)
res, err := c.Do(req)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 4412230

Please sign in to comment.