]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: add tracing to TestTransportReuseConnection_Gzip_*
authorDamien Neil <dneil@google.com>
Wed, 21 Sep 2022 15:11:40 +0000 (08:11 -0700)
committerDamien Neil <dneil@google.com>
Wed, 21 Sep 2022 15:39:17 +0000 (15:39 +0000)
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>

src/net/http/transport_test.go

index e1f2a24f46cbf37508aecd41fc833af5f813224a..26293befb4d69ffa100993096055658faa95597a 100644 (file)
@@ -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)
                }