From 271cc5fc9c51dada750315aeb74826c298d0c0be Mon Sep 17 00:00:00 2001 From: Leonidas Vrachnis Date: Wed, 29 May 2024 11:55:58 +0200 Subject: [PATCH] chore: fix etcd deprecated warning --- go.mod | 2 +- testhelper/docker/resource/etcd/etcd.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 4e306de7..54a3e8fe 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,6 @@ require ( golang.org/x/sync v0.7.0 golang.org/x/text v0.15.0 google.golang.org/api v0.182.0 - google.golang.org/grpc v1.64.0 google.golang.org/protobuf v1.34.1 gopkg.in/alexcesaro/statsd.v2 v2.0.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 @@ -65,6 +64,7 @@ require ( github.com/gorilla/handlers v1.5.2 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/pkg/xattr v0.4.9 // indirect + google.golang.org/grpc v1.64.0 // indirect ) require ( diff --git a/testhelper/docker/resource/etcd/etcd.go b/testhelper/docker/resource/etcd/etcd.go index 9f3c886a..31735205 100644 --- a/testhelper/docker/resource/etcd/etcd.go +++ b/testhelper/docker/resource/etcd/etcd.go @@ -1,6 +1,7 @@ package etcd import ( + "context" "fmt" "strconv" "time" @@ -8,7 +9,6 @@ import ( "github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3/docker" etcd "go.etcd.io/etcd/client/v3" - "google.golang.org/grpc" "github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource" ) @@ -73,14 +73,18 @@ func Setup(pool *dockertest.Pool, cln resource.Cleaner, opts ...Option) (*Resour } etcdHosts = []string{"http://localhost:" + etcdPortStr} + + etcdClient, err = etcd.New(etcd.Config{ + Endpoints: etcdHosts, + DialTimeout: time.Second, + }) + if err != nil { + return nil, fmt.Errorf("setting up etcd client: %w", err) + } + err = pool.Retry(func() (err error) { - etcdClient, err = etcd.New(etcd.Config{ - Endpoints: etcdHosts, - DialOptions: []grpc.DialOption{ - grpc.WithBlock(), // block until the underlying connection is up - }, - DialTimeout: 10 * time.Second, - }) + _, err = etcdClient.Cluster.MemberList(context.Background()) + return err }) if err != nil {