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

laszlog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new 95408da87 IMPALA-13546: Fix Flaky JWT Unit Tests
95408da87 is described below

commit 95408da87b431a9b5d5a44f86c3f5fd5569bb82f
Author: jasonmfehr <[email protected]>
AuthorDate: Thu Feb 27 09:22:35 2025 -0800

    IMPALA-13546: Fix Flaky JWT Unit Tests
    
    The JwtHttpTest unit tests sometimes fail with a
    java.nio.charset.MalformedInputException. This error message is
    thrown from the java.nio.charset.CharsetDecoder#decode() function
    to indicate a byte sequence is not valid for a charset.
    
    Since these tests fail intermittently, the malformed byte sequence is
    most likely caused by attempting to read the log file while it is
    still being written.
    
    This patch hardens the existing limited retries when reading the
    impalad.ERROR log file to also retry on exceptions.
    
    Testing was accomplished by running the JwtHttpTest unit tests
    locally.
    
    Change-Id: I48eea2b522b1834c92a8db14a0bdd63ca8c66c93
    Reviewed-on: http://gerrit.cloudera.org:8080/22561
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Riza Suminto <[email protected]>
---
 .../org/apache/impala/customcluster/JwtHttpTest.java  | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java 
b/fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
index dd991c1c0..b3b016b1c 100644
--- a/fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
+++ b/fe/src/test/java/org/apache/impala/customcluster/JwtHttpTest.java
@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hive.service.rpc.thrift.*;
+import org.apache.impala.analysis.AnalyzerTest;
 import org.apache.impala.testutil.WebClient;
 import org.apache.impala.testutil.X509CertChain;
 import org.apache.thrift.transport.THttpClient;
@@ -40,6 +41,8 @@ import org.hamcrest.Matcher;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.junit.After;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static org.hamcrest.core.IsCollectionContaining.hasItem;
 import static org.hamcrest.core.StringContains.containsString;
@@ -49,6 +52,8 @@ import static org.hamcrest.core.StringContains.containsString;
  * JWT authentication is being used.
  */
 public class JwtHttpTest {
+  private final static Logger LOG = LoggerFactory.getLogger(JwtHttpTest.class);
+
   private static final String CA_CERT = "cacert.pem";
   private static final String SERVER_CERT = "server-cert.pem";
   private static final String SERVER_KEY = "server-key.pem";
@@ -612,10 +617,16 @@ public class JwtHttpTest {
 
     // writing logs to disk may take some time, try a few times to search for 
the
     // expected error in the log
-    for (int i=0; i<10; i++) {
-      logLines = Files.readAllLines(logDir.resolve("impalad.ERROR"));
-      if (m.matches(logLines)) {
-        break;
+    for (int i = 0; i < 10; i++) {
+      final Path log_file_path = logDir.resolve("impalad.ERROR");
+      try {
+        logLines = Files.readAllLines(log_file_path);
+        if (m.matches(logLines)) {
+          break;
+        }
+      } catch (Exception e) {
+        LOG.info("attempt '" + Integer.toString(i) + "' could not read logfile 
'"
+            + log_file_path.toString() + "'", e);
       }
       Thread.sleep(250);
     }

Reply via email to