net/http/internal/http2: remove ExportSetH2GoawayTimeout

This was used by one test. Rewrite that test to use synctest (faster!)
and not care about the timeout.

For #67810

Change-Id: I61496e575ae8a16ff778470f3f9d711e6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751303
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
This commit is contained in:
Damien Neil
2026-03-03 11:26:47 -08:00
committed by Gopher Robot
parent 4498bf1a90
commit b8cdabcf99
2 changed files with 7 additions and 23 deletions

View File

@@ -292,12 +292,6 @@ 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 }
}
func (r *Request) ExportIsReplayable() bool { return r.isReplayable() }
// ExportCloseTransportConnsAbruptly closes all idle connections from

View File

@@ -6011,27 +6011,17 @@ func TestServerCloseDeadlock(t *testing.T) {
// Issue 17717: tests that Server.SetKeepAlivesEnabled is respected by
// both HTTP/1 and HTTP/2.
func TestServerKeepAlivesEnabled(t *testing.T) { run(t, testServerKeepAlivesEnabled, testNotParallel) }
func TestServerKeepAlivesEnabled(t *testing.T) { runSynctest(t, testServerKeepAlivesEnabled) }
func testServerKeepAlivesEnabled(t *testing.T, mode testMode) {
if mode == http2Mode {
restore := ExportSetH2GoawayTimeout(10 * time.Millisecond)
defer restore()
}
// Not parallel: messes with global variable. (http2goAwayTimeout)
cst := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) {}))
cst := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) {}), optFakeNet)
defer cst.close()
srv := cst.ts.Config
srv.SetKeepAlivesEnabled(false)
for try := 0; try < 2; try++ {
waitCondition(t, 10*time.Millisecond, func(d time.Duration) bool {
if !srv.ExportAllConnsIdle() {
if d > 0 {
t.Logf("test server still has active conns after %v", d)
}
return false
}
return true
})
for try := range 2 {
synctest.Wait()
if !srv.ExportAllConnsIdle() {
t.Fatalf("test server still has active conns before request %v", try)
}
conns := 0
var info httptrace.GotConnInfo
ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{