You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by el...@apache.org on 2018/08/16 15:57:34 UTC

[2/2] hbase git commit: HBASE-20705 Having RPC quota on a table now no longer prevents Space Quota to be recreate/removed

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 <el...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/75939775
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/75939775
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/75939775

Branch: refs/heads/branch-2
Commit: 75939775afa06ee64bf10b07c278cfc90c0003db
Parents: cbe2fc1
Author: Sakthi <ja...@cloudera.com>
Authored: Tue Aug 7 13:36:15 2018 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 16 11:16:56 2018 -0400

----------------------------------------------------------------------
 .../hbase/quotas/TestMasterQuotasObserver.java  | 67 ++++++++++++++++++++
 1 file changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/75939775/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();