diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index f57e0c1585..1825acd9be 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -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 } +} diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index 174f6845aa..1ffa411500 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -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)