hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-13590 TestEnableTableHandler.testEnableTableWithNoRegionServers is flakey (Yu Li)
Date Thu, 14 Jan 2016 19:53:03 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 e4140b6c0 -> fd7234020


HBASE-13590 TestEnableTableHandler.testEnableTableWithNoRegionServers is flakey (Yu Li)


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

Branch: refs/heads/branch-1.2
Commit: fd723402046d9aef484da005760caa2ce100c999
Parents: e4140b6
Author: stack <stack@apache.org>
Authored: Thu Jan 14 11:15:23 2016 -0800
Committer: stack <stack@apache.org>
Committed: Thu Jan 14 11:15:47 2016 -0800

----------------------------------------------------------------------
 .../master/handler/TestEnableTableHandler.java  | 36 ++++++++++++++++----
 1 file changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/fd723402/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestEnableTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestEnableTableHandler.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestEnableTableHandler.java
index f081860..2871340 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestEnableTableHandler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestEnableTableHandler.java
@@ -20,8 +20,12 @@ package org.apache.hadoop.hbase.master.handler;
 
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
+import java.util.ArrayList;
 import java.util.List;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.HConstants;
@@ -100,24 +104,42 @@ public class TestEnableTableHandler {
     cluster.waitForRegionServerToStop(rs.getRegionServer().getServerName(), 10000);
 
     TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME);
+    LOG.debug("Now enabling table " + tableName);
 
     admin.enableTable(tableName);
     assertTrue(admin.isTableEnabled(tableName));
     JVMClusterUtil.RegionServerThread rs2 = cluster.startRegionServer();
     LOG.info("Started new regionserver " + rs2.getRegionServer().getServerName());
-    m.getAssignmentManager().assign(admin.getTableRegions(tableName));
+    cluster.waitForRegionServerToStart(rs2.getRegionServer().getServerName().getHostname(),
+        rs2.getRegionServer().getServerName().getPort(), 60000);
+
+    // This second region assign action seems to be useless since design of
+    // this case is to make sure that table enabled when no RS up could get
+    // assigned after RS come back
+    List<HRegionInfo> regions = TEST_UTIL.getHBaseAdmin().getTableRegions(tableName);
+    assertEquals(1, regions.size());
+    for (HRegionInfo region : regions) {
+      TEST_UTIL.getHBaseAdmin().assign(region.getEncodedNameAsBytes());
+    }
+    LOG.debug("Waiting for table assigned " + tableName);
     TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
+
     List<HRegionInfo> onlineRegions = admin.getOnlineRegions(
         rs2.getRegionServer().getServerName());
     for (HRegionInfo hri: onlineRegions) LOG.info("Online " + hri);
-    assertTrue("Does not have at least one region " + onlineRegions.size(),
-      onlineRegions.size() >= 1);
-    // Disabling this assert. Saw this which seems legit:
-    //   TestEnableTableHandler.testEnableTableWithNoRegionServers:115 
-    // expected:<testEnableTableWithNoRegionServers> but was:<hbase:namespace>
-    // assertEquals(tableName, onlineRegions.get(0).getTable());
+    ArrayList<HRegionInfo> tableRegions = filterTableRegions(tableName, onlineRegions);
+    assertEquals(1, tableRegions.size());
   }
 
+  private ArrayList<HRegionInfo> filterTableRegions(final TableName tableName,
+      List<HRegionInfo> onlineRegions) {
+    return Lists.newArrayList(Iterables.filter(onlineRegions, new Predicate<HRegionInfo>()
{
+      @Override
+      public boolean apply(HRegionInfo input) {
+        return input.getTable().equals(tableName);
+      }
+    }));
+  }
 
   @Test(timeout = 300000)
   public void testDisableTableAndRestart() throws Exception {


Mime
View raw message