Skip to content

Commit 54cf776

Browse files
committed
net/http: add some debugging to TestDontCacheBrokenHTTP2Conn
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent bf5f641 commit 54cf776

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/net/http/transport_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5930,7 +5930,11 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
59305930

59315931
var brokenState brokenState
59325932

5933+
const numReqs = 5
5934+
var numDials, gotConns uint32 // atomic
5935+
59335936
cst.tr.Dial = func(netw, addr string) (net.Conn, error) {
5937+
atomic.AddUint32(&numDials, 1)
59345938
c, err := net.Dial(netw, addr)
59355939
if err != nil {
59365940
t.Errorf("unexpected Dial error: %v", err)
@@ -5939,8 +5943,6 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
59395943
return &breakableConn{c, &brokenState}, err
59405944
}
59415945

5942-
const numReqs = 5
5943-
var gotConns uint32 // atomic
59445946
for i := 1; i <= numReqs; i++ {
59455947
brokenState.Lock()
59465948
brokenState.broken = false
@@ -5953,6 +5955,7 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
59535955

59545956
ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
59555957
GotConn: func(info httptrace.GotConnInfo) {
5958+
t.Logf("got conn: %v, reused=%v, wasIdle=%v, idleTime=%v", info.Conn.LocalAddr(), info.Reused, info.WasIdle, info.IdleTime)
59565959
atomic.AddUint32(&gotConns, 1)
59575960
},
59585961
TLSHandshakeDone: func(cfg tls.ConnectionState, err error) {
@@ -5975,6 +5978,9 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
59755978
if got, want := atomic.LoadUint32(&gotConns), 1; int(got) != want {
59765979
t.Errorf("GotConn calls = %v; want %v", got, want)
59775980
}
5981+
if got, want := atomic.LoadUint32(&numDials), numReqs; int(got) != want {
5982+
t.Errorf("Dials = %v; want %v", got, want)
5983+
}
59785984
}
59795985

59805986
// Issue 34941

0 commit comments

Comments
 (0)