aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2026-03-03 11:26:47 -0800
committerGopher Robot <gobot@golang.org>2026-03-12 08:09:45 -0700
commitb8cdabcf99218c50a08d12a80f8b0ff8171ee2e3 (patch)
treec04bc94c9e9921122ab6c6081571fa90f6db7d1f
parent4498bf1a90bb693f256e991204d082f16d103eb0 (diff)
downloadgo-b8cdabcf99218c50a08d12a80f8b0ff8171ee2e3.tar.xz
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>
-rw-r--r--src/net/http/export_test.go6
-rw-r--r--src/net/http/serve_test.go24
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{