Skip to content

Commit

Permalink
additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Mattingly committed Jun 28, 2024
1 parent c5cccfc commit 15b5866
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ public void testLargeBatchSaturatesReadNumLimit()
quota.checkBatchQuota(0, limit);
}

@Test
public void testLargeBatchSaturatesReadWriteLimit()
throws RpcThrottlingException, InterruptedException {
int limit = 10;
QuotaProtos.Throttle throttle =
QuotaProtos.Throttle.newBuilder().setWriteNum(QuotaProtos.TimedQuota.newBuilder()
.setSoftLimit(limit).setTimeUnit(HBaseProtos.TimeUnit.SECONDS).build()).build();
QuotaLimiter limiter = TimeBasedLimiter.fromThrottle(throttle);
DefaultOperationQuota quota = new DefaultOperationQuota(new Configuration(), 65536, limiter);

// use the whole limit
quota.checkBatchQuota(limit, 0);

// the next request should be rejected
assertThrows(RpcThrottlingException.class, () -> quota.checkBatchQuota(1, 0));

envEdge.incValue(1000);
// after the TimeUnit, the limit should be refilled
quota.checkBatchQuota(limit, 0);
}

@Test
public void testTooLargeReadBatchIsNotBlocked()
throws RpcThrottlingException, InterruptedException {
Expand Down

0 comments on commit 15b5866

Please sign in to comment.