From 84d2ff93b0010382f7e0f908dc36dccf3ab46c93 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 5 Oct 2016 16:41:06 -0700 Subject: [PATCH] integration/v3_grpc_test: Fix quota tests Use the system page size to set the test quota size. Also, change a comment related to setting the node quota to be more clear. Signed-off-by: Geoff Levand --- integration/v3_grpc_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/integration/v3_grpc_test.go b/integration/v3_grpc_test.go index b97ec3888..24c198b8d 100644 --- a/integration/v3_grpc_test.go +++ b/integration/v3_grpc_test.go @@ -17,6 +17,7 @@ package integration import ( "fmt" "math/rand" + "os" "reflect" "testing" "time" @@ -583,10 +584,12 @@ func TestV3Hash(t *testing.T) { // TestV3StorageQuotaAPI tests the V3 server respects quotas at the API layer func TestV3StorageQuotaAPI(t *testing.T) { defer testutil.AfterTest(t) + quotasize := int64(16 * os.Getpagesize()) clus := NewClusterV3(t, &ClusterConfig{Size: 3}) - clus.Members[0].QuotaBackendBytes = 64 * 1024 + // Set a quota on one node + clus.Members[0].QuotaBackendBytes = quotasize clus.Members[0].Stop(t) clus.Members[0].Restart(t) @@ -602,7 +605,7 @@ func TestV3StorageQuotaAPI(t *testing.T) { } // test big put - bigbuf := make([]byte, 64*1024) + bigbuf := make([]byte, quotasize) _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: key, Value: bigbuf}) if !eqErrGRPC(err, rpctypes.ErrGRPCNoSpace) { t.Fatalf("big put got %v, expected %v", err, rpctypes.ErrGRPCNoSpace) @@ -628,14 +631,15 @@ func TestV3StorageQuotaAPI(t *testing.T) { // TestV3StorageQuotaApply tests the V3 server respects quotas during apply func TestV3StorageQuotaApply(t *testing.T) { testutil.AfterTest(t) + quotasize := int64(16 * os.Getpagesize()) clus := NewClusterV3(t, &ClusterConfig{Size: 2}) defer clus.Terminate(t) kvc0 := toGRPC(clus.Client(0)).KV kvc1 := toGRPC(clus.Client(1)).KV - // force a node to have a different quota - clus.Members[0].QuotaBackendBytes = 64 * 1024 + // Set a quota on one node + clus.Members[0].QuotaBackendBytes = quotasize clus.Members[0].Stop(t) clus.Members[0].Restart(t) clus.waitLeader(t, clus.Members) @@ -650,7 +654,7 @@ func TestV3StorageQuotaApply(t *testing.T) { } // test big put - bigbuf := make([]byte, 64*1024) + bigbuf := make([]byte, quotasize) _, err := kvc1.Put(context.TODO(), &pb.PutRequest{Key: key, Value: bigbuf}) if err != nil { t.Fatal(err)