hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17120 TestAssignmentListener#testAssignmentListener fails (ChiaPing Tsai)
Date Thu, 17 Nov 2016 15:49:01 GMT
Repository: hbase
Updated Branches:
  refs/heads/master ab55bad89 -> b9319496b


HBASE-17120 TestAssignmentListener#testAssignmentListener fails (ChiaPing Tsai)


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

Branch: refs/heads/master
Commit: b9319496bce4985e7a7a9743e7d6cf42fdff3dbc
Parents: ab55bad
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Nov 17 07:48:52 2016 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Thu Nov 17 07:48:52 2016 -0800

----------------------------------------------------------------------
 .../hbase/master/TestAssignmentListener.java    | 27 +++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b9319496/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentListener.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentListener.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentListener.java
index 9a52c70..f7f9abd 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentListener.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentListener.java
@@ -264,12 +264,19 @@ public class TestAssignmentListener {
       listener.reset();
       List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
       assertEquals(2, regions.size());
+      boolean sameServer = areAllRegionsLocatedOnSameServer(TABLE_NAME);
+      // If the regions are located by different server, we need to move
+      // regions to same server before merging. So the expected modifications
+      // will increaes to 5. (open + close)
+      final int expectedModifications = sameServer ? 3 : 5;
+      final int expectedLoadCount = sameServer ? 1 : 2;
+      final int expectedCloseCount = sameServer ? 2 : 3;
       admin.mergeRegionsAsync(regions.get(0).getEncodedNameAsBytes(),
         regions.get(1).getEncodedNameAsBytes(), true);
-      listener.awaitModifications(3);
+      listener.awaitModifications(expectedModifications);
       assertEquals(1, admin.getTableRegions(TABLE_NAME).size());
-      assertEquals(1, listener.getLoadCount());     // new merged region added
-      assertEquals(2, listener.getCloseCount());    // daughters removed
+      assertEquals(expectedLoadCount, listener.getLoadCount());     // new merged region
added
+      assertEquals(expectedCloseCount, listener.getCloseCount());    // daughters removed
 
       // Delete the table
       LOG.info("Drop Table");
@@ -283,6 +290,20 @@ public class TestAssignmentListener {
     }
   }
 
+  private boolean areAllRegionsLocatedOnSameServer(TableName TABLE_NAME) {
+    MiniHBaseCluster miniCluster = TEST_UTIL.getMiniHBaseCluster();
+    int serverCount = 0;
+    for (JVMClusterUtil.RegionServerThread regionThread: miniCluster.getRegionServerThreads())
{
+      if (!regionThread.getRegionServer().getOnlineRegions(TABLE_NAME).isEmpty()) {
+        ++serverCount;
+      }
+      if (serverCount > 1) {
+        return false;
+      }
+    }
+    return serverCount == 1;
+  }
+
   @Test
   public void testAddNewServerThatExistsInDraining() throws Exception {
     // Under certain circumstances, such as when we failover to the Backup


Mime
View raw message