From f6042890b792c76f92168a298a0e8ff849c47229 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 2 Dec 2016 22:14:44 -0800 Subject: [PATCH] integration: use RequireLeader for TestV3LeaseFailover Giving Renew() the default request timeout causes TestV3LeaseFailover to miss its timing constraints. Since it only needs to wait until the leader recognizes the leader is lost, use RequireLeader to cancel the keepalive stream before the request times out. --- integration/v3_lease_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration/v3_lease_test.go b/integration/v3_lease_test.go index f3ce69ba3..4040b0f8f 100644 --- a/integration/v3_lease_test.go +++ b/integration/v3_lease_test.go @@ -19,11 +19,13 @@ import ( "testing" "time" + "golang.org/x/net/context" + "google.golang.org/grpc/metadata" + "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) // TestV3LeasePrmote ensures the newly elected leader can promote itself @@ -356,7 +358,9 @@ func TestV3LeaseFailover(t *testing.T) { lreq := &pb.LeaseKeepAliveRequest{ID: lresp.ID} - ctx, cancel := context.WithCancel(context.Background()) + md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader) + mctx := metadata.NewContext(context.Background(), md) + ctx, cancel := context.WithCancel(mctx) defer cancel() lac, err := lc.LeaseKeepAlive(ctx) if err != nil {