Skip to content

Commit c5150ea

Browse files
raggiandrew-d
andcommitted
net/netcheck: reenable TestNodeAddrResolve on Windows
Updates tailscale#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
1 parent 80b138f commit c5150ea

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

net/netcheck/netcheck_test.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,6 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
830830
}
831831

832832
func TestNodeAddrResolve(t *testing.T) {
833-
if runtime.GOOS == "windows" {
834-
t.Skip("TODO(#7876): test regressed on windows while CI was broken")
835-
}
836833
c := &Client{
837834
Logf: t.Logf,
838835
UDPBindAddr: "127.0.0.1:0",
@@ -852,6 +849,29 @@ func TestNodeAddrResolve(t *testing.T) {
852849
// No IPv4 or IPv6 addrs
853850
}
854851

852+
// Checks whether IPv6 and IPv6 DNS resolution works on this platform.
853+
ipv6Works := func(t *testing.T) bool {
854+
// Verify that we can create an IPv6 socket.
855+
ln, err := net.ListenPacket("udp6", "[::1]:0")
856+
if err != nil {
857+
t.Logf("IPv6 may not work on this machine: %v", err)
858+
return false
859+
}
860+
ln.Close()
861+
862+
// Resolve a hostname that we know has an IPv6 address.
863+
addrs, err := net.DefaultResolver.LookupNetIP(context.Background(), "ip6", "google.com")
864+
if err != nil {
865+
t.Logf("IPv6 DNS resolution error: %v", err)
866+
return false
867+
}
868+
if len(addrs) == 0 {
869+
t.Logf("IPv6 DNS resolution returned no addresses")
870+
return false
871+
}
872+
return true
873+
}
874+
855875
ctx := context.Background()
856876
for _, tt := range []bool{true, false} {
857877
t.Run(fmt.Sprintf("UseDNSCache=%v", tt), func(t *testing.T) {
@@ -869,6 +889,11 @@ func TestNodeAddrResolve(t *testing.T) {
869889
t.Logf("got IPv4 addr: %v", ap)
870890
})
871891
t.Run("IPv6", func(t *testing.T) {
892+
// Skip if IPv6 doesn't work on this machine.
893+
if !ipv6Works(t) {
894+
t.Skipf("IPv6 may not work on this machine")
895+
}
896+
872897
ap := c.nodeAddr(ctx, dn, probeIPv6)
873898
if !ap.IsValid() {
874899
t.Fatal("expected valid AddrPort")

0 commit comments

Comments
 (0)