aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/grpc_test.go
diff options
context:
space:
mode:
authorGravatar John Belamaric <jbelamaric@infoblox.com> 2017-03-01 10:41:54 -0500
committerGravatar GitHub <noreply@github.com> 2017-03-01 10:41:54 -0500
commit9ea8cde36e24cb68d6cb2c5db7b6b08e204db7a8 (patch)
treee2ed28202d4e047d1ffcbecf797d1e04bdc9d068 /middleware/proxy/grpc_test.go
parent0a4903571e85d985f1789aa8f15465337bea9a84 (diff)
downloadcoredns-9ea8cde36e24cb68d6cb2c5db7b6b08e204db7a8.tar.gz
coredns-9ea8cde36e24cb68d6cb2c5db7b6b08e204db7a8.tar.zst
coredns-9ea8cde36e24cb68d6cb2c5db7b6b08e204db7a8.zip
Grpc tracing (#544)
* checkpoint * Pass context through ServeDNS, enable gRPC tracing * Fix types and make tracer available to proxy. go fmt * Fix imports * Use the DoNotStartTrace option * Change to SpanFilter from DoNotStartTrace * Use new name (IncludeSpan) * Final names * Add tests; fix possible client/conn leaks in grpc * go fmt
Diffstat (limited to 'middleware/proxy/grpc_test.go')
-rw-r--r--middleware/proxy/grpc_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/middleware/proxy/grpc_test.go b/middleware/proxy/grpc_test.go
new file mode 100644
index 000000000..0eade58a9
--- /dev/null
+++ b/middleware/proxy/grpc_test.go
@@ -0,0 +1,54 @@
+package proxy
+
+import (
+ "testing"
+ "time"
+)
+
+func pool() []*UpstreamHost {
+ return []*UpstreamHost{
+ {
+ Name: "localhost:10053",
+ },
+ {
+ Name: "localhost:10054",
+ },
+ }
+}
+
+func TestStartupShutdown(t *testing.T) {
+ upstream := &staticUpstream{
+ from: ".",
+ Hosts: pool(),
+ Policy: &Random{},
+ Spray: nil,
+ FailTimeout: 10 * time.Second,
+ MaxFails: 1,
+ }
+ g := newGrpcClient(nil, upstream)
+ upstream.ex = g
+
+ p := &Proxy{Trace: nil}
+ p.Upstreams = &[]Upstream{upstream}
+
+ err := g.OnStartup(p)
+ if err != nil {
+ t.Errorf("Error starting grpc client exchanger: %s", err)
+ return
+ }
+ if len(g.clients) != len(pool()) {
+ t.Errorf("Expected %d grpc clients but found %d", len(pool()), len(g.clients))
+ }
+
+ err = g.OnShutdown(p)
+ if err != nil {
+ t.Errorf("Error stopping grpc client exchanger: %s", err)
+ return
+ }
+ if len(g.clients) != 0 {
+ t.Errorf("Shutdown didn't remove clients, found %d", len(g.clients))
+ }
+ if len(g.conns) != 0 {
+ t.Errorf("Shutdown didn't remove conns, found %d", len(g.conns))
+ }
+}