Commit 74604bb5 authored by Elias Naur's avatar Elias Naur Committed by Brad Fitzpatrick

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 <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 67894aa7
...@@ -749,9 +749,8 @@ func TestDialCancel(t *testing.T) { ...@@ -749,9 +749,8 @@ func TestDialCancel(t *testing.T) {
switch testenv.Builder() { switch testenv.Builder() {
case "linux-arm64-buildlet": case "linux-arm64-buildlet":
t.Skip("skipping on linux-arm64-buildlet; incompatible network config? issue 15191") t.Skip("skipping on linux-arm64-buildlet; incompatible network config? issue 15191")
case "":
testenv.MustHaveExternalNetwork(t)
} }
mustHaveExternalNetwork(t)
if runtime.GOOS == "nacl" { if runtime.GOOS == "nacl" {
// nacl doesn't have external network access. // nacl doesn't have external network access.
...@@ -897,9 +896,7 @@ func TestCancelAfterDial(t *testing.T) { ...@@ -897,9 +896,7 @@ func TestCancelAfterDial(t *testing.T) {
// if the machine has halfway configured IPv6 such that it can bind on // if the machine has halfway configured IPv6 such that it can bind on
// "::" not connect back to that same address. // "::" not connect back to that same address.
func TestDialListenerAddr(t *testing.T) { func TestDialListenerAddr(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
ln, err := Listen("tcp", ":0") ln, err := Listen("tcp", ":0")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -912,3 +909,13 @@ func TestDialListenerAddr(t *testing.T) { ...@@ -912,3 +909,13 @@ func TestDialListenerAddr(t *testing.T) {
} }
c.Close() 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)
}
}
...@@ -64,9 +64,7 @@ var backoffDuration = [...]time.Duration{time.Second, 5 * time.Second, 30 * time ...@@ -64,9 +64,7 @@ var backoffDuration = [...]time.Duration{time.Second, 5 * time.Second, 30 * time
func TestLookupGoogleSRV(t *testing.T) { func TestLookupGoogleSRV(t *testing.T) {
t.Parallel() t.Parallel()
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
t.Skip("no resolv.conf on iOS") t.Skip("no resolv.conf on iOS")
...@@ -115,9 +113,7 @@ var lookupGmailMXTests = []struct { ...@@ -115,9 +113,7 @@ var lookupGmailMXTests = []struct {
func TestLookupGmailMX(t *testing.T) { func TestLookupGmailMX(t *testing.T) {
t.Parallel() t.Parallel()
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
t.Skip("no resolv.conf on iOS") t.Skip("no resolv.conf on iOS")
...@@ -163,9 +159,7 @@ var lookupGmailNSTests = []struct { ...@@ -163,9 +159,7 @@ var lookupGmailNSTests = []struct {
func TestLookupGmailNS(t *testing.T) { func TestLookupGmailNS(t *testing.T) {
t.Parallel() t.Parallel()
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
t.Skip("no resolv.conf on iOS") t.Skip("no resolv.conf on iOS")
...@@ -211,9 +205,7 @@ var lookupGmailTXTTests = []struct { ...@@ -211,9 +205,7 @@ var lookupGmailTXTTests = []struct {
func TestLookupGmailTXT(t *testing.T) { func TestLookupGmailTXT(t *testing.T) {
t.Parallel() t.Parallel()
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
t.Skip("no resolv.conf on iOS") t.Skip("no resolv.conf on iOS")
...@@ -261,9 +253,7 @@ var lookupGooglePublicDNSAddrTests = []struct { ...@@ -261,9 +253,7 @@ var lookupGooglePublicDNSAddrTests = []struct {
} }
func TestLookupGooglePublicDNSAddr(t *testing.T) { func TestLookupGooglePublicDNSAddr(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4() || !supportsIPv6() || !*testIPv4 || !*testIPv6 { if !supportsIPv4() || !supportsIPv6() || !*testIPv4 || !*testIPv6 {
t.Skip("both IPv4 and IPv6 are required") t.Skip("both IPv4 and IPv6 are required")
...@@ -322,9 +312,7 @@ var lookupCNAMETests = []struct { ...@@ -322,9 +312,7 @@ var lookupCNAMETests = []struct {
} }
func TestLookupCNAME(t *testing.T) { func TestLookupCNAME(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4() || !*testIPv4 { if !supportsIPv4() || !*testIPv4 {
t.Skip("IPv4 is required") t.Skip("IPv4 is required")
...@@ -362,9 +350,7 @@ var lookupGoogleHostTests = []struct { ...@@ -362,9 +350,7 @@ var lookupGoogleHostTests = []struct {
} }
func TestLookupGoogleHost(t *testing.T) { func TestLookupGoogleHost(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4() || !*testIPv4 { if !supportsIPv4() || !*testIPv4 {
t.Skip("IPv4 is required") t.Skip("IPv4 is required")
...@@ -390,9 +376,7 @@ func TestLookupGoogleHost(t *testing.T) { ...@@ -390,9 +376,7 @@ func TestLookupGoogleHost(t *testing.T) {
func TestLookupLongTXT(t *testing.T) { func TestLookupLongTXT(t *testing.T) {
testenv.SkipFlaky(t, 22857) testenv.SkipFlaky(t, 22857)
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
defer dnsWaitGroup.Wait() defer dnsWaitGroup.Wait()
...@@ -418,9 +402,7 @@ var lookupGoogleIPTests = []struct { ...@@ -418,9 +402,7 @@ var lookupGoogleIPTests = []struct {
} }
func TestLookupGoogleIP(t *testing.T) { func TestLookupGoogleIP(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4() || !*testIPv4 { if !supportsIPv4() || !*testIPv4 {
t.Skip("IPv4 is required") t.Skip("IPv4 is required")
...@@ -566,9 +548,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { ...@@ -566,9 +548,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) {
t.Skip("IPv4 is required") t.Skip("IPv4 is required")
} }
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
defer dnsWaitGroup.Wait() defer dnsWaitGroup.Wait()
...@@ -609,9 +589,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { ...@@ -609,9 +589,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) {
} }
func TestLookupDotsWithRemoteSource(t *testing.T) { func TestLookupDotsWithRemoteSource(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4() || !*testIPv4 { if !supportsIPv4() || !*testIPv4 {
t.Skip("IPv4 is required") t.Skip("IPv4 is required")
...@@ -864,9 +842,7 @@ func TestLookupNonLDH(t *testing.T) { ...@@ -864,9 +842,7 @@ func TestLookupNonLDH(t *testing.T) {
} }
func TestLookupContextCancel(t *testing.T) { func TestLookupContextCancel(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "nacl" { if runtime.GOOS == "nacl" {
t.Skip("skip on nacl") t.Skip("skip on nacl")
} }
...@@ -891,9 +867,7 @@ func TestLookupContextCancel(t *testing.T) { ...@@ -891,9 +867,7 @@ func TestLookupContextCancel(t *testing.T) {
// Issue 24330: treat the nil *Resolver like a zero value. Verify nothing // Issue 24330: treat the nil *Resolver like a zero value. Verify nothing
// crashes if nil is used. // crashes if nil is used.
func TestNilResolverLookup(t *testing.T) { func TestNilResolverLookup(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "nacl" { if runtime.GOOS == "nacl" {
t.Skip("skip on nacl") t.Skip("skip on nacl")
} }
...@@ -915,9 +889,7 @@ func TestNilResolverLookup(t *testing.T) { ...@@ -915,9 +889,7 @@ func TestNilResolverLookup(t *testing.T) {
// TestLookupHostCancel verifies that lookup works even after many // TestLookupHostCancel verifies that lookup works even after many
// canceled lookups (see golang.org/issue/24178 for details). // canceled lookups (see golang.org/issue/24178 for details).
func TestLookupHostCancel(t *testing.T) { func TestLookupHostCancel(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
if runtime.GOOS == "nacl" { if runtime.GOOS == "nacl" {
t.Skip("skip on nacl") t.Skip("skip on nacl")
} }
......
...@@ -8,7 +8,6 @@ package net ...@@ -8,7 +8,6 @@ package net
import ( import (
"context" "context"
"internal/testenv"
"math/rand" "math/rand"
"runtime" "runtime"
"sync" "sync"
...@@ -84,9 +83,8 @@ func TestTCPSpuriousConnSetupCompletion(t *testing.T) { ...@@ -84,9 +83,8 @@ func TestTCPSpuriousConnSetupCompletion(t *testing.T) {
// Issue 19289. // Issue 19289.
// Test that a canceled Dial does not cause a subsequent Dial to succeed. // Test that a canceled Dial does not cause a subsequent Dial to succeed.
func TestTCPSpuriousConnSetupCompletionWithCancel(t *testing.T) { func TestTCPSpuriousConnSetupCompletionWithCancel(t *testing.T) {
if testenv.Builder() == "" { mustHaveExternalNetwork(t)
testenv.MustHaveExternalNetwork(t)
}
defer dnsWaitGroup.Wait() defer dnsWaitGroup.Wait()
t.Parallel() t.Parallel()
const tries = 10000 const tries = 10000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment