Skip to content
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

net/http/httputil: TestDumpRequest fails for count=2 #26858

Closed
randall77 opened this issue Aug 8, 2018 · 2 comments
Closed

net/http/httputil: TestDumpRequest fails for count=2 #26858

randall77 opened this issue Aug 8, 2018 · 2 comments
Labels
FrozenDueToAge help wanted Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@randall77
Copy link
Contributor

$ ../bin/go test net/http/httputil -count=2
--- FAIL: TestDumpRequest (0.00s)
    dump_test.go:224: DumpRequest #7: http: invalid Read on closed Body
FAIL
FAIL	net/http/httputil	0.059s

The test seems to fail n-1 times for any count n >= 2.

@randall77 randall77 added the Testing An issue that has been verified to require only test changes, not just a test failure. label Aug 8, 2018
@randall77 randall77 added this to the Go1.12 milestone Aug 8, 2018
@gopherbot
Copy link

Change https://golang.org/cl/128478 mentions this issue: net/http/httputil: fix TestDumpRequest fails for count equal th…

@odeke-em odeke-em self-assigned this Dec 9, 2018
@gopherbot
Copy link

Change https://golang.org/cl/153377 mentions this issue: net/http/httputil: make TestDumpRequest idempotent

@bradfitz bradfitz modified the milestones: Go1.12, Go1.13 Jan 30, 2019
nebulabox pushed a commit to nebulabox/go that referenced this issue Feb 18, 2019
TestDumpRequest was failing with -count=2 or more
because for test cases that involved mustReadRequest,
the body was created as a *bufio.Reader. DumpRequest
and DumpRequestOut would then read the body until EOF
and would close it after use.
However, on re-runs of the test, the body would
be terminally exhausted and result in an unexpected
error "http: invalid Read on closed Body".

The update to the test cases adds an extra field "GetReq"
which allows us to construct requests per run of the tests
and hence make the test indefinitely re-runnable/idempotent.
"Req" or "GetReq" are mutually exclusive: either one of them
can be set or nil, but not both.

Fixes golang#26858

Change-Id: Ice3083dac1aa3249da4afc7075cd984eb159530d
Reviewed-on: https://go-review.googlesource.com/c/153377
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
nebulabox pushed a commit to nebulabox/go that referenced this issue Feb 20, 2019
TestDumpRequest was failing with -count=2 or more
because for test cases that involved mustReadRequest,
the body was created as a *bufio.Reader. DumpRequest
and DumpRequestOut would then read the body until EOF
and would close it after use.
However, on re-runs of the test, the body would
be terminally exhausted and result in an unexpected
error "http: invalid Read on closed Body".

The update to the test cases adds an extra field "GetReq"
which allows us to construct requests per run of the tests
and hence make the test indefinitely re-runnable/idempotent.
"Req" or "GetReq" are mutually exclusive: either one of them
can be set or nil, but not both.

Fixes golang#26858

Change-Id: Ice3083dac1aa3249da4afc7075cd984eb159530d
Reviewed-on: https://go-review.googlesource.com/c/153377
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

5 participants