-
Notifications
You must be signed in to change notification settings - Fork 14.6k
MINOR: describeTopics should pass the timeout to the describeCluster call #20375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
ea01714
7300c6c
7a1dee8
f754c1c
976a33b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11668,4 +11668,26 @@ private static StreamsGroupDescribeResponseData makeFullStreamsGroupDescribeResp | |||||
.setAssignmentEpoch(1)); | ||||||
return data; | ||||||
} | ||||||
|
||||||
@Test | ||||||
public void testDescribeTopicsTimeoutWhenNoBrokerResponds() 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(); | ||||||
DescribeTopicsResult result = env.adminClient().describeTopics(Collections.singletonList("test-topic"), new DescribeTopicsOptions().timeoutMs(200)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
Map<String, KafkaFuture<TopicDescription>> topicDescriptionMap = result.topicNameValues(); | ||||||
KafkaFuture<TopicDescription> topicDescription = topicDescriptionMap.get("test-topic"); | ||||||
ExecutionException exception = assertThrows(ExecutionException.class, () -> topicDescription.get()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for these suggestions, update it. |
||||||
// Duration should be greater than or equal to 200 ms but less than 30000 ms. | ||||||
long duration = System.currentTimeMillis() - start; | ||||||
|
||||||
assertInstanceOf(TimeoutException.class, exception.getCause()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a common debate between In this case, I prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explanation! |
||||||
assertTrue(duration >= 150L && duration < 2000L); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pardon me, how do you come up with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this comment, update it. |
||||||
} | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add
@Timeout(30)
to this unit test?