aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-10-08 14:46:22 +0100
committerGravatar GitHub <noreply@github.com> 2016-10-08 14:46:22 +0100
commita05901f62a47b9cca92b46937a59a7b06f23023a (patch)
tree01fa87a7c598f6a5cd6a803717cc6236f3adca61 /test
parentf29f622ec7f1eb20413a9a92fb633148a9e9c1d4 (diff)
downloadcoredns-a05901f62a47b9cca92b46937a59a7b06f23023a.tar.gz
coredns-a05901f62a47b9cca92b46937a59a7b06f23023a.tar.zst
coredns-a05901f62a47b9cca92b46937a59a7b06f23023a.zip
middleware/proxy: make it scale (#287)
* middleware/proxy Use connection pooling for communicating with an upstream, instead of opening a new socket every time. This makes the proxy more efficient and allowed for some cleanups. * Some cleanups * Some fixes * more * Kill pool * Add nil check * remove pool
Diffstat (limited to 'test')
-rw-r--r--test/proxy_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/proxy_test.go b/test/proxy_test.go
index 400aee0b5..c2cdc2fcc 100644
--- a/test/proxy_test.go
+++ b/test/proxy_test.go
@@ -62,3 +62,41 @@ func TestLookupProxy(t *testing.T) {
t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String())
}
}
+
+func BenchmarkLookupProxy(b *testing.B) {
+ t := new(testing.T)
+ name, rm, err := test.TempFile(t, ".", exampleOrg)
+ if err != nil {
+ t.Fatalf("failed to created zone: %s", err)
+ }
+ defer rm()
+
+ corefile := `example.org:0 {
+ file ` + name + `
+}
+`
+
+ i, err := CoreDNSServer(corefile)
+ if err != nil {
+ t.Fatalf("could not get CoreDNS serving instance: %s", err)
+ }
+
+ udp, _ := CoreDNSServerPorts(i, 0)
+ if udp == "" {
+ t.Fatalf("could not get udp listening port")
+ }
+ defer i.Stop()
+
+ log.SetOutput(ioutil.Discard)
+
+ p := proxy.New([]string{udp})
+ state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ _, err := p.Lookup(state, "example.org.", dns.TypeA)
+ if err != nil {
+ b.Fatal("Expected to receive reply, but didn't")
+ }
+ }
+}