mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
middleware/proxy: silence gprc errors
Add discard logger
This commit is contained in:
@@ -3,6 +3,8 @@ package proxy
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pool() []*UpstreamHost {
|
func pool() []*UpstreamHost {
|
||||||
@@ -17,6 +19,8 @@ func pool() []*UpstreamHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStartupShutdown(t *testing.T) {
|
func TestStartupShutdown(t *testing.T) {
|
||||||
|
grpclog.SetLogger(discard{})
|
||||||
|
|
||||||
upstream := &staticUpstream{
|
upstream := &staticUpstream{
|
||||||
from: ".",
|
from: ".",
|
||||||
Hosts: pool(),
|
Hosts: pool(),
|
||||||
@@ -28,7 +32,7 @@ func TestStartupShutdown(t *testing.T) {
|
|||||||
g := newGrpcClient(nil, upstream)
|
g := newGrpcClient(nil, upstream)
|
||||||
upstream.ex = g
|
upstream.ex = g
|
||||||
|
|
||||||
p := &Proxy{Trace: nil}
|
p := &Proxy{}
|
||||||
p.Upstreams = &[]Upstream{upstream}
|
p.Upstreams = &[]Upstream{upstream}
|
||||||
|
|
||||||
err := g.OnStartup(p)
|
err := g.OnStartup(p)
|
||||||
@@ -52,3 +56,13 @@ func TestStartupShutdown(t *testing.T) {
|
|||||||
t.Errorf("Shutdown didn't remove conns, found %d", len(g.conns))
|
t.Errorf("Shutdown didn't remove conns, found %d", len(g.conns))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// discard is a Logger that outputs nothing.
|
||||||
|
type discard struct{}
|
||||||
|
|
||||||
|
func (d discard) Fatal(args ...interface{}) {}
|
||||||
|
func (d discard) Fatalf(format string, args ...interface{}) {}
|
||||||
|
func (d discard) Fatalln(args ...interface{}) {}
|
||||||
|
func (d discard) Print(args ...interface{}) {}
|
||||||
|
func (d discard) Printf(format string, args ...interface{}) {}
|
||||||
|
func (d discard) Println(args ...interface{}) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user