From a8d45a72eb7a204ff9e8189eb54d7ea3da1ea7a7 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 30 Aug 2023 10:48:09 -0400 Subject: [PATCH] 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 Auto-Submit: Bryan Mills Reviewed-by: Damien Neil LUCI-TryBot-Result: Go LUCI Run-TryBot: Bryan Mills --- src/net/error_plan9_test.go | 8 ++++++++ src/net/error_unix_test.go | 8 ++++++++ src/net/error_windows_test.go | 9 +++++++++ src/net/timeout_test.go | 10 ++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/net/error_plan9_test.go b/src/net/error_plan9_test.go index 1270af19e54..aa3912c332a 100644 --- a/src/net/error_plan9_test.go +++ b/src/net/error_plan9_test.go @@ -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 +} diff --git a/src/net/error_unix_test.go b/src/net/error_unix_test.go index 291a7234f21..20daf13c188 100644 --- a/src/net/error_unix_test.go +++ b/src/net/error_unix_test.go @@ -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 +} diff --git a/src/net/error_windows_test.go b/src/net/error_windows_test.go index 25825f96f80..e99ea492bba 100644 --- a/src/net/error_windows_test.go +++ b/src/net/error_windows_test.go @@ -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) +} diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index 4218025fc09..cee1f49a05e 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -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 {