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

michaelsmith 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 492745af6 IMPALA-14678: Fix retries in testHiveserver2SharedCookie
492745af6 is described below

commit 492745af66b35ca812908be291eb524e6a337c81
Author: Michael Smith <[email protected]>
AuthorDate: Mon Jan 12 16:02:57 2026 -0800

    IMPALA-14678: Fix retries in testHiveserver2SharedCookie
    
    This test had a few mistakes. It would never retry the last case because
    the Exception that's supposed to trigger retry - when OpenSession
    succeeds - would be caught and returned instead, which led to
    
        expected:<[Expected failure due to changed cookie secret.]>
        but was:<[HTTP Response code: 401]>
    
    This worked most of the time because the cookie reload is fast, and
    usually the first request fails with an invalid cookie.
    
    After fixing that issue, I ran into another. Apache HttpClient makes it
    easy to re-use connections. In testHiveserver2SharedCookie, we keep
    retrying until cookie authentication fails. If it instead succeeds, all
    subsequent attempts re-used the same connection and never actually
    retried cookie authentication, so we would time out.
    
    Fixes THttpClient retries in testHiveserver2SharedCookie test. Moves the
    retry exception out of try/catch and uses a new client for each request
    to avoid connection re-use. Also fixes expected in assertEquals.
    
    Tested by running the test 40 times without failure.
    
    Change-Id: Icaccc6fcc4529fe9a93ede97ca5130644e88c439
    Reviewed-on: http://gerrit.cloudera.org:8080/23861
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 .../test/java/org/apache/impala/customcluster/LdapHS2Test.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java 
b/fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
index 7b2b26235..d97e49672 100644
--- a/fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
+++ b/fe/src/test/java/org/apache/impala/customcluster/LdapHS2Test.java
@@ -1051,22 +1051,22 @@ public class LdapHS2Test {
     // Cookie should be reloaded with the new key.
     writeCookieSecret(keyFile);
     String respMessage = retryUntilSuccess(() -> {
-      try (THttpClient transport = new THttpClient("http://localhost:28000";)) {
+      try (CloseableHttpClient clientImpl = HttpClients.createDefault();
+          THttpClient transport = new THttpClient("http://localhost:28000";, 
clientImpl)) {
         transport.setCustomHeader("Cookie", cookie[0]);
         transport.open();
         TCLIService.Iface client = new TCLIService.Client(new 
TBinaryProtocol(transport));
 
         // Open a session which will get username 'Test1Ldap'. Failure is 
expected since
         // the cookie_secret_file has changed.
-        TOpenSessionReq openReq = new TOpenSessionReq();
         try {
-          client.OpenSession(openReq);
-          throw new Exception("Expected failure due to changed cookie 
secret.");
+          client.OpenSession(new TOpenSessionReq());
         } catch (Exception e) {
           return e.getMessage();
         }
+        throw new Exception("Expected failure due to changed cookie secret.");
       }
     }, 20, 100);
-    assertEquals(respMessage, "HTTP Response code: 401");
+    assertEquals("HTTP Response code: 401", respMessage);
   }
 }

Reply via email to