From: Brad Fitzpatrick Date: Wed, 25 Jan 2012 20:31:06 +0000 (-0800) Subject: net/http: disabled test for Transport race / deadlock bug X-Git-Tag: weekly.2012-01-27~44 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cf09a9d3bfbdf82ba67419b7efbf188651786271;p=gostls13.git net/http: disabled test for Transport race / deadlock bug The real fix for Issue 2616 is in https://golang.org/cl/5532057, to be submitted following this CL, without the test there which doesn't work reliably. This one seems to. R=rsc CC=golang-dev https://golang.org/cl/5569063 --- diff --git a/src/pkg/net/http/transport_test.go b/src/pkg/net/http/transport_test.go index ff12fa2d01..8f63bdbdb7 100644 --- a/src/pkg/net/http/transport_test.go +++ b/src/pkg/net/http/transport_test.go @@ -304,6 +304,66 @@ func TestTransportServerClosingUnexpectedly(t *testing.T) { } } +// Test for http://golang.org/issue/2616 (appropriate issue number) +// This fails pretty reliably with GOMAXPROCS=100 or something high. +func TestStressSurpriseServerCloses(t *testing.T) { + if true { + t.Logf("known broken test; fix coming. Issue 2616") + return + } + if testing.Short() { + t.Logf("skipping test in short mode") + return + } + ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { + w.Header().Set("Content-Length", "5") + w.Header().Set("Content-Type", "text/plain") + w.Write([]byte("Hello")) + w.(Flusher).Flush() + conn, buf, _ := w.(Hijacker).Hijack() + buf.Flush() + conn.Close() + })) + defer ts.Close() + + tr := &Transport{DisableKeepAlives: false} + c := &Client{Transport: tr} + + // Do a bunch of traffic from different goroutines. Send to activityc + // after each request completes, regardless of whether it failed. + const ( + numClients = 50 + reqsPerClient = 250 + ) + activityc := make(chan bool) + for i := 0; i < numClients; i++ { + go func() { + for i := 0; i < reqsPerClient; i++ { + res, err := c.Get(ts.URL) + if err == nil { + // We expect errors since the server is + // hanging up on us after telling us to + // send more requests, so we don't + // actually care what the error is. + // But we want to close the body in cases + // where we won the race. + res.Body.Close() + } + activityc <- true + } + }() + } + + // Make sure all the request come back, one way or another. + for i := 0; i < numClients*reqsPerClient; i++ { + select { + case <-activityc: + case <-time.After(5 * time.Second): + t.Fatalf("presumed deadlock; no HTTP client activity seen in awhile") + } + } +} + // TestTransportHeadResponses verifies that we deal with Content-Lengths // with no bodies properly func TestTransportHeadResponses(t *testing.T) {