]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: add some debugging to TestDontCacheBrokenHTTP2Conn
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 12 Nov 2019 18:38:33 +0000 (18:38 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 13 Nov 2019 14:12:20 +0000 (14:12 +0000)
Not a fix, but will give us more info when it flakes again.

Updates #35113

Change-Id: I2f90c24530c1bea81dd9d8c7a59f4b0640dfa4c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/206819
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/net/http/transport_test.go

index 27be26cedc5b5d948d9939f479522632850f542c..62f1e36b388adb69bebd13b584c1398389a166ba 100644 (file)
@@ -5930,7 +5930,11 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
 
        var brokenState brokenState
 
+       const numReqs = 5
+       var numDials, gotConns uint32 // atomic
+
        cst.tr.Dial = func(netw, addr string) (net.Conn, error) {
+               atomic.AddUint32(&numDials, 1)
                c, err := net.Dial(netw, addr)
                if err != nil {
                        t.Errorf("unexpected Dial error: %v", err)
@@ -5939,8 +5943,6 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
                return &breakableConn{c, &brokenState}, err
        }
 
-       const numReqs = 5
-       var gotConns uint32 // atomic
        for i := 1; i <= numReqs; i++ {
                brokenState.Lock()
                brokenState.broken = false
@@ -5953,6 +5955,7 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
 
                ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
                        GotConn: func(info httptrace.GotConnInfo) {
+                               t.Logf("got conn: %v, reused=%v, wasIdle=%v, idleTime=%v", info.Conn.LocalAddr(), info.Reused, info.WasIdle, info.IdleTime)
                                atomic.AddUint32(&gotConns, 1)
                        },
                        TLSHandshakeDone: func(cfg tls.ConnectionState, err error) {
@@ -5975,6 +5978,9 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
        if got, want := atomic.LoadUint32(&gotConns), 1; int(got) != want {
                t.Errorf("GotConn calls = %v; want %v", got, want)
        }
+       if got, want := atomic.LoadUint32(&numDials), numReqs; int(got) != want {
+               t.Errorf("Dials = %v; want %v", got, want)
+       }
 }
 
 // Issue 34941