net/netcheck: reenable TestNodeAddrResolve on Windows
Updates #7876 Co-authored-by: Andrew Dunham <andrew@du.nham.ca> Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Signed-off-by: James Tucker <james@tailscale.com> Change-Id: Idb2e6cc2edf6ca123b751d6c8f8729b0cba86023
This commit is contained in:
parent
80b138f0df
commit
c5150eae67
|
@ -830,9 +830,6 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNodeAddrResolve(t *testing.T) {
|
func TestNodeAddrResolve(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("TODO(#7876): test regressed on windows while CI was broken")
|
|
||||||
}
|
|
||||||
c := &Client{
|
c := &Client{
|
||||||
Logf: t.Logf,
|
Logf: t.Logf,
|
||||||
UDPBindAddr: "127.0.0.1:0",
|
UDPBindAddr: "127.0.0.1:0",
|
||||||
|
@ -852,6 +849,29 @@ func TestNodeAddrResolve(t *testing.T) {
|
||||||
// No IPv4 or IPv6 addrs
|
// No IPv4 or IPv6 addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks whether IPv6 and IPv6 DNS resolution works on this platform.
|
||||||
|
ipv6Works := func(t *testing.T) bool {
|
||||||
|
// Verify that we can create an IPv6 socket.
|
||||||
|
ln, err := net.ListenPacket("udp6", "[::1]:0")
|
||||||
|
if err != nil {
|
||||||
|
t.Logf("IPv6 may not work on this machine: %v", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
ln.Close()
|
||||||
|
|
||||||
|
// Resolve a hostname that we know has an IPv6 address.
|
||||||
|
addrs, err := net.DefaultResolver.LookupNetIP(context.Background(), "ip6", "google.com")
|
||||||
|
if err != nil {
|
||||||
|
t.Logf("IPv6 DNS resolution error: %v", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(addrs) == 0 {
|
||||||
|
t.Logf("IPv6 DNS resolution returned no addresses")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for _, tt := range []bool{true, false} {
|
for _, tt := range []bool{true, false} {
|
||||||
t.Run(fmt.Sprintf("UseDNSCache=%v", tt), func(t *testing.T) {
|
t.Run(fmt.Sprintf("UseDNSCache=%v", tt), func(t *testing.T) {
|
||||||
|
@ -869,6 +889,11 @@ func TestNodeAddrResolve(t *testing.T) {
|
||||||
t.Logf("got IPv4 addr: %v", ap)
|
t.Logf("got IPv4 addr: %v", ap)
|
||||||
})
|
})
|
||||||
t.Run("IPv6", func(t *testing.T) {
|
t.Run("IPv6", func(t *testing.T) {
|
||||||
|
// Skip if IPv6 doesn't work on this machine.
|
||||||
|
if !ipv6Works(t) {
|
||||||
|
t.Skipf("IPv6 may not work on this machine")
|
||||||
|
}
|
||||||
|
|
||||||
ap := c.nodeAddr(ctx, dn, probeIPv6)
|
ap := c.nodeAddr(ctx, dn, probeIPv6)
|
||||||
if !ap.IsValid() {
|
if !ap.IsValid() {
|
||||||
t.Fatal("expected valid AddrPort")
|
t.Fatal("expected valid AddrPort")
|
||||||
|
|
Loading…
Reference in New Issue