1
0
mirror of https://github.com/golang/go synced 2024-11-18 22:55:23 -07:00

net: skip TestDialTimeout subtests on Windows if Dial returns WSAECONNREFUSED

Since we have only seen this failure mode on windows/arm64,
we do not skip on the Go project's windows/amd64 builders
so that we will be more likely to find out whether this failure mode
is specific to arm64.

Also simplify the ECONNRESET check, since I've remembered that the
error_*_test.go files exist.

Fixes #62359.
Updates #56876.

Change-Id: I17bd678486f3d3ec3363a45986a711f570b013d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/524455
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2023-08-30 10:48:09 -04:00 committed by Gopher Robot
parent 2fa7129836
commit a8d45a72eb
4 changed files with 33 additions and 2 deletions

View File

@ -21,3 +21,11 @@ func isPlatformError(err error) bool {
func isENOBUFS(err error) bool {
return false // ENOBUFS is Unix-specific
}
func isECONNRESET(err error) bool {
return false // ECONNRESET is Unix-specific
}
func isWSAECONNREFUSED(err error) bool {
return false // WSAECONNREFUSED is Windows-specific
}

View File

@ -37,3 +37,11 @@ func samePlatformError(err, want error) bool {
func isENOBUFS(err error) bool {
return errors.Is(err, syscall.ENOBUFS)
}
func isECONNRESET(err error) bool {
return errors.Is(err, syscall.ECONNRESET)
}
func isWSAECONNREFUSED(err error) bool {
return false // WSAECONNREFUSED is Windows-specific
}

View File

@ -27,3 +27,12 @@ func isENOBUFS(err error) bool {
// defined in the syscall package we may as well check for it.
return errors.Is(err, syscall.ENOBUFS)
}
func isECONNRESET(err error) bool {
return errors.Is(err, syscall.ECONNRESET)
}
func isWSAECONNREFUSED(err error) bool {
const WSAECONNREFUSED = syscall.Errno(10061)
return errors.Is(err, WSAECONNREFUSED)
}

View File

@ -13,7 +13,6 @@ import (
"io"
"os"
"runtime"
"strings"
"sync"
"testing"
"time"
@ -89,7 +88,7 @@ func TestDialTimeout(t *testing.T) {
}
}
if strings.Contains(err.Error(), "connection reset by peer") && (testenv.Builder() == "" || runtime.GOOS == "freebsd") {
if isECONNRESET(err) && (testenv.Builder() == "" || runtime.GOOS == "freebsd") {
// After we set up the connection on Unix, we make a call to
// getsockopt to retrieve its status. Empirically, on some platforms
// (notably FreeBSD 13), we may see ECONNRESET from that call instead
@ -115,6 +114,13 @@ func TestDialTimeout(t *testing.T) {
t.Skipf("skipping due to ECONNRESET with full accept queue")
}
if isWSAECONNREFUSED(err) && (testenv.Builder() == "" || runtime.GOARCH == "arm64") {
// A similar situation seems to occur on windows/arm64, but returning
// WSAECONNREFUSED from ConnectEx instead of ECONNRESET from getsockopt.
t.Logf("Dial: %v", err)
t.Skipf("skipping due to WSAECONNREFUSED with full accept queue")
}
if d.Deadline.IsZero() || afterDial.Before(d.Deadline) {
delay := afterDial.Sub(beforeDial)
if delay < tt.timeout {