You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2019/03/06 10:06:43 UTC

[hbase] branch branch-2.2 updated: HBASE-21949 Fix flaky test TestHBaseTestingUtility.testMiniZooKeeperWithMultipleClientPorts

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

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


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new 4ab2dc2  HBASE-21949 Fix flaky test TestHBaseTestingUtility.testMiniZooKeeperWithMultipleClientPorts
4ab2dc2 is described below

commit 4ab2dc20f15e9b59477de4bd971c367f3ce342cb
Author: maoling <ma...@sina.com>
AuthorDate: Tue Mar 5 17:09:54 2019 +0800

    HBASE-21949 Fix flaky test TestHBaseTestingUtility.testMiniZooKeeperWithMultipleClientPorts
    
    Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
 .../org/apache/hadoop/hbase/TestHBaseTestingUtility.java | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
index 0ec97ef..76a2370 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
@@ -275,7 +275,9 @@ public class TestHBaseTestingUtility {
       List<Integer> clientPortListInCluster = cluster1.getClientPortList();
 
       for (i = 0; i < clientPortListInCluster.size(); i++) {
-        assertEquals(clientPortListInCluster.get(i).intValue(), clientPortList1[i]);
+        // cannot assert the specific port due to the port conflict in which situation
+        // it always chooses a bigger port by +1. The below is the same.
+        assertTrue(clientPortListInCluster.get(i).intValue() >= clientPortList1[i]);
       }
     } finally {
       hbt.shutdownMiniZKCluster();
@@ -292,11 +294,11 @@ public class TestHBaseTestingUtility {
 
       for (i = 0, j = 0; i < clientPortListInCluster.size(); i++) {
         if (i < clientPortList2.length) {
-          assertEquals(clientPortListInCluster.get(i).intValue(), clientPortList2[i]);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= clientPortList2[i]);
         } else {
           // servers with no specified client port will use defaultClientPort or some other ports
           // based on defaultClientPort
-          assertEquals(clientPortListInCluster.get(i).intValue(), defaultClientPort + j);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= defaultClientPort + j);
           j++;
         }
       }
@@ -317,9 +319,9 @@ public class TestHBaseTestingUtility {
         // Servers will only use valid client ports; if ports are not specified or invalid,
         // the default port or a port based on default port will be used.
         if (i < clientPortList3.length && clientPortList3[i] > 0) {
-          assertEquals(clientPortListInCluster.get(i).intValue(), clientPortList3[i]);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= clientPortList3[i]);
         } else {
-          assertEquals(clientPortListInCluster.get(i).intValue(), defaultClientPort + j);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= defaultClientPort + j);
           j++;
         }
       }
@@ -343,9 +345,9 @@ public class TestHBaseTestingUtility {
         // Servers will only use valid client ports; if ports are not specified or invalid,
         // the default port or a port based on default port will be used.
         if (i < clientPortList4.length && clientPortList4[i] > 0) {
-          assertEquals(clientPortListInCluster.get(i).intValue(), clientPortList4[i]);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= clientPortList4[i]);
         } else {
-          assertEquals(clientPortListInCluster.get(i).intValue(), defaultClientPort + j);
+          assertTrue(clientPortListInCluster.get(i).intValue() >= defaultClientPort + j);
           j +=2;
         }
       }