diff options
| author | Damien Neil <dneil@google.com> | 2025-10-09 15:25:30 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-10-10 08:39:10 -0700 |
| commit | 5368e7742971c8dbcb75a405eb2319e71fb1d0c7 (patch) | |
| tree | 68d3c75bf34890d54a5c54b02fb968c87c9dc08f /src/net/http/requestwrite_test.go | |
| parent | c53cb642deea152e28281133bc0053f5ec0ce358 (diff) | |
| download | go-5368e7742971c8dbcb75a405eb2319e71fb1d0c7.tar.xz | |
net/http: run TestRequestWriteTransport with fake time to avoid flakes
This test verifies whether or not we use the chunked encoding when
sending a request with a body like io.NopCloser(strings.NewReader("")).
This depends on whether the transport can read a single byte from the
request body within 200ms, which is flaky on very slow builders.
Use fake time to avoid flakes.
Fixes #52575
Change-Id: Ie11a58ac6bc18d43af1423827887e804242dee30
Reviewed-on: https://go-review.googlesource.com/c/go/+/710737
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/net/http/requestwrite_test.go')
| -rw-r--r-- | src/net/http/requestwrite_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/net/http/requestwrite_test.go b/src/net/http/requestwrite_test.go index 380ae9dec3..8b097cd5e1 100644 --- a/src/net/http/requestwrite_test.go +++ b/src/net/http/requestwrite_test.go @@ -15,6 +15,7 @@ import ( "strings" "testing" "testing/iotest" + "testing/synctest" "time" ) @@ -667,6 +668,13 @@ func TestRequestWrite(t *testing.T) { func TestRequestWriteTransport(t *testing.T) { t.Parallel() + // Run this test in a synctest bubble, since it relies on the transport + // successfully probing the request body within 200ms + // (see transferWriter.probeRequestBody). + // This occasionally flakes on slow builders (#52575) if we don't use a fake clock. + synctest.Test(t, testRequestWriteTransport) +} +func testRequestWriteTransport(t *testing.T) { matchSubstr := func(substr string) func(string) error { return func(written string) error { if !strings.Contains(written, substr) { |
