]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: ignore ECONNRESET errors in TestTransportConcurrency on netbsd
authorBryan C. Mills <bcmills@google.com>
Wed, 6 Apr 2022 16:03:37 +0000 (12:03 -0400)
committerBryan Mills <bcmills@google.com>
Wed, 6 Apr 2022 20:46:47 +0000 (20:46 +0000)
The source of these errors is undiagnosed, but they have only been
observed on netbsd builders (on a variety of architectures).

Tested manually by injecting this code into the test's handler:

if mrand.Intn(4) == 0 {
if conn, _, err := w.(Hijacker).Hijack(); err == nil {
conn.(*net.TCPConn).SetLinger(0)
conn.Close()
return
}
}

and temporarily disabling the 'runtime.GOOS' part of the condition.

For #52168.

Change-Id: I10965803e5a0d493ac4a000575de8b5f0266989c
Reviewed-on: https://go-review.googlesource.com/c/go/+/398635
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/http/transport_test.go

index 440d6b969b08aa9d0603df8243194bc305835c02..84065c70851eb7ebfb55c6f85ccf3a1ce8d6e7b5 100644 (file)
@@ -2099,17 +2099,21 @@ func TestTransportConcurrency(t *testing.T) {
                        for req := range reqs {
                                res, err := c.Get(ts.URL + "/?echo=" + req)
                                if err != nil {
-                                       t.Errorf("error on req %s: %v", req, err)
+                                       if runtime.GOOS == "netbsd" && strings.HasSuffix(err.Error(), ": connection reset by peer") {
+                                               // https://go.dev/issue/52168: this test was observed to fail with
+                                               // ECONNRESET errors in Dial on various netbsd builders.
+                                               t.Logf("error on req %s: %v", req, err)
+                                               t.Logf("(see https://go.dev/issue/52168)")
+                                       } else {
+                                               t.Errorf("error on req %s: %v", req, err)
+                                       }
                                        wg.Done()
                                        continue
                                }
                                all, err := io.ReadAll(res.Body)
                                if err != nil {
                                        t.Errorf("read error on req %s: %v", req, err)
-                                       wg.Done()
-                                       continue
-                               }
-                               if string(all) != req {
+                               } else if string(all) != req {
                                        t.Errorf("body of req %s = %q; want %q", req, all, req)
                                }
                                res.Body.Close()