diff --git a/integration/v3_grpc_test.go b/integration/v3_grpc_test.go index 78fb21d20d2..13c2b875636 100644 --- a/integration/v3_grpc_test.go +++ b/integration/v3_grpc_test.go @@ -44,7 +44,7 @@ func TestV3PutOverwrite(t *testing.T) { kvc := toGRPC(clus.RandClient()).KV key := []byte("foo") - reqput := &pb.PutRequest{Key: key, Value: []byte("bar")} + reqput := &pb.PutRequest{Key: key, Value: []byte("bar"), PrevKv: true} respput, err := kvc.Put(context.TODO(), reqput) if err != nil { @@ -61,6 +61,9 @@ func TestV3PutOverwrite(t *testing.T) { t.Fatalf("expected newer revision on overwrite, got %v <= %v", respput2.Header.Revision, respput.Header.Revision) } + if pkv := respput2.PrevKv; pkv == nil || string(pkv.Value) != "bar" { + t.Fatalf("expected PrevKv=bar, got response %+v", respput2) + } reqrange := &pb.RangeRequest{Key: key} resprange, err := kvc.Range(context.TODO(), reqrange) diff --git a/proxy/grpcproxy/kv.go b/proxy/grpcproxy/kv.go index 7799d817e33..4e6b0366173 100644 --- a/proxy/grpcproxy/kv.go +++ b/proxy/grpcproxy/kv.go @@ -196,6 +196,9 @@ func PutRequestToOp(r *pb.PutRequest) clientv3.Op { if r.IgnoreLease { opts = append(opts, clientv3.WithIgnoreLease()) } + if r.PrevKv { + opts = append(opts, clientv3.WithPrevKV()) + } return clientv3.OpPut(string(r.Key), string(r.Value), opts...) }