Repository: hbase Updated Branches: refs/heads/branch-2 cbe2fc113 -> 75939775a refs/heads/master 50a8ea719 -> 2cfe1e8ae
HBASE-20705 Having RPC quota on a table now no longer prevents Space Quota to be recreate/removed Just added 2 test cases as the subtasks of this jira solves the issue Signed-off-by: Josh Elser <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2cfe1e8a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2cfe1e8a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2cfe1e8a Branch: refs/heads/master Commit: 2cfe1e8aef69514acac85cecd3a4abe318314209 Parents: 50a8ea7 Author: Sakthi <[email protected]> Authored: Tue Aug 7 13:36:15 2018 -0700 Committer: Josh Elser <[email protected]> Committed: Thu Aug 16 11:07:37 2018 -0400 ---------------------------------------------------------------------- .../hbase/quotas/TestMasterQuotasObserver.java | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/2cfe1e8a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java index b6b7924..92e1d9d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java @@ -138,6 +138,38 @@ public class TestMasterQuotasObserver { } @Test + public void testTableSpaceAndRPCQuotaRemoved() throws Exception { + final Connection conn = TEST_UTIL.getConnection(); + final Admin admin = conn.getAdmin(); + final TableName tn = TableName.valueOf(testName.getMethodName()); + // Drop the table if it somehow exists + if (admin.tableExists(tn)) { + dropTable(admin, tn); + } + + createTable(admin, tn); + assertEquals(0, getNumSpaceQuotas()); + assertEquals(0, getThrottleQuotas()); + + // Set Both quotas + QuotaSettings settings = + QuotaSettingsFactory.limitTableSpace(tn, 1024L, SpaceViolationPolicy.NO_INSERTS); + admin.setQuota(settings); + + settings = + QuotaSettingsFactory.throttleTable(tn, ThrottleType.REQUEST_SIZE, 2L, TimeUnit.HOURS); + admin.setQuota(settings); + + assertEquals(1, getNumSpaceQuotas()); + assertEquals(1, getThrottleQuotas()); + + // Delete the table and observe the quotas being automatically deleted as well + dropTable(admin, tn); + assertEquals(0, getNumSpaceQuotas()); + assertEquals(0, getThrottleQuotas()); + } + + @Test public void testNamespaceSpaceQuotaRemoved() throws Exception { final Connection conn = TEST_UTIL.getConnection(); final Admin admin = conn.getAdmin(); @@ -190,6 +222,41 @@ public class TestMasterQuotasObserver { } @Test + public void testNamespaceSpaceAndRPCQuotaRemoved() throws Exception { + final Connection conn = TEST_UTIL.getConnection(); + final Admin admin = conn.getAdmin(); + final TableName tn = TableName.valueOf(testName.getMethodName()); + final String ns = testName.getMethodName(); + // Drop the ns if it somehow exists + if (namespaceExists(ns)) { + admin.deleteNamespace(ns); + } + + // Create the ns + NamespaceDescriptor desc = NamespaceDescriptor.create(ns).build(); + admin.createNamespace(desc); + assertEquals(0, getNumSpaceQuotas()); + assertEquals(0, getThrottleQuotas()); + + // Set Both quotas + QuotaSettings settings = + QuotaSettingsFactory.limitNamespaceSpace(ns, 1024L, SpaceViolationPolicy.NO_INSERTS); + admin.setQuota(settings); + + settings = + QuotaSettingsFactory.throttleNamespace(ns, ThrottleType.REQUEST_SIZE, 2L, TimeUnit.HOURS); + admin.setQuota(settings); + + assertEquals(1, getNumSpaceQuotas()); + assertEquals(1, getThrottleQuotas()); + + // Delete the namespace and observe the quotas being automatically deleted as well + admin.deleteNamespace(ns); + assertEquals(0, getNumSpaceQuotas()); + assertEquals(0, getThrottleQuotas()); + } + + @Test public void testObserverAddedByDefault() throws Exception { final HMaster master = TEST_UTIL.getHBaseCluster().getMaster(); final MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
