From 1855be75271bc3cdd543c103093652e621db0298 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 31 May 2022 15:13:29 -0400 Subject: [PATCH] http2: eliminate arbitrary timeouts in testServerResponse If the test deadlocks, we probably want a goroutine dump (which will happen naturally if we allow the test to time out). Otherwise, these arbitrary timeouts tend to only add noise on slower builders. Fixes golang/go#53160 (maybe). Change-Id: I2a95bf7fece27f949ab2cf9dea36fe440ac90d51 Reviewed-on: https://go-review.googlesource.com/c/net/+/409574 Reviewed-by: Damien Neil Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills --- server_test.go | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/server_test.go b/server_test.go index 9caf713e..40cbc439 100644 --- a/server_test.go +++ b/server_test.go @@ -2646,8 +2646,7 @@ func (st *serverTester) decodeHeader(headerBlock []byte) (pairs [][2]string) { } // testServerResponse sets up an idle HTTP/2 connection. The client function should -// write a single request that must be handled by the handler. This waits up to 5s -// for client to return, then up to an additional 2s for the handler to return. +// write a single request that must be handled by the handler. func testServerResponse(t testing.TB, handler func(http.ResponseWriter, *http.Request) error, client func(*serverTester), @@ -2657,30 +2656,20 @@ func testServerResponse(t testing.TB, if r.Body == nil { t.Fatal("nil Body") } - errc <- handler(w, r) + err := handler(w, r) + select { + case errc <- err: + default: + t.Errorf("unexpected duplicate request") + } }) defer st.Close() - donec := make(chan bool) - go func() { - defer close(donec) - st.greet() - client(st) - }() - - select { - case <-donec: - case <-time.After(5 * time.Second): - t.Fatal("timeout in client") - } + st.greet() + client(st) - select { - case err := <-errc: - if err != nil { - t.Fatalf("Error in handler: %v", err) - } - case <-time.After(2 * time.Second): - t.Fatal("timeout in handler") + if err := <-errc; err != nil { + t.Fatalf("Error in handler: %v", err) } }