Skip to content

Commit

Permalink
tests: add tests with specifying MaxBytes option
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Lin <[email protected]>
  • Loading branch information
linxiulei committed Jul 25, 2023
1 parent 8c68493 commit 282db51
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/common/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func TestKVGet(t *testing.T) {
{begin: "foo", options: config.GetOptions{Prefix: true}, wkv: []string{"foo", "foo/abc"}},
{begin: "foo", options: config.GetOptions{FromKey: true}, wkv: []string{"foo", "foo/abc", "fop"}},
{begin: "", options: config.GetOptions{Prefix: true, Limit: 2}, wkv: wantKvs[:2]},
{begin: "", options: config.GetOptions{Prefix: true, MaxBytes: 42}, wkv: wantKvs[:3]},
{begin: "", options: config.GetOptions{Prefix: true, Order: clientv3.SortAscend, SortBy: clientv3.SortByModRevision}, wkv: wantKvs},
{begin: "", options: config.GetOptions{Prefix: true, Order: clientv3.SortAscend, SortBy: clientv3.SortByVersion}, wkv: kvsByVersion},
{begin: "", options: config.GetOptions{Prefix: true, Order: clientv3.SortNone, SortBy: clientv3.SortByCreateRevision}, wkv: wantKvs},
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/ctl_v3_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func getTest(cx ctlCtx) {
{[]string{"", "--from-key"}, kvs},
{[]string{"key", "--prefix"}, kvs},
{[]string{"key", "--prefix", "--limit=2"}, kvs[:2]},
{[]string{"key", "--prefix", "--max-bytes=36"}, kvs[:2]},
{[]string{"key", "--prefix", "--order=ASCEND", "--sort-by=MODIFY"}, kvs},
{[]string{"key", "--prefix", "--order=ASCEND", "--sort-by=VERSION"}, kvs},
{[]string{"key", "--prefix", "--sort-by=CREATE"}, kvs}, // ASCEND by default
Expand Down
1 change: 1 addition & 0 deletions tests/framework/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type GetOptions struct {
Prefix bool
FromKey bool
Limit int
MaxBytes int
Order clientv3.SortOrder
SortBy clientv3.SortTarget
Timeout time.Duration
Expand Down
3 changes: 3 additions & 0 deletions tests/framework/e2e/etcdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (ctl *EtcdctlV3) Get(ctx context.Context, key string, o config.GetOptions)
if o.Limit != 0 {
args = append(args, fmt.Sprintf("--limit=%d", o.Limit))
}
if o.MaxBytes != 0 {
args = append(args, fmt.Sprintf("--max-bytes=%d", o.MaxBytes))
}
if o.FromKey {
args = append(args, "--from-key")
}
Expand Down
3 changes: 3 additions & 0 deletions tests/framework/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func (c integrationClient) Get(ctx context.Context, key string, o config.GetOpti
if o.Limit != 0 {
clientOpts = append(clientOpts, clientv3.WithLimit(int64(o.Limit)))
}
if o.MaxBytes != 0 {
clientOpts = append(clientOpts, clientv3.WithMaxBytes(int64(o.MaxBytes)))
}
if o.FromKey {
clientOpts = append(clientOpts, clientv3.WithFromKey())
}
Expand Down

0 comments on commit 282db51

Please sign in to comment.