Commit c6687153 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: shorten and clean up TestTransportConcurrency

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7817044
parent ba50e4f1
......@@ -941,14 +941,17 @@ func TestChunkedNoContent(t *testing.T) {
func TestTransportConcurrency(t *testing.T) {
defer afterTest(t)
const maxProcs = 16
const numReqs = 500
maxProcs, numReqs := 16, 500
if testing.Short() {
maxProcs, numReqs = 4, 50
}
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs))
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
fmt.Fprintf(w, "%v", r.FormValue("echo"))
}))
defer ts.Close()
tr := &Transport{}
defer tr.CloseIdleConnections()
c := &Client{Transport: tr}
reqs := make(chan string)
defer close(reqs)
......@@ -973,8 +976,8 @@ func TestTransportConcurrency(t *testing.T) {
if string(all) != req {
t.Errorf("body of req %s = %q; want %q", req, all, req)
}
wg.Done()
res.Body.Close()
wg.Done()
}
}()
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment