Skip to content

Commit

Permalink
[internal-branch.go1.17-vendor] http2: don't rely on system TCP buffe…
Browse files Browse the repository at this point in the history
…r sizes in TestServer_MaxQueuedControlFrames

This test relies on filling up a TCP write buffer, but buffer sizes aren't
under our control and can be large. Use a net.Conn wrapper that blocks instead.

Updates golang/go#49077

Change-Id: I72471ef293f906b33f2a0fd81d69a3dd57f32fde
Reviewed-on: https://go-review.googlesource.com/c/net/+/349932
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/net/+/357688
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
neild authored and dmitshur committed Oct 29, 2021
1 parent 2187e36 commit 1031437
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,12 +1185,34 @@ func TestServer_Ping(t *testing.T) {
}
}

type filterListener struct {
net.Listener
accept func(conn net.Conn) (net.Conn, error)
}

func (l *filterListener) Accept() (net.Conn, error) {
c, err := l.Listener.Accept()
if err != nil {
return nil, err
}
return l.accept(c)
}

func TestServer_MaxQueuedControlFrames(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}

st := newServerTester(t, nil)
st := newServerTester(t, nil, func(ts *httptest.Server) {
// TCP buffer sizes on test systems aren't under our control and can be large.
// Create a conn that blocks after 10000 bytes written.
ts.Listener = &filterListener{
Listener: ts.Listener,
accept: func(conn net.Conn) (net.Conn, error) {
return newBlockingWriteConn(conn, 10000), nil
},
}
})
defer st.Close()
st.greet()

Expand Down

0 comments on commit 1031437

Please sign in to comment.