@@ -970,6 +970,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
970
970
io .Copy (w , neverEnding ('a' ))
971
971
})
972
972
ts := httptest .NewServer (mux )
973
+ timeout := 100 * time .Millisecond
973
974
974
975
client := & Client {
975
976
Transport : & Transport {
@@ -978,7 +979,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
978
979
if err != nil {
979
980
return nil , err
980
981
}
981
- conn .SetDeadline (time .Now ().Add (100 * time . Millisecond ))
982
+ conn .SetDeadline (time .Now ().Add (timeout ))
982
983
if debug {
983
984
conn = NewLoggingConn ("client" , conn )
984
985
}
@@ -988,6 +989,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
988
989
},
989
990
}
990
991
992
+ getFailed := false
991
993
nRuns := 5
992
994
if testing .Short () {
993
995
nRuns = 1
@@ -998,6 +1000,14 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
998
1000
}
999
1001
sres , err := client .Get (ts .URL + "/get" )
1000
1002
if err != nil {
1003
+ if ! getFailed {
1004
+ // Make the timeout longer, once.
1005
+ getFailed = true
1006
+ t .Logf ("increasing timeout" )
1007
+ i --
1008
+ timeout *= 10
1009
+ continue
1010
+ }
1001
1011
t .Errorf ("Error issuing GET: %v" , err )
1002
1012
break
1003
1013
}
@@ -1024,6 +1034,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
1024
1034
io .Copy (ioutil .Discard , r .Body )
1025
1035
})
1026
1036
ts := httptest .NewServer (mux )
1037
+ timeout := 100 * time .Millisecond
1027
1038
1028
1039
client := & Client {
1029
1040
Transport : & Transport {
@@ -1032,7 +1043,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
1032
1043
if err != nil {
1033
1044
return nil , err
1034
1045
}
1035
- conn .SetDeadline (time .Now ().Add (100 * time . Millisecond ))
1046
+ conn .SetDeadline (time .Now ().Add (timeout ))
1036
1047
if debug {
1037
1048
conn = NewLoggingConn ("client" , conn )
1038
1049
}
@@ -1042,6 +1053,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
1042
1053
},
1043
1054
}
1044
1055
1056
+ getFailed := false
1045
1057
nRuns := 5
1046
1058
if testing .Short () {
1047
1059
nRuns = 1
@@ -1052,6 +1064,14 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
1052
1064
}
1053
1065
sres , err := client .Get (ts .URL + "/get" )
1054
1066
if err != nil {
1067
+ if ! getFailed {
1068
+ // Make the timeout longer, once.
1069
+ getFailed = true
1070
+ t .Logf ("increasing timeout" )
1071
+ i --
1072
+ timeout *= 10
1073
+ continue
1074
+ }
1055
1075
t .Errorf ("Error issuing GET: %v" , err )
1056
1076
break
1057
1077
}
0 commit comments