Skip to content

Commit f49e802

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
net/http: eliminate arbitrary timeouts in TestServerRequestContextCancel_ConnClose
These timeouts are empirically sometimes (but rarely) too short on slower builders, and at any rate if this test fails “for real” we'll want a goroutine dump in order to debug it anyway. A goroutine dump is exactly what we get if we let the test time out on its own. Fixes #52414. Change-Id: Id2dd3839977bd8a41f296d67d1cccbf068fd73f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/400816 Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 3df9df8 commit f49e802

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/net/http/serve_test.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,11 +4877,7 @@ func TestServerRequestContextCancel_ConnClose(t *testing.T) {
48774877
handlerDone := make(chan struct{})
48784878
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
48794879
close(inHandler)
4880-
select {
4881-
case <-r.Context().Done():
4882-
case <-time.After(3 * time.Second):
4883-
t.Errorf("timeout waiting for context to be done")
4884-
}
4880+
<-r.Context().Done()
48854881
close(handlerDone)
48864882
}))
48874883
defer ts.Close()
@@ -4891,18 +4887,9 @@ func TestServerRequestContextCancel_ConnClose(t *testing.T) {
48914887
}
48924888
defer c.Close()
48934889
io.WriteString(c, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n")
4894-
select {
4895-
case <-inHandler:
4896-
case <-time.After(3 * time.Second):
4897-
t.Fatalf("timeout waiting to see ServeHTTP get called")
4898-
}
4890+
<-inHandler
48994891
c.Close() // this should trigger the context being done
4900-
4901-
select {
4902-
case <-handlerDone:
4903-
case <-time.After(4 * time.Second):
4904-
t.Fatalf("timeout waiting to see ServeHTTP exit")
4905-
}
4892+
<-handlerDone
49064893
}
49074894

49084895
func TestServerContext_ServerContextKey_h1(t *testing.T) {

0 commit comments

Comments
 (0)