Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpcproxy: respect KeysOnly flag #8552

Merged
merged 2 commits into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions e2e/ctl_v3_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,15 @@ func getRevTest(cx ctlCtx) {
}

func getKeysOnlyTest(cx ctlCtx) {
var (
kvs = []kv{{"key1", "val1"}}
)
for i := range kvs {
if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
cx.t.Fatalf("getKeysOnlyTest #%d: ctlV3Put error (%v)", i, err)
}
if err := ctlV3Put(cx, "key", "val", ""); err != nil {
cx.t.Fatal(err)
}

cmdArgs := append(cx.PrefixArgs(), "get")
cmdArgs = append(cmdArgs, []string{"--prefix", "--keys-only", "key"}...)

err := spawnWithExpects(cmdArgs, []string{"key1", ""}...)
if err != nil {
cx.t.Fatalf("getKeysOnlyTest : error (%v)", err)
cmdArgs := append(cx.PrefixArgs(), []string{"get", "--keys-only", "key"}...)
if err := spawnWithExpect(cmdArgs, "key"); err != nil {
cx.t.Fatal(err)
}
if err := spawnWithExpects(cmdArgs, "val"); err == nil {
cx.t.Fatalf("got value but passed --keys-only")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: t.Errorf is better here.

}
}

Expand Down
4 changes: 3 additions & 1 deletion proxy/grpcproxy/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ func RangeRequestToOp(r *pb.RangeRequest) clientv3.Op {
if r.CountOnly {
opts = append(opts, clientv3.WithCountOnly())
}

if r.KeysOnly {
opts = append(opts, clientv3.WithKeysOnly())
}
if r.Serializable {
opts = append(opts, clientv3.WithSerializable())
}
Expand Down