frankvicky commented on code in PR #18668:
URL: https://github.com/apache/kafka/pull/18668#discussion_r1926153407


##########
core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala:
##########
@@ -222,6 +222,18 @@ class SaslClientsWithInvalidCredentialsTest extends 
AbstractSaslTest {
     }, s"Operation did not succeed within timeout after $attempts")
   }
 
+  private def verifyWithRetryPredicate(predicate: => Boolean): Unit = {
+    var attempts = 0
+    TestUtils.waitUntilTrue(() => {
+      try {
+        attempts += 1
+        predicate
+      } catch {
+        case _: SaslAuthenticationException => false
+      }
+    }, s"Operation did not succeed within timeout after $attempts")
+  }

Review Comment:
   Hi @lianetm 
   I have found that the cause of `testConsumerWithAuthenticationFailure` 
failing is due to a non-retriable assertion.
   
   
https://github.com/apache/kafka/blob/94a1bfb1281f06263976b1ba8bba8c5ac5d7f2ce/core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala#L157
   
   If we pass the assertion as an argument to `verifyWithRetry`, it will fail 
because we don't catch `AssertionFailedError` (and we shouldn't do it). The 
`subscribe` call needs to wait for metadata updates and it's not as quick as 
`assign`, so there's a high chance it will fail on the first `poll`. As 
mentioned, when we pass the assertion as an argument, it will fail with 
`AssertionFailedError` and cannot retry.



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to