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

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


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 8d91cd204ce HBASE-28106 TestShadeSaslAuthenticationProvider fails for 
branch-2.x (#5433)
8d91cd204ce is described below

commit 8d91cd204cebfc891a4bb5c10646ef483d036703
Author: Duo Zhang <[email protected]>
AuthorDate: Sun Sep 24 21:43:08 2023 +0800

    HBASE-28106 TestShadeSaslAuthenticationProvider fails for branch-2.x (#5433)
    
    Signed-off-by: Nihal Jain <[email protected]>
---
 .../TestShadeSaslAuthenticationProvider.java       | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git 
a/hbase-examples/src/test/java/org/apache/hadoop/hbase/security/provider/example/TestShadeSaslAuthenticationProvider.java
 
b/hbase-examples/src/test/java/org/apache/hadoop/hbase/security/provider/example/TestShadeSaslAuthenticationProvider.java
index 5ddba9bca00..9c7aa355c4c 100644
--- 
a/hbase-examples/src/test/java/org/apache/hadoop/hbase/security/provider/example/TestShadeSaslAuthenticationProvider.java
+++ 
b/hbase-examples/src/test/java/org/apache/hadoop/hbase/security/provider/example/TestShadeSaslAuthenticationProvider.java
@@ -19,8 +19,8 @@ package org.apache.hadoop.hbase.security.provider.example;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -37,7 +37,6 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
@@ -50,6 +49,7 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.RetriesExhaustedException;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
@@ -217,7 +217,7 @@ public class TestShadeSaslAuthenticationProvider {
     }
   }
 
-  @Test(expected = DoNotRetryIOException.class)
+  @Test
   public void testNegativeAuthentication() throws Exception {
     // Validate that we can read that record back out as the user with our 
custom auth'n
     final Configuration clientConf = new Configuration(CONF);
@@ -227,17 +227,20 @@ public class TestShadeSaslAuthenticationProvider {
         UserGroupInformation.createUserForTesting("user1", new String[0]);
       user1.addToken(
         ShadeClientTokenUtil.obtainToken(conn, "user1", "not a real 
password".toCharArray()));
-      user1.doAs(new PrivilegedExceptionAction<Void>() {
-        @Override
-        public Void run() throws Exception {
-          try (Connection conn = 
ConnectionFactory.createConnection(clientConf);
-            Table t = conn.getTable(tableName)) {
-            t.get(new Get(Bytes.toBytes("r1")));
-            fail("Should not successfully authenticate with HBase");
-            return null;
+      // Server will close the connection directly once auth failed, so at 
client side, we do not
+      // know what is the real problem so we will keep retrying, until reached 
the max retry times
+      // limitation
+      assertThrows("Should not successfully authenticate with HBase",
+        RetriesExhaustedException.class, () -> user1.doAs(new 
PrivilegedExceptionAction<Void>() {
+          @Override
+          public Void run() throws Exception {
+            try (Connection conn = 
ConnectionFactory.createConnection(clientConf);
+              Table t = conn.getTable(tableName)) {
+              t.get(new Get(Bytes.toBytes("r1")));
+              return null;
+            }
           }
-        }
-      });
+        }));
     }
   }
 }

Reply via email to