joshelser commented on a change in pull request #572: HBASE-22012 Space Quota:
DisableTableViolationPolicy will cause cycles of enable/disable table
URL: https://github.com/apache/hbase/pull/572#discussion_r326908185
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java
##########
@@ -221,4 +228,32 @@ public void testTableQuotaOverridesNamespaceQuota()
throws Exception {
Bytes.toBytes("reject"));
helper.verifyViolation(policy, tn, p);
}
+
+ @Test
+ public void testDisablePolicyQuotaAndViolate() throws Exception {
+ TableName tableName = helper.createTable();
+ helper.setQuotaLimit(tableName, SpaceViolationPolicy.DISABLE, 1L);
+ helper.writeData(tableName, SpaceQuotaHelperForTests.ONE_MEGABYTE * 2L);
+ TEST_UTIL.getConfiguration()
+ .setLong("hbase.master.quotas.region.report.retention.millis", 100);
+
+ HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
+ MasterQuotaManager quotaManager = master.getMasterQuotaManager();
+
+ // Make sure the master has report for the table.
+ Waiter.waitFor(TEST_UTIL.getConfiguration(), 30 * 1000, new
Waiter.Predicate<Exception>() {
+ @Override
+ public boolean evaluate() throws Exception {
+ Map<RegionInfo, Long> regionSizes = quotaManager.snapshotRegionSizes();
+ List<RegionInfo> tableRegions =
+ MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(),
tableName);
+ return regionSizes.containsKey(tableRegions.get(0));
+ }
+ });
+
+ // Check if disabled table region report present in the map after
retention period expired.
+ // It should be present after retention period expired.
+ Assert.assertTrue(quotaManager.snapshotRegionSizes().keySet().stream()
Review comment:
Can you pull the lambda out of the `assertTrue` to make this a little more
readable? e.g.
```
final int regionSizes = quotaManager.snapshotRegionSizes()...;
Assert.assertTrue(regionSizes > 0);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services