coredns/test/middleware_test.go
John Belamaric ef315ef3e2 Rewrite edns0 (#561)
* Add edns0 code rewrite

* check arg count

* change `new`; set EDNS0 if request doesn't have it set

* change set to replace_or_append

* change to append_or_replace

* return error in new

* update documents

* fixt UT

* return error

* go fmt

* Rework for more general EDNS0 use

Also changed how rules are created and validated. Implements
EDNS0 NSID in addition to local.

* go fmt

* README updates, NSID tests and fixes

* gofmt -s -w

* Fix tests for rewrite syntax change

* Add tests, fix error message

* Review nits

* Missed on nit

* More tests, integration test, fix edns0 parse issue

* Fix README, use RewriteIgnored

* go fmt
2017-03-06 21:32:17 +00:00

44 lines
791 B
Go

package test
import (
"io/ioutil"
"log"
"testing"
"github.com/coredns/coredns/middleware/test"
"github.com/miekg/dns"
)
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, err := CoreDNSServer(corefile)
if err != nil {
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
}
udp, _ := CoreDNSServerPorts(ex, 0)
defer ex.Stop()
log.SetOutput(ioutil.Discard)
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)
}
}