HBASE-20677 Backport test of HBASE-20566 'Creating a system table after 
enabling rsgroup feature puts region into RIT' to branch-2

Signed-off-by: tedyu <[email protected]>


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

Branch: refs/heads/HBASE-20331
Commit: 832f67d483985bc6cf488bb8ecef32280fdee668
Parents: d99ba62
Author: Nihal Jain <[email protected]>
Authored: Tue Jun 5 01:57:03 2018 +0530
Committer: tedyu <[email protected]>
Committed: Mon Jun 4 14:30:04 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/rsgroup/TestRSGroups.java      | 38 ++++++++++++++------
 1 file changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/832f67d4/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
----------------------------------------------------------------------
diff --git 
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java 
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
index c2fc0f1..f9dafd4 100644
--- 
a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
+++ 
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
@@ -89,14 +89,16 @@ public class TestRSGroups extends TestRSGroupsBase {
         RSGroupBasedLoadBalancer.class.getName());
     
TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
         RSGroupAdminEndpoint.class.getName() + "," + 
CPMasterObserver.class.getName());
-    // Enable quota for testRSGroupsWithHBaseQuota()
-    TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
     TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE - 1);
     TEST_UTIL.getConfiguration().setInt(
         ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
         NUM_SLAVES_BASE - 1);
     
TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, 
true);
 
+    initialize();
+  }
+
+  private static void initialize() throws Exception {
     admin = TEST_UTIL.getAdmin();
     cluster = TEST_UTIL.getHBaseCluster();
     master = ((MiniHBaseCluster)cluster).getMaster();
@@ -178,8 +180,8 @@ public class TestRSGroups extends TestRSGroupsBase {
     assertEquals(4, defaultInfo.getServers().size());
     // Assignment of root and meta regions.
     int count = 
master.getAssignmentManager().getRegionStates().getRegionAssignments().size();
-    //4 meta,namespace, group, quota
-    assertEquals(4, count);
+    //3 meta,namespace, group
+    assertEquals(3, count);
   }
 
   @Test
@@ -525,11 +527,27 @@ public class TestRSGroups extends TestRSGroupsBase {
 
   @Test
   public void testRSGroupsWithHBaseQuota() throws Exception {
-    TEST_UTIL.waitFor(90000, new Waiter.Predicate<Exception>() {
-      @Override
-      public boolean evaluate() throws Exception {
-        return admin.isTableAvailable(QuotaTableUtil.QUOTA_TABLE_NAME);
-      }
-    });
+    TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
+    restartHBaseCluster();
+    try {
+      TEST_UTIL.waitFor(90000, new Waiter.Predicate<Exception>() {
+        @Override
+        public boolean evaluate() throws Exception {
+          return admin.isTableAvailable(QuotaTableUtil.QUOTA_TABLE_NAME);
+        }
+      });
+    } finally {
+      TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, false);
+      restartHBaseCluster();
+    }
+  }
+
+  private void restartHBaseCluster() throws Exception {
+    LOG.info("\n\nShutting down cluster");
+    TEST_UTIL.shutdownMiniHBaseCluster();
+    LOG.info("\n\nSleeping a bit");
+    Thread.sleep(2000);
+    TEST_UTIL.restartHBaseCluster(NUM_SLAVES_BASE - 1);
+    initialize();
   }
 }

Reply via email to