Changes large parts of proxy lookup mechanism. The duplicate zone checking erroneous added a nameserver for each zone we are auth. for, creating to many backend hosts. So even when a host was determined do be Down() we still got an (identical) new one from the list. The Down() and failure checking for upstream hosts had data race in the uh.Fails check - we now use atomic.LoadInt32 for that. Use and debug the test/server.go test servers implementation in the TestStubLookup test to prevent going out to the internet. Also delete the stub cycle test. That test was wrong and did not test what it needed to be testing. Deleted for now.
77 lines
1.8 KiB
Go
77 lines
1.8 KiB
Go
// +build etcd
|
|
|
|
package etcd
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/miekg/coredns/middleware"
|
|
"github.com/miekg/coredns/middleware/etcd/msg"
|
|
"github.com/miekg/coredns/middleware/proxy"
|
|
"github.com/miekg/coredns/middleware/test"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
func TestProxyLookupFailDebug(t *testing.T) {
|
|
for _, serv := range servicesProxy {
|
|
set(t, etc, serv.Key, 0, serv)
|
|
defer delete(t, etc, serv.Key)
|
|
}
|
|
|
|
prxy := etc.Proxy
|
|
etc.Proxy = proxy.New([]string{"127.0.0.1:154"})
|
|
defer func() { etc.Proxy = prxy }()
|
|
|
|
etc.Debug = true
|
|
defer func() { etc.Debug = false }()
|
|
|
|
for _, tc := range dnsTestCasesProxy {
|
|
m := tc.Msg()
|
|
|
|
rec := middleware.NewResponseRecorder(&test.ResponseWriter{})
|
|
_, err := etc.ServeDNS(ctxt, rec, m)
|
|
if err != nil {
|
|
t.Errorf("expected no error, got %v\n", err)
|
|
continue
|
|
}
|
|
resp := rec.Msg()
|
|
|
|
sort.Sort(test.RRSet(resp.Answer))
|
|
sort.Sort(test.RRSet(resp.Ns))
|
|
sort.Sort(test.RRSet(resp.Extra))
|
|
|
|
if !test.Header(t, tc, resp) {
|
|
t.Logf("%v\n", resp)
|
|
continue
|
|
}
|
|
if !test.Section(t, tc, test.Answer, resp.Answer) {
|
|
t.Logf("%v\n", resp)
|
|
}
|
|
if !test.Section(t, tc, test.Ns, resp.Ns) {
|
|
t.Logf("%v\n", resp)
|
|
}
|
|
if !test.Section(t, tc, test.Extra, resp.Extra) {
|
|
t.Logf("%v\n", resp)
|
|
}
|
|
}
|
|
}
|
|
|
|
var servicesProxy = []*msg.Service{
|
|
{Host: "www.example.org", Key: "a.dom.skydns.test."},
|
|
}
|
|
|
|
var dnsTestCasesProxy = []test.Case{
|
|
{
|
|
Qname: "o-o.debug.dom.skydns.test.", Qtype: dns.TypeSRV,
|
|
Answer: []dns.RR{
|
|
test.SRV("dom.skydns.test. 300 IN SRV 10 100 0 www.example.org."),
|
|
},
|
|
Extra: []dns.RR{
|
|
test.TXT("a.dom.skydns.test. 300 CH TXT \"www.example.org:0(10,0,,false)[0,]\""),
|
|
test.TXT("www.example.org. 0 CH TXT \"www.example.org.:0(0,0, IN A: unreachable backend,false)[0,]\""),
|
|
test.TXT("www.example.org. 0 CH TXT \"www.example.org.:0(0,0, IN AAAA: unreachable backend,false)[0,]\""),
|
|
},
|
|
},
|
|
}
|