mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	* Clean up tests logging This cleans up the travis logs so you can see the failures better. Older tests in tests/ would call log.SetOutput(ioutil.Discard) in a haphazard way. This add log.Discard and put an `init` function in each package's dir (no way to do this globally). The cleanup in tests/ is clear. All plugins also got this init function to have some uniformity and kill any (future) logging there in the tests as well. There is a one-off in pkg/healthcheck because that does log. Signed-off-by: Miek Gieben <miek@miek.nl> * bring back original log_test.go Signed-off-by: Miek Gieben <miek@miek.nl> * suppress logging here as well Signed-off-by: Miek Gieben <miek@miek.nl>
		
			
				
	
	
		
			44 lines
		
	
	
		
			819 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			819 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package test
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/coredns/coredns/plugin/test"
 | 
						|
 | 
						|
	"github.com/miekg/dns"
 | 
						|
 | 
						|
	// Load all managed plugins in github.com/coredns/coredns
 | 
						|
	_ "github.com/coredns/coredns/core/plugin"
 | 
						|
)
 | 
						|
 | 
						|
func benchmarkLookupBalanceRewriteCache(b *testing.B) {
 | 
						|
	t := new(testing.T)
 | 
						|
	name, rm, err := test.TempFile(".", exampleOrg)
 | 
						|
	if err != nil {
 | 
						|
		t.Fatalf("Failed to create zone: %s", err)
 | 
						|
	}
 | 
						|
	defer rm()
 | 
						|
 | 
						|
	corefile := `example.org:0 {
 | 
						|
    file ` + name + `
 | 
						|
    rewrite type ANY HINFO
 | 
						|
    loadbalance
 | 
						|
}
 | 
						|
`
 | 
						|
 | 
						|
	ex, udp, _, err := CoreDNSServerAndPorts(corefile)
 | 
						|
	if err != nil {
 | 
						|
		t.Fatalf("Could not get CoreDNS serving instance: %s", err)
 | 
						|
	}
 | 
						|
	defer ex.Stop()
 | 
						|
 | 
						|
	c := new(dns.Client)
 | 
						|
	m := new(dns.Msg)
 | 
						|
	m.SetQuestion("example.org.", dns.TypeA)
 | 
						|
 | 
						|
	b.ResetTimer()
 | 
						|
	for i := 0; i < b.N; i++ {
 | 
						|
		c.Exchange(m, udp)
 | 
						|
	}
 | 
						|
}
 |