chia7712 commented on code in PR #20375: URL: https://github.com/apache/kafka/pull/20375#discussion_r2296800523
########## clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java: ########## @@ -11668,4 +11668,23 @@ private static StreamsGroupDescribeResponseData makeFullStreamsGroupDescribeResp .setAssignmentEpoch(1)); return data; } + + @Test + public void testDescribeClusterTimeoutWhenNoBrokerResponds() throws Exception { + try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv( + mockCluster(1, 0), + AdminClientConfig.RETRIES_CONFIG, "0", + AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, "30000")) { + env.kafkaClient().setNodeApiVersions(NodeApiVersions.create()); + + // Not using prepareResponse is equivalent to "no brokers respond". + long start = System.currentTimeMillis(); + ExecutionException exception = assertThrows(ExecutionException.class, () -> env.adminClient().describeCluster(new DescribeClusterOptions().timeoutMs(200)).clusterId().get()); + // Duration should be greater than or equal to 200 ms but less than 30000 ms. + long duration = System.currentTimeMillis() - start; + + assertTrue(exception.getCause() instanceof TimeoutException); Review Comment: ``` assertInstanceOf(TimeoutException.class, exception.getCause()); ``` ########## clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java: ########## @@ -11668,4 +11668,23 @@ private static StreamsGroupDescribeResponseData makeFullStreamsGroupDescribeResp .setAssignmentEpoch(1)); return data; } + + @Test + public void testDescribeClusterTimeoutWhenNoBrokerResponds() throws Exception { + try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv( + mockCluster(1, 0), + AdminClientConfig.RETRIES_CONFIG, "0", + AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, "30000")) { + env.kafkaClient().setNodeApiVersions(NodeApiVersions.create()); + + // Not using prepareResponse is equivalent to "no brokers respond". + long start = System.currentTimeMillis(); + ExecutionException exception = assertThrows(ExecutionException.class, () -> env.adminClient().describeCluster(new DescribeClusterOptions().timeoutMs(200)).clusterId().get()); Review Comment: the API which should be tested is `describeTopics`, right? -- 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