joshelser commented on a change in pull request #1102: HBASE-23752: Fix 
remaining test failures from nightly runs
URL: https://github.com/apache/hbase/pull/1102#discussion_r373525226
 
 

 ##########
 File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/security/provider/TestCustomSaslAuthenticationProvider.java
 ##########
 @@ -527,12 +568,22 @@ public void testNegativeAuthentication() throws 
Exception {
     user1.addToken(createPasswordToken("user1", "definitely not the password", 
clusterId));
     user1.doAs(new PrivilegedExceptionAction<Void>() {
       @Override public Void run() throws Exception {
+        // Depending on the registry in use, the following code can throw 
exceptions at different
+        // places. Master registry fails at the createConnection() step 
because the RPC to the
+        // master fails with sasl auth. With ZK registry, connection creation 
succeeds (since there
+        // is no RPC to HBase services involved) but the subsequent get() 
fails. The root cause
+        // should still be a SaslException in both the cases.
         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;
+        } catch (MasterRegistryFetchException mfe) {
+          Throwable cause = mfe.getCause();
+          assertTrue(cause.getMessage(), 
cause.getMessage().contains("SaslException"));
+        } catch (RetriesExhaustedException re) {
+          assertTrue(re.getMessage(), 
re.getMessage().contains("SaslException"));
         }
+        return null;
 
 Review comment:
   There's a `throws Exception` on `run()` so we need  a `fail()` "close" to 
the `return null`. Right now, an exception other than 
MasterRegistryFetchException and RetriesExhaustedException would not cause a 
unit test failure.
   
   You can just move the `fail` from inside the try, next to this `return null` 
and change the message to be something like `Expected an authentication 
failure`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to