diff options
author | 2019-01-13 16:54:49 +0000 | |
---|---|---|
committer | 2019-01-13 16:54:49 +0000 | |
commit | 9c16ed1d14f570f27b4ff9cb89845a3a1548a776 (patch) | |
tree | 8050afa683fdb3f2e1efa1dd2e3a35a680d689d0 /plugin/file/cname_test.go | |
parent | 6b56a9c92130d50cee9bd92aaee500dbccff395f (diff) | |
download | coredns-9c16ed1d14f570f27b4ff9cb89845a3a1548a776.tar.gz coredns-9c16ed1d14f570f27b4ff9cb89845a3a1548a776.tar.zst coredns-9c16ed1d14f570f27b4ff9cb89845a3a1548a776.zip |
Default to upstream to self (#2436)
* Default to upstream to self
This is a backwards incompatible change.
This is a massive (cleanup) PR where we default to resolving external
names by the coredns process itself, instead of directly forwarding them
to some upstream.
This ignores any arguments `upstream` may have had and makes it depend
on proxy/forward configuration in the Corefile. This allows resolved
upstream names to be cached and we have better healthchecking of the
upstreams. It also means there is only one way to resolve names, by
either using the proxy or forward plugin.
The proxy/forward lookup.go functions have been removed. This also
lessen the dependency on proxy, meaning deprecating proxy will become
easier. Some tests have been removed as well, or moved to the top-level
test directory as they now require a full coredns process instead of
just the plugin.
For the etcd plugin, the entire StubZone resolving is *dropped*! This
was a hacky (but working) solution to say the least. If someone cares
deeply it can be brought back (maybe)?
The pkg/upstream is now very small and almost does nothing. Also the
New() function was changed to return a pointer to upstream.Upstream. It
also returns only one parameter, so any stragglers using it will
encounter a compile error.
All documentation has been adapted. This affected the following plugins:
* etcd
* file
* auto
* secondary
* federation
* template
* route53
A followup PR will make any upstream directives with arguments an error,
right now they are ignored.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix etcd build - probably still fails unit test
Signed-off-by: Miek Gieben <miek@miek.nl>
* Slightly smarter lookup check in upstream
Signed-off-by: Miek Gieben <miek@miek.nl>
* Compilez
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/file/cname_test.go')
-rw-r--r-- | plugin/file/cname_test.go | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/plugin/file/cname_test.go b/plugin/file/cname_test.go deleted file mode 100644 index 10eb7d934..000000000 --- a/plugin/file/cname_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLookupCNAMEChain(t *testing.T) { - name := "example.org." - zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range cnameTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var cnameTestCases = []test.Case{ - { - Qname: "a.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.1"), - }, - }, - { - Qname: "www3.example.org.", Qtype: dns.TypeCNAME, - Answer: []dns.RR{ - test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."), - }, - }, - { - Qname: "dangling.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("dangling.example.org. 1800 IN CNAME foo.example.org."), - }, - }, - { - Qname: "www3.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.1"), - test.CNAME("www.example.org. 1800 IN CNAME a.example.org."), - test.CNAME("www1.example.org. 1800 IN CNAME www.example.org."), - test.CNAME("www2.example.org. 1800 IN CNAME www1.example.org."), - test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."), - }, - }, -} - -func TestLookupCNAMEExternal(t *testing.T) { - name := "example.org." - zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - zone.Upstream, _ = upstream.New([]string{"8.8.8.8:53"}) // TODO(miek): point to local instance - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range exernalTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var exernalTestCases = []test.Case{ - { - Qname: "external.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("external.example.org. 1800 CNAME www.example.net."), - // magic 303 TTL that says: don't check TTL. - test.A("www.example.net. 303 IN A 93.184.216.34"), - }, - }, -} - -const dbExampleCNAME = ` -$TTL 30M -$ORIGIN example.org. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - -a IN A 127.0.0.1 -www3 IN CNAME www2 -www2 IN CNAME www1 -www1 IN CNAME www -www IN CNAME a -dangling IN CNAME foo -external IN CNAME www.example.net.` |