net/http/internal/http2: skip TestTransportNewClientConnCloseOnWriteError

Rewrote this test to use newTestClientConn, discovered that the assertion
that it's supposed to make (if a write to a conn fails, the conn is closed)
doesn't hold for all writes.

Skip the amended test for now.

For #67810

Change-Id: I1b696afcd2ba86ed631ee5f32c48b2366a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/753842
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Damien Neil
2026-03-10 14:02:10 -07:00
committed by Gopher Robot
parent 2cd24ace83
commit 81908597a8

View File

@@ -3850,31 +3850,36 @@ func testTransportBodyLargerThanSpecifiedContentLength(t testing.TB, body *chunk
}
}
type fakeConnErr struct {
net.Conn
writeErr error
closed bool
}
func (fce *fakeConnErr) Write(b []byte) (n int, err error) {
return 0, fce.writeErr
}
func (fce *fakeConnErr) Close() error {
fce.closed = true
return nil
}
// issue 39337: close the connection on a failed write
func TestTransportNewClientConnCloseOnWriteError(t *testing.T) {
tr := &Transport{}
synctestTest(t, testTransportNewClientConnCloseOnWriteError)
}
func testTransportNewClientConnCloseOnWriteError(t testing.TB) {
// The original version of this test verifies that we close a connection
// if we fail to write the client preface, SETTINGS, and WINDOW_UPDATE.
//
// The current version of this test instead tests what happens if we fail to
// write the ack for a SETTINGS sent by the server. Currently, we do nothing.
//
// Skip the test for the moment, but we should fix this.
t.Skip("TODO: test fails because write errors don't cause the conn to close")
tc := newTestClientConn(t)
synctest.Wait()
writeErr := errors.New("write error")
fakeConn := &fakeConnErr{writeErr: writeErr}
_, err := tr.NewClientConn(fakeConn)
if err != writeErr {
t.Fatalf("expected %v, got %v", writeErr, err)
}
if !fakeConn.closed {
tc.netconn.loc.setWriteError(writeErr)
tc.writeSettings()
tc.wantIdle()
// Write settings to the conn; its attempt to write an ack fails.
tc.wantFrameType(FrameSettings)
tc.wantFrameType(FrameWindowUpdate)
tc.wantIdle()
synctest.Wait()
if !tc.netconn.IsClosedByPeer() {
t.Error("expected closed conn")
}
}