diff options
| author | Damien Neil <dneil@google.com> | 2026-03-10 14:02:10 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-12 08:10:51 -0700 |
| commit | 81908597a8787b09b1da90e7c6d3461b4302820f (patch) | |
| tree | 215cd17c7badc2effa483879de26b6856fa2543e /src/net/http | |
| parent | 2cd24ace83bb8055280b9302efb1a21a14d7c763 (diff) | |
| download | go-81908597a8787b09b1da90e7c6d3461b4302820f.tar.xz | |
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>
Diffstat (limited to 'src/net/http')
| -rw-r--r-- | src/net/http/internal/http2/transport_test.go | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/net/http/internal/http2/transport_test.go b/src/net/http/internal/http2/transport_test.go index 28501c9ca0..faae10e6a4 100644 --- a/src/net/http/internal/http2/transport_test.go +++ b/src/net/http/internal/http2/transport_test.go @@ -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 +// issue 39337: close the connection on a failed write +func TestTransportNewClientConnCloseOnWriteError(t *testing.T) { + 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") -func (fce *fakeConnErr) Close() error { - fce.closed = true - return nil -} + tc := newTestClientConn(t) -// issue 39337: close the connection on a failed write -func TestTransportNewClientConnCloseOnWriteError(t *testing.T) { - tr := &Transport{} + 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") } } |
