FrankYang0529 commented on code in PR #16753:
URL: https://github.com/apache/kafka/pull/16753#discussion_r1703783178


##########
clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java:
##########
@@ -7811,6 +7816,40 @@ public void testListClientMetricsResourcesNotSupported() 
{
         }
     }
 
+    @Test
+    public void 
testCallFailWithUnsupportedVersionExceptionDoesNotHaveConcurrentModificationException()
 throws InterruptedException {
+        try (AdminClientUnitTestEnv env = new 
AdminClientUnitTestEnv(mockCluster(1, 0))) {
+            AdminMetadataManager metadataManager = 
mock(AdminMetadataManager.class);
+
+            // first false result make sure 
LeastLoadedBrokerOrActiveKController#provide can go to requestUpdate
+            // second true result make sure 
LeastLoadedBrokerOrActiveKController#provide can get a node
+            doReturn(false).doReturn(true).when(metadataManager).isReady();
+
+            // make maybeDrainPendingCall throw UnsupportedVersionException 
and go to Call#fail
+            doThrow(new UnsupportedVersionException("Unsupported 
version")).doNothing().when(metadataManager).requestUpdate();
+
+            // make sure describeCluster handleUnsupportedVersionException 
doesn't always return false
+            doReturn(false).when(metadataManager).usingBootstrapControllers();
+            // avoid sending fetchMetadata request
+            doReturn(1L).when(metadataManager).metadataFetchDelayMs(anyLong());
+
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
+
+            try (KafkaAdminClient admin = KafkaAdminClient.createInternal(

Review Comment:
   Yes, originally, I would like to avoid waiting long time for 
`KafkaAdminClient#close` because there is active external call and 
`threadShouldExit` always return false. I add `timeoutMs` when test sends 
`listNodes` request, so the admin client can be closed in expected time. Thanks.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to