Skip to content

Commit

Permalink
net/http: deflake TestTransportEventTrace_h2
Browse files Browse the repository at this point in the history
Fixes #15765

Change-Id: Id0a89d90ef9d3fffa9af0affca8c10a26fe6b7bc
Reviewed-on: https://go-review.googlesource.com/23284
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
bradfitz committed May 20, 2016
1 parent db5af0d commit cc0d8c8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/net/http/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3218,10 +3218,18 @@ func TestTransportEventTrace_NoHooks_h2(t *testing.T) { testTransportEventTrace(
func testTransportEventTrace(t *testing.T, h2 bool, noHooks bool) {
defer afterTest(t)
const resBody = "some body"
gotWroteReqEvent := make(chan struct{})
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
if _, err := ioutil.ReadAll(r.Body); err != nil {
t.Error(err)
}
if !noHooks {
select {
case <-gotWroteReqEvent:
case <-time.After(5 * time.Second):
t.Error("timeout waiting for WroteRequest event")
}
}
io.WriteString(w, resBody)
}))
defer cst.close()
Expand Down Expand Up @@ -3269,7 +3277,10 @@ func testTransportEventTrace(t *testing.T, h2 bool, noHooks bool) {
},
Wait100Continue: func() { logf("Wait100Continue") },
Got100Continue: func() { logf("Got100Continue") },
WroteRequest: func(e httptrace.WroteRequestInfo) { logf("WroteRequest: %+v", e) },
WroteRequest: func(e httptrace.WroteRequestInfo) {
close(gotWroteReqEvent)
logf("WroteRequest: %+v", e)
},
}
if noHooks {
// zero out all func pointers, trying to get some path to crash
Expand Down

0 comments on commit cc0d8c8

Please sign in to comment.