hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vjas...@apache.org
Subject [hbase] branch branch-1 updated: HBASE-25910 - Fix port assignment test (#3308)
Date Wed, 02 Jun 2021 09:10:58 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/branch-1 by this push:
     new 0fd6eeb  HBASE-25910 - Fix port assignment test (#3308)
0fd6eeb is described below

commit 0fd6eeb012218d64252f0c9976680f0ad622f29f
Author: Victor <vli02@hotmail.com>
AuthorDate: Wed Jun 2 14:35:47 2021 +0530

    HBASE-25910 - Fix port assignment test (#3308)
    
    Signed-off-by: David Manning <david.manning@salesforce.com>
    Signed-off-by: Viraj Jasani <vjasani@apache.org>
---
 .../hadoop/hbase/regionserver/HRegionServer.java   |  1 +
 .../hadoop/hbase/TestClusterPortAssignment.java    | 23 +++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 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 5f5c9c5..a5500a1 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
@@ -2032,6 +2032,7 @@ public class HRegionServer extends HasThread 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 5a46105..ee181fa 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,12 +19,13 @@ 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.lang.exception.ExceptionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 
 import org.junit.Test;
@@ -39,7 +40,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 {
@@ -48,10 +49,15 @@ 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));
@@ -64,9 +70,16 @@ public class TestClusterPortAssignment {
           cluster.getRegionServer(0).getRpcServer().getListenerAddress().getPort());
         assertEquals("RS info port is incorrect", rsInfoPort,
           cluster.getRegionServer(0).getInfoServer().getPort());
-      } catch (BindException e) {
-        LOG.info("Failed to bind, need to retry", e);
-        retry = true;
+      } catch (Exception e) {
+        Throwable rootCause = ExceptionUtils.getRootCause(e);
+        if (rootCause instanceof BindException) {
+          LOG.info("Failed bind, need to retry", e);
+          retry = true;
+        } else {
+          LOG.error("Failed to start mini cluster", e);
+          retry = false;
+          fail("Failed to start mini cluster with assigned ports.");
+        }
       } finally {
         TEST_UTIL.shutdownMiniCluster();
       }

Mime
View raw message