mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Add debugging for failed lookups (#199)
This PR adds debug support for failed lookups. I.e. when a record is outside the configured domain, we do a forward lookup. If this fails the error is silently dropped. This PR adds it back as an error in when debugging is enabled. Fixes #197
This commit is contained in:
77
middleware/etcd/proxy_lookup_test.go
Normal file
77
middleware/etcd/proxy_lookup_test.go
Normal file
@@ -0,0 +1,77 @@
|
||||
// +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.0:154"})
|
||||
etc.Debug = true
|
||||
|
||||
defer func() { etc.Debug = false }()
|
||||
defer func() { etc.Proxy = prxy }()
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note the key is encoded as DNS name, while in "reality" it is a etcd path.
|
||||
var servicesProxy = []*msg.Service{
|
||||
{Host: "www.example.org", Key: "a.dom.skydns.test."},
|
||||
}
|
||||
|
||||
var dnsTestCasesProxy = []test.Case{
|
||||
{
|
||||
Qname: "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(". 0 CH TXT \"www.example.org. IN A: unreachable backend\""),
|
||||
test.TXT(". 0 CH TXT \"www.example.org. IN AAAA: unreachable backend\""),
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user