diff options
| author | Damien Neil <dneil@google.com> | 2024-05-23 09:05:04 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-05-23 16:36:03 +0000 |
| commit | 3ed007d754b685cd8f6011a8e96a3c9303c785db (patch) | |
| tree | 6165a16e90199a01c0c0734fe3cffe47bfcecdec /src/net/http | |
| parent | 63c1e141bccff884dd9cab51a46c42c1a058fbe2 (diff) | |
| download | go-3ed007d754b685cd8f6011a8e96a3c9303c785db.tar.xz | |
net/http: remove TestTransportDialCancelRace
This test was added to cover a specific race condition
in request cancellation, applying only to the deprecated
Transport.CancelRequest cancellation path. The test
assumes that canceling a request at the moment
persistConn.RoundTrip begins guarantees that it will
be canceled before being sent.
This does not apply to the newer forms of canceling
a request: Request.Cancel and context-based cancellation
both send the cancel signal on a channel, and do not
check for cancellation before sending a request.
A recent refactoring unified the implementation
of cancellation, so the Transport.CancelRequest
path now translates into context-based cancellation
internally. This makes this test flaky, since
sometimes the request completes before we read
from the context's done channel.
Drop the test entirely. It's verifying the fix
for a bug in a code path which no longer exists,
and the property that it's testing for (canceling
a request at a very specific point in the internal
request flow) is not interesting.
Fixes #67533
Change-Id: I8d71540f1b44a64e0621d31a1c545c9351ae897c
Reviewed-on: https://go-review.googlesource.com/c/go/+/587935
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/net/http')
| -rw-r--r-- | src/net/http/transport_test.go | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index 25876e8d16..aa877b57c7 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -4279,30 +4279,6 @@ func testTransportContentEncodingCaseInsensitive(t *testing.T, mode testMode) { } } -func TestTransportDialCancelRace(t *testing.T) { - run(t, testTransportDialCancelRace, testNotParallel, []testMode{http1Mode}) -} -func testTransportDialCancelRace(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) {})).ts - tr := ts.Client().Transport.(*Transport) - - req, err := NewRequest("GET", ts.URL, nil) - if err != nil { - t.Fatal(err) - } - SetEnterRoundTripHook(func() { - tr.CancelRequest(req) - }) - defer SetEnterRoundTripHook(nil) - res, err := tr.RoundTrip(req) - if err != ExportErrRequestCanceled { - t.Errorf("expected canceled request error; got %v", err) - if err == nil { - res.Body.Close() - } - } -} - // https://go.dev/issue/49621 func TestConnClosedBeforeRequestIsWritten(t *testing.T) { run(t, testConnClosedBeforeRequestIsWritten, testNotParallel, []testMode{http1Mode}) |
