1
0
mirror of https://github.com/golang/go synced 2024-11-18 04:04:49 -07:00

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: Tom Bergan <tombergan@google.com>
This commit is contained in:
Brad Fitzpatrick 2017-12-01 19:42:55 +00:00
parent 496688b3cf
commit 8ba0933a69
2 changed files with 11 additions and 1 deletions

View File

@ -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 }
}

View File

@ -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)