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

Comments

Projects
None yet
5 participants
@randall77
Copy link
Contributor

randall77 commented Aug 8, 2018

$ ../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.

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Aug 8, 2018

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

This comment has been minimized.

Copy link

gopherbot commented Dec 9, 2018

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

@gopherbot gopherbot closed this in b690d7e Feb 13, 2019

nebulabox added a commit to nebulabox/go that referenced this issue Feb 18, 2019

net/http/httputil: make TestDumpRequest idempotent
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 added a commit to nebulabox/go that referenced this issue Feb 20, 2019

net/http/httputil: make TestDumpRequest idempotent
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.