]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: eliminate arbitrary timeouts in TestServerRequestContextCancel_ConnClose
authorBryan C. Mills <bcmills@google.com>
Mon, 18 Apr 2022 16:55:30 +0000 (12:55 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 18 Apr 2022 22:07:54 +0000 (22:07 +0000)
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 <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/http/serve_test.go

index 435f828871a3a63d2b669de096c354e46cf19db8..1c85a665997841c432ea6ce1c55847630d1a7333 100644 (file)
@@ -4877,11 +4877,7 @@ func TestServerRequestContextCancel_ConnClose(t *testing.T) {
        handlerDone := make(chan struct{})
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
                close(inHandler)
-               select {
-               case <-r.Context().Done():
-               case <-time.After(3 * time.Second):
-                       t.Errorf("timeout waiting for context to be done")
-               }
+               <-r.Context().Done()
                close(handlerDone)
        }))
        defer ts.Close()
@@ -4891,18 +4887,9 @@ func TestServerRequestContextCancel_ConnClose(t *testing.T) {
        }
        defer c.Close()
        io.WriteString(c, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n")
-       select {
-       case <-inHandler:
-       case <-time.After(3 * time.Second):
-               t.Fatalf("timeout waiting to see ServeHTTP get called")
-       }
+       <-inHandler
        c.Close() // this should trigger the context being done
-
-       select {
-       case <-handlerDone:
-       case <-time.After(4 * time.Second):
-               t.Fatalf("timeout waiting to see ServeHTTP exit")
-       }
+       <-handlerDone
 }
 
 func TestServerContext_ServerContextKey_h1(t *testing.T) {