Skip to content

Commit

Permalink
clientv3/integration: test large KV requests
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Dec 19, 2017
1 parent b7e8239 commit ceab8ea
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions clientv3/integration/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,46 @@ func TestKVPutAtMostOnce(t *testing.T) {
t.Fatalf("expected version <= 10, got %+v", resp.Kvs[0])
}
}

// TestKVLargeRequests ensures that configurable MaxRequestBytes
// works as intended for clients.
func TestKVLargeRequests(t *testing.T) {
defer testutil.AfterTest(t)
tests := []struct {
maxRequestBytes uint
valueSize int
expectError error
}{
{1, 1024, rpctypes.ErrRequestTooLarge},

// without proper client-side receive size limit
// "code = ResourceExhausted desc = grpc: received message larger than max (5242929 vs. 4194304)"
{7 * 1024 * 1024, 5 * 1024 * 1024, nil},

{10 * 1024 * 1024, 10 * 1024 * 1024, rpctypes.ErrRequestTooLarge},
{10 * 1024 * 1024, 10*1024*1024 + 5, rpctypes.ErrRequestTooLarge},
}
for i, test := range tests {
clus := integration.NewClusterV3(t,
&integration.ClusterConfig{
Size: 1,
MaxRequestBytes: test.maxRequestBytes,
},
)
cli := clus.Client(0)
_, err := cli.Put(context.TODO(), "foo", strings.Repeat("a", test.valueSize))
if err != test.expectError {
t.Errorf("#%d: expected %v, got %v", i, test.expectError, err)
}

// put request went through, now expects large response back
if err == nil {
_, err = cli.Get(context.TODO(), "foo")
if err != nil {
t.Errorf("#%d: get expected no error, got %v", i, err)
}
}

clus.Terminate(t)
}
}

0 comments on commit ceab8ea

Please sign in to comment.