mirror of
https://github.com/golang/go
synced 2024-11-17 18:54:42 -07:00
net: make TestGoLookupIPWithResolverConfig robust
It crashes when the node under the test is shaken up. -- FAIL: TestGoLookupIPWithResolverConfig (11.73s) panic: interface conversion: error is nil, not *net.DNSError [recovered] panic: interface conversion: error is nil, not *net.DNSError goroutine 23 [running]: panic(0x2e2620, 0xc820181440) /go/src/runtime/panic.go:483 +0x3f3 testing.tRunner.func1(0xc820136d80) /go/src/testing/testing.go:467 +0x192 panic(0x2e2620, 0xc820181440) /go/src/runtime/panic.go:441 +0x4f6 net.TestGoLookupIPWithResolverConfig(0xc820136d80) /go/src/net/dnsclient_unix_test.go:358 +0x7ca testing.tRunner(0xc820136d80, 0x49ddc0) /go/src/testing/testing.go:473 +0x98 created by testing.RunTests /go/src/testing/testing.go:582 +0x892 exit status 2 Change-Id: I9631f41a3c73f3269c7e30d679c025ae64d71a98 Reviewed-on: https://go-review.googlesource.com/19870 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7c90abe206
commit
b48120ca3a
@ -355,7 +355,13 @@ func TestGoLookupIPWithResolverConfig(t *testing.T) {
|
||||
}
|
||||
addrs, err := goLookupIP(tt.name)
|
||||
if err != nil {
|
||||
if err, ok := err.(*DNSError); !ok || (err.Name != tt.error.(*DNSError).Name || err.Server != tt.error.(*DNSError).Server || err.IsTimeout != tt.error.(*DNSError).IsTimeout) {
|
||||
// This test uses external network connectivity.
|
||||
// We need to take care with errors on both
|
||||
// DNS message exchange layer and DNS
|
||||
// transport layer because goLookupIP may fail
|
||||
// when the IP connectivty on node under test
|
||||
// gets lost during its run.
|
||||
if err, ok := err.(*DNSError); !ok || tt.error != nil && (err.Name != tt.error.(*DNSError).Name || err.Server != tt.error.(*DNSError).Server || err.IsTimeout != tt.error.(*DNSError).IsTimeout) {
|
||||
t.Errorf("got %v; want %v", err, tt.error)
|
||||
}
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user