From: Damien Neil Date: Thu, 9 Oct 2025 22:25:30 +0000 (-0700) Subject: net/http: run TestRequestWriteTransport with fake time to avoid flakes X-Git-Tag: go1.26rc1~647 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5368e7742971c8dbcb75a405eb2319e71fb1d0c7;p=gostls13.git 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 Reviewed-by: Nicholas Husin Reviewed-by: Nicholas Husin LUCI-TryBot-Result: Go LUCI --- 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) {