Skip to content

Commit 15b5866

Browse files
author
Ray Mattingly
committed
additional test
1 parent c5cccfc commit 15b5866

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ public void testLargeBatchSaturatesReadNumLimit()
163163
quota.checkBatchQuota(0, limit);
164164
}
165165

166+
@Test
167+
public void testLargeBatchSaturatesReadWriteLimit()
168+
throws RpcThrottlingException, InterruptedException {
169+
int limit = 10;
170+
QuotaProtos.Throttle throttle =
171+
QuotaProtos.Throttle.newBuilder().setWriteNum(QuotaProtos.TimedQuota.newBuilder()
172+
.setSoftLimit(limit).setTimeUnit(HBaseProtos.TimeUnit.SECONDS).build()).build();
173+
QuotaLimiter limiter = TimeBasedLimiter.fromThrottle(throttle);
174+
DefaultOperationQuota quota = new DefaultOperationQuota(new Configuration(), 65536, limiter);
175+
176+
// use the whole limit
177+
quota.checkBatchQuota(limit, 0);
178+
179+
// the next request should be rejected
180+
assertThrows(RpcThrottlingException.class, () -> quota.checkBatchQuota(1, 0));
181+
182+
envEdge.incValue(1000);
183+
// after the TimeUnit, the limit should be refilled
184+
quota.checkBatchQuota(limit, 0);
185+
}
186+
166187
@Test
167188
public void testTooLargeReadBatchIsNotBlocked()
168189
throws RpcThrottlingException, InterruptedException {

0 commit comments

Comments
 (0)