You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/04/02 10:58:39 UTC

[hbase] branch branch-2 updated: HBASE-22141 Fix TestAsyncDecommissionAdminApi

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 1a12b24  HBASE-22141 Fix TestAsyncDecommissionAdminApi
1a12b24 is described below

commit 1a12b244ec5b3536ae29b371e6c7468e8fd08e5c
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Mon Apr 1 18:53:19 2019 +0800

    HBASE-22141 Fix TestAsyncDecommissionAdminApi
---
 .../hadoop/hbase/client/TestAsyncAdminBase.java    |  5 +++-
 .../client/TestAsyncDecommissionAdminApi.java      |  9 ++++++-
 .../hbase/client/TestAsyncRegionAdminApi.java      | 29 +++++++++-------------
 3 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
index 1d19beb..73529c0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminBase.java
@@ -84,7 +84,7 @@ public abstract class TestAsyncAdminBase {
     TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 120000);
     TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
     TEST_UTIL.getConfiguration().setInt(START_LOG_ERRORS_AFTER_COUNT_KEY, 0);
-    TEST_UTIL.startMiniCluster(3);
+    TEST_UTIL.startMiniCluster(2);
     ASYNC_CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();
   }
 
@@ -116,6 +116,9 @@ public abstract class TestAsyncAdminBase {
           });
         }
       }, ForkJoinPool.commonPool()).join();
+    if (!admin.isBalancerEnabled().join()) {
+      admin.balancerSwitch(true, true);
+    }
   }
 
   protected void createTableWithDefaultConf(TableName tableName) throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncDecommissionAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncDecommissionAdminApi.java
index 14a881b..4540011 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncDecommissionAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncDecommissionAdminApi.java
@@ -46,6 +46,7 @@ public class TestAsyncDecommissionAdminApi extends TestAsyncAdminBase {
 
   @Test
   public void testAsyncDecommissionRegionServers() throws Exception {
+    admin.balancerSwitch(false, true);
     List<ServerName> decommissionedRegionServers = admin.listDecommissionedRegionServers().get();
     assertTrue(decommissionedRegionServers.isEmpty());
 
@@ -55,7 +56,8 @@ public class TestAsyncDecommissionAdminApi extends TestAsyncAdminBase {
         new ArrayList<>(admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).get()
           .getLiveServerMetrics().keySet());
 
-    assertEquals(2, clusterRegionServers.size());
+    assertEquals(TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().size(),
+      clusterRegionServers.size());
 
     HashMap<ServerName, List<RegionInfo>> serversToDecommssion = new HashMap<>();
     // Get a server that has regions. We will decommission one of the servers,
@@ -84,6 +86,11 @@ public class TestAsyncDecommissionAdminApi extends TestAsyncAdminBase {
       }
     }
 
+    // Maybe the TRSP is still not finished at master side, since the reportRegionTransition just
+    // updates the procedure store, and we still need to wake up the procedure and execute it in the
+    // procedure executor, which is asynchronous
+    TEST_UTIL.waitUntilNoRegionsInTransition(10000);
+
     // Recommission and load regions
     for (ServerName server : serversToDecommssion.keySet()) {
       List<byte[]> encodedRegionNames = serversToDecommssion.get(server).stream()
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
index b065a39..28e60d2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java
@@ -180,23 +180,18 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
   public void testGetOnlineRegions() throws Exception {
     createTableAndGetOneRegion(tableName);
     AtomicInteger regionServerCount = new AtomicInteger(0);
-    TEST_UTIL
-        .getHBaseCluster()
-        .getLiveRegionServerThreads()
-        .stream()
-        .map(rsThread -> rsThread.getRegionServer())
-        .forEach(
-          rs -> {
-            ServerName serverName = rs.getServerName();
-            try {
-              assertEquals(admin.getRegions(serverName).get().size(), rs
-                  .getRegions().size());
-            } catch (Exception e) {
-              fail("admin.getOnlineRegions() method throws a exception: " + e.getMessage());
-            }
-            regionServerCount.incrementAndGet();
-          });
-    assertEquals(3, regionServerCount.get());
+    TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().stream()
+      .map(rsThread -> rsThread.getRegionServer()).forEach(rs -> {
+        ServerName serverName = rs.getServerName();
+        try {
+          assertEquals(admin.getRegions(serverName).get().size(), rs.getRegions().size());
+        } catch (Exception e) {
+          fail("admin.getOnlineRegions() method throws a exception: " + e.getMessage());
+        }
+        regionServerCount.incrementAndGet();
+      });
+    assertEquals(TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().size(),
+      regionServerCount.get());
   }
 
   @Test