From b8cdabcf99218c50a08d12a80f8b0ff8171ee2e3 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 3 Mar 2026 11:26:47 -0800 Subject: [PATCH] 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 LUCI-TryBot-Result: Go LUCI Auto-Submit: Damien Neil Reviewed-by: Nicholas Husin --- src/net/http/export_test.go | 6 ------ src/net/http/serve_test.go | 24 +++++++----------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index 5492a97a98..472d9c37ae 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -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 diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index 6ade598834..9ad3fdfd2d 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -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{