You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2021/05/28 15:23:56 UTC

[hbase] branch branch-2 updated: HBASE-25910 - Fix port assignment test (#3308)

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

vjasani 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 5aa39a9  HBASE-25910 - Fix port assignment test (#3308)
5aa39a9 is described below

commit 5aa39a975c958b7887ff03a9b9a7489c5b11c81d
Author: Victor <vl...@hotmail.com>
AuthorDate: Fri May 28 08:22:07 2021 -0700

    HBASE-25910 - Fix port assignment test (#3308)
    
    Signed-off-by: David Manning <da...@salesforce.com>
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 .../apache/hadoop/hbase/regionserver/HRegionServer.java |  1 +
 .../apache/hadoop/hbase/TestClusterPortAssignment.java  | 17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 1df79e1..6387747 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -2256,6 +2256,7 @@ public class HRegionServer extends Thread implements
         // auto bind enabled, try to use another port
         LOG.info("Failed binding http info server to port: " + port);
         port++;
+        LOG.info("Retry starting http info server with port: " + port);
       }
     }
     port = this.infoServer.getPort();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClusterPortAssignment.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClusterPortAssignment.java
index 933cdc6..4d37ca5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClusterPortAssignment.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestClusterPortAssignment.java
@@ -19,7 +19,9 @@ package org.apache.hadoop.hbase;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import java.net.BindException;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -27,7 +29,6 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@org.junit.Ignore // See HBASE-24342. This test can't pass 100% of time as written so disabling
 @Category(MediumTests.class)
 public class TestClusterPortAssignment {
   @ClassRule
@@ -41,7 +42,7 @@ public class TestClusterPortAssignment {
    * Check that we can start an HBase cluster specifying a custom set of
    * RPC and infoserver ports.
    */
-  @Test
+  @Test(timeout = 300000)
   public void testClusterPortAssignment() throws Exception {
     boolean retry = false;
     do {
@@ -50,10 +51,13 @@ public class TestClusterPortAssignment {
       int rsPort =  HBaseTestingUtility.randomFreePort();
       int rsInfoPort =  HBaseTestingUtility.randomFreePort();
       TEST_UTIL.getConfiguration().setBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS, false);
+      TEST_UTIL.getConfiguration().setBoolean(HConstants.REGIONSERVER_INFO_PORT_AUTO, false);
+      TEST_UTIL.getConfiguration().setBoolean("fs.hdfs.impl.disable.cache", true);
       TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_PORT, masterPort);
       TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, masterInfoPort);
       TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_PORT, rsPort);
       TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, rsInfoPort);
+      LOG.info("Ports: {}, {}, {}, {}", masterPort, masterInfoPort, rsPort, rsInfoPort);
       try {
         MiniHBaseCluster cluster = TEST_UTIL.startMiniCluster();
         assertTrue("Cluster failed to come up", cluster.waitForActiveAndReadyMaster(30000));
@@ -67,13 +71,14 @@ public class TestClusterPortAssignment {
         assertEquals("RS info port is incorrect", rsInfoPort,
           cluster.getRegionServer(0).getInfoServer().getPort());
       } catch (Exception e) {
-        if (e instanceof  BindException || e.getCause() != null &&
-            (e.getCause() instanceof BindException || e.getCause().getCause() != null &&
-              e.getCause().getCause() instanceof BindException)) {
+        Throwable rootCause = ExceptionUtils.getRootCause(e);
+        if (rootCause instanceof BindException) {
           LOG.info("Failed bind, need to retry", e);
           retry = true;
         } else {
-          throw e;
+          LOG.error("Failed to start mini cluster", e);
+          retry = false;
+          fail("Failed to start mini cluster with assigned ports.");
         }
       } finally {
         TEST_UTIL.shutdownMiniCluster();