Commit cc0d8c86 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: deflake TestTransportEventTrace_h2

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent db5af0d7
......@@ -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()
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment