A test flake in #59447 seems to indicate that this test got stuck
waiting for the test handler to close the readc channel.
If the handler returns early due to an unexpected error, it might
fail to close this channel. Add a second channel to act as a
signal that the handler has given up and the test should stop.
This won't fix whatever happened in the flake, but might help
us debug it if it happens again.
For #59447
Change-Id: I05d84c6176aa938887d93126a6f3bb4dc941c90d
Reviewed-on: https://go-review.googlesource.com/c/go/+/482935
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
}
func testResponseControllerSetPastReadDeadline(t *testing.T, mode testMode) {
readc := make(chan struct{})
+ donec := make(chan struct{})
cst := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) {
+ defer close(donec)
ctl := NewResponseController(w)
b := make([]byte, 3)
n, err := io.ReadFull(r.Body, b)
wg.Add(1)
go func() {
defer wg.Done()
+ defer pw.Close()
pw.Write([]byte("one"))
- <-readc
+ select {
+ case <-readc:
+ case <-donec:
+ t.Errorf("server handler unexpectedly exited without closing readc")
+ return
+ }
pw.Write([]byte("two"))
- pw.Close()
}()
defer wg.Wait()
res, err := cst.c.Post(cst.ts.URL, "text/foo", pr)