mirror of
https://github.com/golang/go
synced 2024-11-23 20:40:07 -07:00
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
bf5f64107a
commit
54cf776020
@ -5930,7 +5930,11 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
|
|||||||
|
|
||||||
var brokenState brokenState
|
var brokenState brokenState
|
||||||
|
|
||||||
|
const numReqs = 5
|
||||||
|
var numDials, gotConns uint32 // atomic
|
||||||
|
|
||||||
cst.tr.Dial = func(netw, addr string) (net.Conn, error) {
|
cst.tr.Dial = func(netw, addr string) (net.Conn, error) {
|
||||||
|
atomic.AddUint32(&numDials, 1)
|
||||||
c, err := net.Dial(netw, addr)
|
c, err := net.Dial(netw, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected Dial error: %v", err)
|
t.Errorf("unexpected Dial error: %v", err)
|
||||||
@ -5939,8 +5943,6 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
|
|||||||
return &breakableConn{c, &brokenState}, err
|
return &breakableConn{c, &brokenState}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const numReqs = 5
|
|
||||||
var gotConns uint32 // atomic
|
|
||||||
for i := 1; i <= numReqs; i++ {
|
for i := 1; i <= numReqs; i++ {
|
||||||
brokenState.Lock()
|
brokenState.Lock()
|
||||||
brokenState.broken = false
|
brokenState.broken = false
|
||||||
@ -5953,6 +5955,7 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
|
|||||||
|
|
||||||
ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
|
ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
|
||||||
GotConn: func(info httptrace.GotConnInfo) {
|
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)
|
atomic.AddUint32(&gotConns, 1)
|
||||||
},
|
},
|
||||||
TLSHandshakeDone: func(cfg tls.ConnectionState, err error) {
|
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 {
|
if got, want := atomic.LoadUint32(&gotConns), 1; int(got) != want {
|
||||||
t.Errorf("GotConn calls = %v; want %v", 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
|
// Issue 34941
|
||||||
|
Loading…
Reference in New Issue
Block a user