Commit 8ba0933a authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: speed up and deflake TestServerKeepAlivesEnabled_h2

Fixes #21724

Change-Id: I92571bf228781b17fdf012a2fb52a597c877cefe
Reviewed-on: https://go-review.googlesource.com/81576
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarTom Bergan <tombergan@google.com>
parent 496688b3
......@@ -211,3 +211,9 @@ func (s *Server) ExportAllConnsIdle() bool {
func (r *Request) WithT(t *testing.T) *Request {
return r.WithContext(context.WithValue(r.Context(), tLogKey{}, t.Logf))
}
func ExportSetH2GoawayTimeout(d time.Duration) (restore func()) {
old := http2goAwayTimeout
http2goAwayTimeout = d
return func() { http2goAwayTimeout = old }
}
......@@ -5447,7 +5447,11 @@ func TestServerCloseDeadlock(t *testing.T) {
func TestServerKeepAlivesEnabled_h1(t *testing.T) { testServerKeepAlivesEnabled(t, h1Mode) }
func TestServerKeepAlivesEnabled_h2(t *testing.T) { testServerKeepAlivesEnabled(t, h2Mode) }
func testServerKeepAlivesEnabled(t *testing.T, h2 bool) {
setParallel(t)
if h2 {
restore := ExportSetH2GoawayTimeout(10 * time.Millisecond)
defer restore()
}
// Not parallel: messes with global variable. (http2goAwayTimeout)
defer afterTest(t)
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
fmt.Fprintf(w, "%v", r.RemoteAddr)
......
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