Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
a2ade452
Commit
a2ade452
authored
Feb 21, 2013
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/http: improve test reliability
Fixes #4852 R=golang-dev, adg CC=golang-dev
https://golang.org/cl/7374045
parent
c6f23bb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
transport_test.go
src/pkg/net/http/transport_test.go
+22
-2
No files found.
src/pkg/net/http/transport_test.go
View file @
a2ade452
...
...
@@ -970,6 +970,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
io
.
Copy
(
w
,
neverEnding
(
'a'
))
})
ts
:=
httptest
.
NewServer
(
mux
)
timeout
:=
100
*
time
.
Millisecond
client
:=
&
Client
{
Transport
:
&
Transport
{
...
...
@@ -978,7 +979,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
if
err
!=
nil
{
return
nil
,
err
}
conn
.
SetDeadline
(
time
.
Now
()
.
Add
(
100
*
time
.
Millisecond
))
conn
.
SetDeadline
(
time
.
Now
()
.
Add
(
timeout
))
if
debug
{
conn
=
NewLoggingConn
(
"client"
,
conn
)
}
...
...
@@ -988,6 +989,7 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
},
}
getFailed
:=
false
nRuns
:=
5
if
testing
.
Short
()
{
nRuns
=
1
...
...
@@ -998,6 +1000,14 @@ func TestIssue4191_InfiniteGetTimeout(t *testing.T) {
}
sres
,
err
:=
client
.
Get
(
ts
.
URL
+
"/get"
)
if
err
!=
nil
{
if
!
getFailed
{
// Make the timeout longer, once.
getFailed
=
true
t
.
Logf
(
"increasing timeout"
)
i
--
timeout
*=
10
continue
}
t
.
Errorf
(
"Error issuing GET: %v"
,
err
)
break
}
...
...
@@ -1024,6 +1034,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
io
.
Copy
(
ioutil
.
Discard
,
r
.
Body
)
})
ts
:=
httptest
.
NewServer
(
mux
)
timeout
:=
100
*
time
.
Millisecond
client
:=
&
Client
{
Transport
:
&
Transport
{
...
...
@@ -1032,7 +1043,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
if
err
!=
nil
{
return
nil
,
err
}
conn
.
SetDeadline
(
time
.
Now
()
.
Add
(
100
*
time
.
Millisecond
))
conn
.
SetDeadline
(
time
.
Now
()
.
Add
(
timeout
))
if
debug
{
conn
=
NewLoggingConn
(
"client"
,
conn
)
}
...
...
@@ -1042,6 +1053,7 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
},
}
getFailed
:=
false
nRuns
:=
5
if
testing
.
Short
()
{
nRuns
=
1
...
...
@@ -1052,6 +1064,14 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) {
}
sres
,
err
:=
client
.
Get
(
ts
.
URL
+
"/get"
)
if
err
!=
nil
{
if
!
getFailed
{
// Make the timeout longer, once.
getFailed
=
true
t
.
Logf
(
"increasing timeout"
)
i
--
timeout
*=
10
continue
}
t
.
Errorf
(
"Error issuing GET: %v"
,
err
)
break
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment