mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
wgengine/tsdns: skip test that requires local IPv6 when IPv6 unavailable
Fixes #1292 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
4ec01323c1
commit
65815cc1ac
@ -5,6 +5,9 @@
|
||||
package tsdns
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"inet.af/netaddr"
|
||||
)
|
||||
@ -71,7 +74,7 @@ func resolveToNXDOMAIN(w dns.ResponseWriter, req *dns.Msg) {
|
||||
w.WriteMsg(m)
|
||||
}
|
||||
|
||||
func serveDNS(addr string) (*dns.Server, chan error) {
|
||||
func serveDNS(tb testing.TB, addr string) (*dns.Server, chan error) {
|
||||
server := &dns.Server{Addr: addr, Net: "udp"}
|
||||
|
||||
waitch := make(chan struct{})
|
||||
@ -79,7 +82,11 @@ func serveDNS(addr string) (*dns.Server, chan error) {
|
||||
|
||||
errch := make(chan error, 1)
|
||||
go func() {
|
||||
errch <- server.ListenAndServe()
|
||||
err := server.ListenAndServe()
|
||||
if err != nil {
|
||||
log.Printf("ListenAndServe(%q): %v", addr, err)
|
||||
}
|
||||
errch <- err
|
||||
close(errch)
|
||||
}()
|
||||
|
||||
|
@ -274,14 +274,27 @@ func TestResolveReverse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func ipv6Works() bool {
|
||||
c, err := net.Listen("tcp", "[::1]:0")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
c.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
func TestDelegate(t *testing.T) {
|
||||
tstest.ResourceCheck(t)
|
||||
|
||||
if !ipv6Works() {
|
||||
t.Skip("skipping test that requires localhost IPv6")
|
||||
}
|
||||
|
||||
dnsHandleFunc("test.site.", resolveToIP(testipv4, testipv6, "dns.test.site."))
|
||||
dnsHandleFunc("nxdomain.site.", resolveToNXDOMAIN)
|
||||
|
||||
v4server, v4errch := serveDNS("127.0.0.1:0")
|
||||
v6server, v6errch := serveDNS("[::1]:0")
|
||||
v4server, v4errch := serveDNS(t, "127.0.0.1:0")
|
||||
v6server, v6errch := serveDNS(t, "[::1]:0")
|
||||
|
||||
defer func() {
|
||||
if err := <-v4errch; err != nil {
|
||||
@ -371,7 +384,7 @@ func TestDelegate(t *testing.T) {
|
||||
func TestDelegateCollision(t *testing.T) {
|
||||
dnsHandleFunc("test.site.", resolveToIP(testipv4, testipv6, "dns.test.site."))
|
||||
|
||||
server, errch := serveDNS("127.0.0.1:0")
|
||||
server, errch := serveDNS(t, "127.0.0.1:0")
|
||||
defer func() {
|
||||
if err := <-errch; err != nil {
|
||||
t.Errorf("server error: %v", err)
|
||||
@ -473,7 +486,7 @@ func TestConcurrentSetMap(t *testing.T) {
|
||||
func TestConcurrentSetUpstreams(t *testing.T) {
|
||||
dnsHandleFunc("test.site.", resolveToIP(testipv4, testipv6, "dns.test.site."))
|
||||
|
||||
server, errch := serveDNS("127.0.0.1:0")
|
||||
server, errch := serveDNS(t, "127.0.0.1:0")
|
||||
defer func() {
|
||||
if err := <-errch; err != nil {
|
||||
t.Errorf("server error: %v", err)
|
||||
@ -752,7 +765,7 @@ func TestTrimRDNSBonjourPrefix(t *testing.T) {
|
||||
func BenchmarkFull(b *testing.B) {
|
||||
dnsHandleFunc("test.site.", resolveToIP(testipv4, testipv6, "dns.test.site."))
|
||||
|
||||
server, errch := serveDNS("127.0.0.1:0")
|
||||
server, errch := serveDNS(b, "127.0.0.1:0")
|
||||
defer func() {
|
||||
if err := <-errch; err != nil {
|
||||
b.Errorf("server error: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user