showuon commented on a change in pull request #8712: URL: https://github.com/apache/kafka/pull/8712#discussion_r436446907
########## File path: streams/src/test/java/org/apache/kafka/streams/processor/internals/InternalTopicManagerTest.java ########## @@ -287,12 +290,49 @@ public void shouldLogWhenTopicNotFoundAndNotThrowException() { assertThat( appender.getMessages(), - hasItem("stream-thread [" + threadName + "] Topic internal-topic is unknown or not found, hence not existed yet:" + - " org.apache.kafka.common.errors.UnknownTopicOrPartitionException: Topic internal-topic not found.") + hasItem("stream-thread [" + threadName + "] Topic internal-topic is unknown or not found, hence not existed yet.\n" + + "Error message was: org.apache.kafka.common.errors.UnknownTopicOrPartitionException: Topic internal-topic not found.") ); } } + @Test + public void shouldLogWhenTopicLeaderNotAvailableAndThrowException() { + final String topicLeaderNotAvailable = "LeaderNotAvailableTopic"; + mockAdminClient.addTopic( + false, + topicLeaderNotAvailable, + Collections.singletonList(new TopicPartitionInfo(0, broker1, cluster, Collections.emptyList())), + null); + + final InternalTopicConfig internalTopicConfig = new RepartitionTopicConfig(topicLeaderNotAvailable, Collections.emptyMap()); + internalTopicConfig.setNumberOfPartitions(1); + + final Map<String, InternalTopicConfig> topicConfigMap = new HashMap<>(); + topicConfigMap.put(topicLeaderNotAvailable, internalTopicConfig); + + LogCaptureAppender.setClassLoggerToDebug(InternalTopicManager.class); + try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(InternalTopicManager.class)) { + final StreamsException exception = assertThrows( + StreamsException.class, + () -> internalTopicManager.makeReady(topicConfigMap)); + + final String expectedMessage = "Could not create topics after 1 retries. This can happen if the Kafka cluster is temporary not available"; Review comment: Good suggestion. Remove the log message check and only verify the exception thrown. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org