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

[hbase] branch branch-1 updated: HBASE-26074: Fix testLogLevelByHttps/testLogLevelByHttpsWithSpnego (#3466)

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

bharathv 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 b7fbfdd  HBASE-26074: Fix testLogLevelByHttps/testLogLevelByHttpsWithSpnego (#3466)
b7fbfdd is described below

commit b7fbfdd0786e18fa9789f5bf164ddc0b0a4f1655
Author: Bharath Vissapragada <bh...@apache.org>
AuthorDate: Thu Jul 8 22:46:50 2021 -0700

    HBASE-26074: Fix testLogLevelByHttps/testLogLevelByHttpsWithSpnego (#3466)
    
    Signed-off-by: Reid Chan <re...@apache.org>
---
 .../apache/hadoop/hbase/http/log/TestLogLevel.java | 35 +++++++++++++---------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
index b475c1a..bf90bac 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.base.Joiner;
 import java.io.File;
 import java.net.BindException;
 import java.net.SocketException;
@@ -400,7 +401,7 @@ public class TestLogLevel {
       testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTPS, false);
       fail("A HTTPS Client should not have succeeded in connecting to a HTTP server");
     } catch (SSLException e) {
-      exceptionShouldContains("Unrecognized SSL message", e);
+      exceptionShouldContains(e, "Unrecognized SSL message");
     }
   }
 
@@ -417,7 +418,7 @@ public class TestLogLevel {
       testDynamicLogLevel(LogLevel.PROTOCOL_HTTP, LogLevel.PROTOCOL_HTTPS, true);
       fail("A HTTPS Client should not have succeeded in connecting to a HTTP server");
     } catch (SSLException e) {
-      exceptionShouldContains("Unrecognized SSL message", e);
+      exceptionShouldContains(e, "Unrecognized SSL message");
     }
   }
 
@@ -434,7 +435,10 @@ public class TestLogLevel {
       testDynamicLogLevel(LogLevel.PROTOCOL_HTTPS, LogLevel.PROTOCOL_HTTP, false);
       fail("A HTTP Client should not have succeeded in connecting to a HTTPS server");
     } catch (SocketException e) {
-      exceptionShouldContains("Unexpected end of file from server", e);
+      // Connection clean up and state management depends on the JVM and it's corresponding SSL
+      // libraries in use. We specifically noticed different behaviors with OpenJDK and Azul JVMs,
+      // See HBASE-26074.
+      exceptionShouldContains(e, "Unexpected end of file from server", "Connection reset");
     }
   }
 
@@ -453,12 +457,12 @@ public class TestLogLevel {
       fail("A HTTP Client should not have succeeded in connecting to a " +
           "HTTPS server");
     }  catch (SocketException e) {
-      exceptionShouldContains("Unexpected end of file from server", e);
+      exceptionShouldContains(e, "Unexpected end of file from server", "Connection reset");
     }
   }
 
   /**
-   * Assert that a throwable or one of its causes should contain the substr in its message.
+   * Assert that a throwable or one of its causes should contain any of the substr in its message.
    *
    * Ideally we should use {@link GenericTestUtils#assertExceptionContains(String, Throwable)} util
    * method which asserts t.toString() contains the substr. As the original throwable may have been
@@ -466,16 +470,19 @@ public class TestLogLevel {
    * After stop supporting Hadoop2, this method can be removed and assertion in tests can use
    * t.getCause() directly, similar to HADOOP-15280.
    */
-  private static void exceptionShouldContains(String substr, Throwable throwable) {
-    Throwable t = throwable;
-    while (t != null) {
-      String msg = t.toString();
-      if (msg != null && msg.toLowerCase().contains(substr.toLowerCase())) {
-        return;
+  private static void exceptionShouldContains(Throwable throwable, String... substr) {
+    for (String s: substr) {
+      Throwable t = throwable;
+      while (t != null) {
+        String msg = t.toString();
+        if (msg != null && msg.toLowerCase().contains(s.toLowerCase())) {
+          return;
+        }
+        t = t.getCause();
       }
-      t = t.getCause();
     }
-    throw new AssertionError("Expected to find '" + substr + "' but got unexpected exception:" +
-        StringUtils.stringifyException(throwable), throwable);
+    String debug = "[" + Joiner.on(" , ").join(substr) + "]";
+    throw new AssertionError("Expected to find any of " + debug + " but got unexpected"
+      + " exception:" + StringUtils.stringifyException(throwable), throwable);
   }
 }