mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Remove the word middleware (#1067)
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
This commit is contained in:
74
plugin/etcd/group_test.go
Normal file
74
plugin/etcd/group_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
// +build etcd
|
||||
|
||||
package etcd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin/etcd/msg"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
|
||||
"github.com/coredns/coredns/plugin/test"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func TestGroupLookup(t *testing.T) {
|
||||
etc := newEtcdMiddleware()
|
||||
|
||||
for _, serv := range servicesGroup {
|
||||
set(t, etc, serv.Key, 0, serv)
|
||||
defer delete(t, etc, serv.Key)
|
||||
}
|
||||
for _, tc := range dnsTestCasesGroup {
|
||||
m := tc.Msg()
|
||||
|
||||
rec := dnsrecorder.New(&test.ResponseWriter{})
|
||||
_, err := etc.ServeDNS(ctxt, rec, m)
|
||||
if err != nil {
|
||||
t.Errorf("expected no error, got %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
resp := rec.Msg
|
||||
test.SortAndCheck(t, resp, tc)
|
||||
}
|
||||
}
|
||||
|
||||
// Note the key is encoded as DNS name, while in "reality" it is a etcd path.
|
||||
var servicesGroup = []*msg.Service{
|
||||
{Host: "127.0.0.1", Key: "a.dom.skydns.test.", Group: "g1"},
|
||||
{Host: "127.0.0.2", Key: "b.sub.dom.skydns.test.", Group: "g1"},
|
||||
|
||||
{Host: "127.0.0.1", Key: "a.dom2.skydns.test.", Group: "g1"},
|
||||
{Host: "127.0.0.2", Key: "b.sub.dom2.skydns.test.", Group: ""},
|
||||
|
||||
{Host: "127.0.0.1", Key: "a.dom1.skydns.test.", Group: "g1"},
|
||||
{Host: "127.0.0.2", Key: "b.sub.dom1.skydns.test.", Group: "g2"},
|
||||
}
|
||||
|
||||
var dnsTestCasesGroup = []test.Case{
|
||||
// Groups
|
||||
{
|
||||
// hits the group 'g1' and only includes those records
|
||||
Qname: "dom.skydns.test.", Qtype: dns.TypeA,
|
||||
Answer: []dns.RR{
|
||||
test.A("dom.skydns.test. 300 IN A 127.0.0.1"),
|
||||
test.A("dom.skydns.test. 300 IN A 127.0.0.2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
// One has group, the other has not... Include the non-group always.
|
||||
Qname: "dom2.skydns.test.", Qtype: dns.TypeA,
|
||||
Answer: []dns.RR{
|
||||
test.A("dom2.skydns.test. 300 IN A 127.0.0.1"),
|
||||
test.A("dom2.skydns.test. 300 IN A 127.0.0.2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
// The groups differ.
|
||||
Qname: "dom1.skydns.test.", Qtype: dns.TypeA,
|
||||
Answer: []dns.RR{
|
||||
test.A("dom1.skydns.test. 300 IN A 127.0.0.1"),
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user