Files
coredns/middleware/etcd/stub_cycle_test.go
Miek Gieben ad76aef5fc Fix stubzone retention (#198)
Make the receiver a pointer so that the uptdateStubZones map update will
retain the stubzones found, unlike the current case where the update
will be applied and then promptly forgotten, because it is working on a
copy.

Add test/etcd_test.go to test a large part of the code. This didn't
catch the chaos middleware hack though. The chaos middleware zones are
now *not* automatically added. You have to take care of that by yourself
(docs updates).

When using debug queries and falling through to the next middleware in
etcd, restore the original (with o-o.debug) query before passing it on.
2016-08-08 19:18:55 -07:00

41 lines
948 B
Go

// +build etcd
package etcd
import (
"testing"
"github.com/miekg/coredns/middleware"
"github.com/miekg/coredns/middleware/test"
"github.com/miekg/dns"
)
func TestStubCycle(t *testing.T) {
// reuse servics from stub_test.go
for _, serv := range servicesStub {
set(t, etc, serv.Key, 0, serv)
defer delete(t, etc, serv.Key)
}
etc.updateStubZones()
defer func() { etc.Stubmap = nil }()
for _, tc := range dnsTestCasesCycleStub {
m := tc.Msg()
if tc.Do {
// add our wacky edns fluff
m.Extra[0] = ednsStub
}
rec := middleware.NewResponseRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err == nil {
t.Errorf("expected error, got none")
continue
}
// err should have been, set msg is nil, CoreDNS middlware handling takes
// care of proper error to client.
}
}
var dnsTestCasesCycleStub = []test.Case{{Qname: "example.org.", Qtype: dns.TypeA, Rcode: dns.RcodeRefused, Do: true}}