diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-12-03 11:44:00 -0500 |
---|---|---|
committer | Bryan Mills <bcmills@google.com> | 2021-12-13 15:48:26 +0000 |
commit | f4ca598c9f08a4d00942a1c6a6b8cc7d8f162b66 (patch) | |
tree | 487795f1f63a635c5529f3dbed579054bb7279f1 /src/net | |
parent | 6f42be78bbc107beef8b6eb61a794355e07120ca (diff) | |
download | go-f4ca598c9f08a4d00942a1c6a6b8cc7d8f162b66.tar.gz go-f4ca598c9f08a4d00942a1c6a6b8cc7d8f162b66.zip |
net: don't check "invalid.invalid" lookup errors in TestLookupHostCancel
The exact error isn't actually relevant to the test,
and may depend on whether the Go or cgo resolver is used.
Also run the test in parallel, because it spends most of its time
sleeping in between lookups.
Fixes #38767
Fixes #43140
Change-Id: I2d64ffddf2eb114a69ed3242daa9a9e4a5679f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/369037
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>
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/lookup_test.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 7bcc5c5be8..5b3a3e24b2 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -925,6 +925,8 @@ func TestNilResolverLookup(t *testing.T) { // canceled lookups (see golang.org/issue/24178 for details). func TestLookupHostCancel(t *testing.T) { mustHaveExternalNetwork(t) + t.Parallel() // Executes 600ms worth of sequential sleeps. + const ( google = "www.google.com" invalidDomain = "invalid.invalid" // RFC 2606 reserves .invalid @@ -943,9 +945,15 @@ func TestLookupHostCancel(t *testing.T) { if err == nil { t.Fatalf("LookupHost(%q): returns %v, but should fail", invalidDomain, addr) } - if !strings.Contains(err.Error(), "canceled") { - t.Fatalf("LookupHost(%q): failed with unexpected error: %v", invalidDomain, err) - } + + // Don't verify what the actual error is. + // We know that it must be non-nil because the domain is invalid, + // but we don't have any guarantee that LookupHost actually bothers + // to check for cancellation on the fast path. + // (For example, it could use a local cache to avoid blocking entirely.) + + // The lookup may deduplicate in-flight requests, so give it time to settle + // in between. time.Sleep(time.Millisecond * 1) } |