-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: deflake TestCancelRequestWhenSharingConnection #56500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The test sleeps for 1 millisecond to give the cancellation a moment to take effect. This is flaky because the request can finish before the cancellation of the context is seen. It's easy to verify by adding time.Sleep(2*time.Millisecond) after https://github.com/golang/go/blob/0a6c4c87404ecb018faf002919e5d5db04c69ee2/src/net/http/transport.go#L2619. With this modification, the test fails about 5 times out of 10 runs. The fix is easy. We just need to block the handler of the second request until this request is cancelled. I have verify that the updated test can uncover the issue fixed by CL 257818.
This PR (HEAD: 99cb1c2) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/446676 to see it. Tip: You can toggle comments from me using the |
Message from Bryan Mills: Patch Set 1: Run-TryBot+1 Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/446676. |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/446676. |
Message from Gopher Robot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/446676. |
The test sleeps for 1 millisecond to give the cancellation a moment to take effect. This is flaky because the request can finish before the cancellation of the context is seen. It's easy to verify by adding time.Sleep(2*time.Millisecond) after https://github.com/golang/go/blob/0a6c4c87404ecb018faf002919e5d5db04c69ee2/src/net/http/transport.go#L2619. With this modification, the test fails about 5 times out of 10 runs. The fix is easy. We just need to block the handler of the second request until this request is cancelled. I have verify that the updated test can uncover the issue fixed by CL 257818. Fixes #55226. Change-Id: I81575beef1a920a2ffaa5c6a5ca70a4008bd5f94 GitHub-Last-Rev: 99cb1c2 GitHub-Pull-Request: #56500 Reviewed-on: https://go-review.googlesource.com/c/go/+/446676 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
This PR is being closed because golang.org/cl/446676 has been merged. |
The test sleeps for 1 millisecond to give the cancellation a moment to take effect. This is flaky because the request can finish before the cancellation of the context is seen. It's easy to verify by adding time.Sleep(2*time.Millisecond) after https://github.com/golang/go/blob/0a6c4c87404ecb018faf002919e5d5db04c69ee2/src/net/http/transport.go#L2619. With this modification, the test fails about 5 times out of 10 runs. The fix is easy. We just need to block the handler of the second request until this request is cancelled. I have verify that the updated test can uncover the issue fixed by CL 257818. Fixes golang#55226. Change-Id: I81575beef1a920a2ffaa5c6a5ca70a4008bd5f94 GitHub-Last-Rev: 99cb1c2 GitHub-Pull-Request: golang#56500 Reviewed-on: https://go-review.googlesource.com/c/go/+/446676 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
The test sleeps for 1 millisecond to give the cancellation a moment
to take effect. This is flaky because the request can finish before
the cancellation of the context is seen. It's easy to verify by adding
after
go/src/net/http/transport.go
Line 2619 in 0a6c4c8
With this modification, the test fails about 5 times out of 10 runs.
The fix is easy. We just need to block the handler of the second
request until this request is cancelled. I have verify that the
updated test can uncover the issue fixed by CL 257818.
Fixes #55226.