@@ -5930,7 +5930,11 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
5930
5930
5931
5931
var brokenState brokenState
5932
5932
5933
+ const numReqs = 5
5934
+ var numDials , gotConns uint32 // atomic
5935
+
5933
5936
cst .tr .Dial = func (netw , addr string ) (net.Conn , error ) {
5937
+ atomic .AddUint32 (& numDials , 1 )
5934
5938
c , err := net .Dial (netw , addr )
5935
5939
if err != nil {
5936
5940
t .Errorf ("unexpected Dial error: %v" , err )
@@ -5939,8 +5943,6 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
5939
5943
return & breakableConn {c , & brokenState }, err
5940
5944
}
5941
5945
5942
- const numReqs = 5
5943
- var gotConns uint32 // atomic
5944
5946
for i := 1 ; i <= numReqs ; i ++ {
5945
5947
brokenState .Lock ()
5946
5948
brokenState .broken = false
@@ -5953,6 +5955,7 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
5953
5955
5954
5956
ctx := httptrace .WithClientTrace (context .Background (), & httptrace.ClientTrace {
5955
5957
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 )
5956
5959
atomic .AddUint32 (& gotConns , 1 )
5957
5960
},
5958
5961
TLSHandshakeDone : func (cfg tls.ConnectionState , err error ) {
@@ -5975,6 +5978,9 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
5975
5978
if got , want := atomic .LoadUint32 (& gotConns ), 1 ; int (got ) != want {
5976
5979
t .Errorf ("GotConn calls = %v; want %v" , got , want )
5977
5980
}
5981
+ if got , want := atomic .LoadUint32 (& numDials ), numReqs ; int (got ) != want {
5982
+ t .Errorf ("Dials = %v; want %v" , got , want )
5983
+ }
5978
5984
}
5979
5985
5980
5986
// Issue 34941
0 commit comments