Skip to content

Commit

Permalink
net/http: eliminate arbitrary timeout in TestClientWriteShutdown
Browse files Browse the repository at this point in the history
This test occasionally hangs on the darwin-arm64-11_0-toothrot
builder. When it does, it fails with the unhelpful error message
"timeout" instead of a useful goroutine dump.

This change eliminates the use of an arbitrary timeout channel, so
that if (and probably when) the test hangs again we will get more
useful logs to diagnose the root cause.

For #49860

Change-Id: I23f6f1c81209f0b2dbe565e1dfb26b1b2eff0187
Reviewed-on: https://go-review.googlesource.com/c/go/+/367615
Trust: Bryan C. Mills <[email protected]>
Run-TryBot: Bryan C. Mills <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
  • Loading branch information
Bryan C. Mills committed Nov 30, 2021
1 parent f463b20 commit 18934e1
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/net/http/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3075,22 +3075,14 @@ func TestClientWriteShutdown(t *testing.T) {
if err != nil {
t.Fatalf("CloseWrite: %v", err)
}
donec := make(chan bool)
go func() {
defer close(donec)
bs, err := io.ReadAll(conn)
if err != nil {
t.Errorf("ReadAll: %v", err)
}
got := string(bs)
if got != "" {
t.Errorf("read %q from server; want nothing", got)
}
}()
select {
case <-donec:
case <-time.After(10 * time.Second):
t.Fatalf("timeout")

bs, err := io.ReadAll(conn)
if err != nil {
t.Errorf("ReadAll: %v", err)
}
got := string(bs)
if got != "" {
t.Errorf("read %q from server; want nothing", got)
}
}

Expand Down

0 comments on commit 18934e1

Please sign in to comment.