aboutsummaryrefslogtreecommitdiff
path: root/plugin/forward/forward_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-01-13 16:54:49 +0000
committerGravatar GitHub <noreply@github.com> 2019-01-13 16:54:49 +0000
commit9c16ed1d14f570f27b4ff9cb89845a3a1548a776 (patch)
tree8050afa683fdb3f2e1efa1dd2e3a35a680d689d0 /plugin/forward/forward_test.go
parent6b56a9c92130d50cee9bd92aaee500dbccff395f (diff)
downloadcoredns-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/forward/forward_test.go')
-rw-r--r--plugin/forward/forward_test.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/plugin/forward/forward_test.go b/plugin/forward/forward_test.go
deleted file mode 100644
index dfdde933f..000000000
--- a/plugin/forward/forward_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package forward
-
-import (
- "testing"
-
- "github.com/coredns/coredns/plugin/pkg/dnstest"
- "github.com/coredns/coredns/plugin/pkg/transport"
- "github.com/coredns/coredns/plugin/test"
- "github.com/coredns/coredns/request"
-
- "github.com/miekg/dns"
-)
-
-func TestForward(t *testing.T) {
- s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
- ret := new(dns.Msg)
- ret.SetReply(r)
- ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1"))
- w.WriteMsg(ret)
- })
- defer s.Close()
-
- p := NewProxy(s.Addr, transport.DNS)
- f := New()
- f.SetProxy(p)
- defer f.Close()
-
- state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
- state.Req.SetQuestion("example.org.", dns.TypeA)
- resp, err := f.Forward(state)
- if err != nil {
- t.Fatal("Expected to receive reply, but didn't")
- }
- // expect answer section with A record in it
- if len(resp.Answer) == 0 {
- t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp)
- }
- if resp.Answer[0].Header().Rrtype != dns.TypeA {
- t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype)
- }
- if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" {
- t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String())
- }
-}
-
-func TestForwardRefused(t *testing.T) {
- s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
- ret := new(dns.Msg)
- ret.SetReply(r)
- ret.Rcode = dns.RcodeRefused
- w.WriteMsg(ret)
- })
- defer s.Close()
-
- p := NewProxy(s.Addr, transport.DNS)
- f := New()
- f.SetProxy(p)
- defer f.Close()
-
- state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
- state.Req.SetQuestion("example.org.", dns.TypeA)
- resp, err := f.Forward(state)
- if err != nil {
- t.Fatal("Expected to receive reply, but didn't")
- }
- if resp.Rcode != dns.RcodeRefused {
- t.Errorf("Expected rcode to be %d, got %d", dns.RcodeRefused, resp.Rcode)
- }
-}
er&follow=1'>src (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-11-29:scissors:Gravatar Jarred Sumner 5-626/+7
2022-11-29Remove some dead bindings codeGravatar Jarred Sumner 7-1401/+69
2022-11-29import everything from "bun" where possibleGravatar Jarred Sumner 161-739/+621
2022-11-28Make .toInt64 fasterGravatar Jarred Sumner 1-0/+8
2022-11-28Handle when the process already exited immediatelyGravatar Jarred Sumner 3-38/+47
2022-11-28toHaveProperty and tests (#1558)Gravatar Dylan Conway 8-118/+532
2022-11-28Fix failing spawn() and spawnSync() testsGravatar Jarred Sumner 7-143/+317
2022-11-28Update README.mdGravatar Jarred Sumner 1-1/+26
2022-11-28Update README.mdGravatar Jarred Sumner 1-5/+5
2022-11-28Add small section about profiling bunGravatar Jarred Sumner 1-0/+171
2022-11-28Fix hanging in FIFO streamsGravatar Jarred Sumner 1-1/+2
2022-11-28[internal] Add debug timerGravatar Jarred Sumner 2-2/+33
2022-11-28Ensure we report errors in controller.closeGravatar Jarred Sumner 1-1/+9
2022-11-28Update JSEnvironmentVariableMap.cppGravatar Jarred Sumner 1-1/+1
2022-11-28Allow overriding node:fsGravatar Jarred Sumner 1-0/+9
2022-11-28Add test for processGravatar Jarred Sumner 1-3/+14
2022-11-28Fix process.env and Bun.env object spreadGravatar Jarred Sumner 8-204/+127
2022-11-27Fix `console.log(process.env)`Gravatar Jarred Sumner 2-20/+27