mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	* 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
		
			
				
	
	
		
			45 lines
		
	
	
		
			766 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			766 B
		
	
	
	
		
			Go
		
	
	
	
	
	
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)
 | 
						|
	}
 | 
						|
}
 |