From 74604bb517b8615331aae44166e0368b25f6a4cb Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 17 May 2018 15:20:57 +0200 Subject: [PATCH] net: skip external net tests on iOS CL 113095 tried to deflake net tests on iOS by skipping the test that uses the most sockets. That didn't work well enough and will be reverted in CL 113555. The flakes appeared after the iOS exec harness started to forward environment variables, causing testenv.Builder to be non-empty on the iOS builder. This CL attempts to fix the flakes with the more conservative strategy of skipping tests that only run on builders. The skipped tests happen to be those requiring external network access; it's plausible that the iOS builder network isn't reliable enough to run the many parallel DNS lookups and dial outs, while keeping the number of open file descriptors below the 250 limit. Change-Id: I9cafdaf2845dd6f3844c4819dcaaaa5970f5da15 Reviewed-on: https://go-review.googlesource.com/113575 Run-TryBot: Elias Naur TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/net/dial_test.go | 17 +++++++---- src/net/lookup_test.go | 56 +++++++++--------------------------- src/net/tcpsock_unix_test.go | 6 ++-- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/src/net/dial_test.go b/src/net/dial_test.go index b5f1dc9e98..811e417cd7 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -749,9 +749,8 @@ func TestDialCancel(t *testing.T) { switch testenv.Builder() { case "linux-arm64-buildlet": t.Skip("skipping on linux-arm64-buildlet; incompatible network config? issue 15191") - case "": - testenv.MustHaveExternalNetwork(t) } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { // nacl doesn't have external network access. @@ -897,9 +896,7 @@ func TestCancelAfterDial(t *testing.T) { // if the machine has halfway configured IPv6 such that it can bind on // "::" not connect back to that same address. func TestDialListenerAddr(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) ln, err := Listen("tcp", ":0") if err != nil { t.Fatal(err) @@ -912,3 +909,13 @@ func TestDialListenerAddr(t *testing.T) { } c.Close() } + +// mustHaveExternalNetwork is like testenv.MustHaveExternalNetwork +// except that it won't skip testing on non-iOS builders. +func mustHaveExternalNetwork(t *testing.T) { + t.Helper() + ios := runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") + if testenv.Builder() == "" || ios { + testenv.MustHaveExternalNetwork(t) + } +} diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 521c5720ba..75fb303d38 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -64,9 +64,7 @@ var backoffDuration = [...]time.Duration{time.Second, 5 * time.Second, 30 * time func TestLookupGoogleSRV(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -115,9 +113,7 @@ var lookupGmailMXTests = []struct { func TestLookupGmailMX(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -163,9 +159,7 @@ var lookupGmailNSTests = []struct { func TestLookupGmailNS(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -211,9 +205,7 @@ var lookupGmailTXTTests = []struct { func TestLookupGmailTXT(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -261,9 +253,7 @@ var lookupGooglePublicDNSAddrTests = []struct { } func TestLookupGooglePublicDNSAddr(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !supportsIPv6() || !*testIPv4 || !*testIPv6 { t.Skip("both IPv4 and IPv6 are required") @@ -322,9 +312,7 @@ var lookupCNAMETests = []struct { } func TestLookupCNAME(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -362,9 +350,7 @@ var lookupGoogleHostTests = []struct { } func TestLookupGoogleHost(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -390,9 +376,7 @@ func TestLookupGoogleHost(t *testing.T) { func TestLookupLongTXT(t *testing.T) { testenv.SkipFlaky(t, 22857) - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) defer dnsWaitGroup.Wait() @@ -418,9 +402,7 @@ var lookupGoogleIPTests = []struct { } func TestLookupGoogleIP(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -566,9 +548,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { t.Skip("IPv4 is required") } - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) defer dnsWaitGroup.Wait() @@ -609,9 +589,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { } func TestLookupDotsWithRemoteSource(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -864,9 +842,7 @@ func TestLookupNonLDH(t *testing.T) { } func TestLookupContextCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } @@ -891,9 +867,7 @@ func TestLookupContextCancel(t *testing.T) { // Issue 24330: treat the nil *Resolver like a zero value. Verify nothing // crashes if nil is used. func TestNilResolverLookup(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } @@ -915,9 +889,7 @@ func TestNilResolverLookup(t *testing.T) { // TestLookupHostCancel verifies that lookup works even after many // canceled lookups (see golang.org/issue/24178 for details). func TestLookupHostCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } diff --git a/src/net/tcpsock_unix_test.go b/src/net/tcpsock_unix_test.go index 95c02d2721..8d8e4e8eb8 100644 --- a/src/net/tcpsock_unix_test.go +++ b/src/net/tcpsock_unix_test.go @@ -8,7 +8,6 @@ package net import ( "context" - "internal/testenv" "math/rand" "runtime" "sync" @@ -84,9 +83,8 @@ func TestTCPSpuriousConnSetupCompletion(t *testing.T) { // Issue 19289. // Test that a canceled Dial does not cause a subsequent Dial to succeed. func TestTCPSpuriousConnSetupCompletionWithCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) + defer dnsWaitGroup.Wait() t.Parallel() const tries = 10000 -- 2.50.0