diff options
author | 2018-02-05 22:00:47 +0000 | |
---|---|---|
committer | 2018-02-05 22:00:47 +0000 | |
commit | 5b844b5017f004fffa83157041e8ffd3ac085c92 (patch) | |
tree | cbf86bb06cd42f720037a0e473ce2d1cba4036af /plugin/forward/persistent_test.go | |
parent | fb1cafe5fa54935361a5cc9a7e3308a738225126 (diff) | |
download | coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.tar.gz coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.tar.zst coredns-5b844b5017f004fffa83157041e8ffd3ac085c92.zip |
plugin/forward: add it (#1447)
* plugin/forward: add it
This moves coredns/forward into CoreDNS. Fixes as a few bugs, adds a
policy option and more tests to the plugin.
Update the documentation, test IPv6 address and add persistent tests.
* Always use random policy when spraying
* include scrub fix here as well
* use correct var name
* Code review
* go vet
* Move logging to metrcs
* Small readme updates
* Fix readme
Diffstat (limited to 'plugin/forward/persistent_test.go')
-rw-r--r-- | plugin/forward/persistent_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/plugin/forward/persistent_test.go b/plugin/forward/persistent_test.go new file mode 100644 index 000000000..5674658e6 --- /dev/null +++ b/plugin/forward/persistent_test.go @@ -0,0 +1,44 @@ +package forward + +import ( + "testing" + + "github.com/coredns/coredns/plugin/pkg/dnstest" + + "github.com/miekg/dns" +) + +func TestPersistent(t *testing.T) { + s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { + ret := new(dns.Msg) + ret.SetReply(r) + w.WriteMsg(ret) + }) + defer s.Close() + + h := newHost(s.Addr) + tr := newTransport(h) + defer tr.Stop() + + c1, _ := tr.Dial("udp") + c2, _ := tr.Dial("udp") + c3, _ := tr.Dial("udp") + + tr.Yield(c1) + tr.Yield(c2) + tr.Yield(c3) + + if x := tr.Len(); x != 3 { + t.Errorf("Expected cache size to be 3, got %d", x) + } + + tr.Dial("udp") + if x := tr.Len(); x != 2 { + t.Errorf("Expected cache size to be 2, got %d", x) + } + + tr.Dial("udp") + if x := tr.Len(); x != 1 { + t.Errorf("Expected cache size to be 2, got %d", x) + } +} |