Skip to content

Commit

Permalink
Configure proper logging for grpc integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptabor committed Apr 14, 2021
1 parent d72f7ef commit fad6391
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 1 addition & 5 deletions tests/integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,7 @@ func NewClientV3(m *member) (*clientv3.Client, error) {
if m.DialOptions != nil {
cfg.DialOptions = append(cfg.DialOptions, m.DialOptions...)
}
c, err := newClientV3(cfg)
if err != nil {
return nil, err
}
return c.WithLogger(m.Logger.Named("client")), nil
return newClientV3(cfg, m.Logger.Named("client"))
}

// Clone returns a member with the same server configuration. The returned
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/cluster_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/server/v3/etcdserver/api/v3election/v3electionpb"
"go.etcd.io/etcd/server/v3/etcdserver/api/v3lock/v3lockpb"
"go.uber.org/zap"
)

const ThroughProxy = false
Expand All @@ -39,6 +40,10 @@ func toGRPC(c *clientv3.Client) grpcAPI {
}
}

func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
return clientv3.New(cfg)
func newClientV3(cfg clientv3.Config, lg *zap.Logger) (*clientv3.Client, error) {
c, err := clientv3.New(cfg)
if err != nil {
return nil, err
}
return c.WithLogger(lg), nil
}
6 changes: 3 additions & 3 deletions tests/integration/cluster_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"go.etcd.io/etcd/client/v3/namespace"
"go.etcd.io/etcd/server/v3/proxy/grpcproxy"
"go.etcd.io/etcd/server/v3/proxy/grpcproxy/adapter"

"go.uber.org/zap"
)

Expand Down Expand Up @@ -56,7 +55,7 @@ func toGRPC(c *clientv3.Client) grpcAPI {
// TODO: Refactor to a separate clientv3.Client instance instead of the context alone.
ctx, ctxCancel := context.WithCancel(context.WithValue(context.TODO(), "_name", "grpcProxyContext"))

lg := zap.NewExample()
lg := c.GetLogger()

if v, ok := proxies[c]; ok {
return v.grpc
Expand Down Expand Up @@ -109,11 +108,12 @@ func (pc *proxyCloser) Close() error {
return err
}

func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
func newClientV3(cfg clientv3.Config, lg *zap.Logger) (*clientv3.Client, error) {
c, err := clientv3.New(cfg)
if err != nil {
return nil, err
}
c = c.WithLogger(lg)
rpc := toGRPC(c)
c.KV = clientv3.NewKVFromKVClient(rpc.KV, c)
pmu.Lock()
Expand Down

0 comments on commit fad6391

Please sign in to comment.