-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-18915: Rewrite AdminClientRebootstrapTest to cover the current scenario #19187
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
KAFKA-18915: Rewrite AdminClientRebootstrapTest to cover the current scenario #19187
Conversation
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.
@clarkwtc : Thanks for the patch.
| // Only the server 0 is available for the admin client during the bootstrap. | ||
| TestUtils.waitForCondition(() -> admin.listTopics().names().get(timeout, TimeUnit.MINUTES).contains(topic), | ||
| // Only the broker 1 is available for the admin client during the bootstrap. | ||
| TestUtils.waitForCondition(() -> admin.listTopics().names().get(timeout, TimeUnit.MINUTES).contains(TOPIC), |
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.
Out of curiosity, why did we have a 5-minute timeout here?
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.
Thank you for your comments.
Maybe it’s a bit too long to wait here.
I updated to 60 seconds.
| clusterInstance.startBroker(broker0); | ||
|
|
||
| // The broker 1, originally cached during the bootstrap, is offline. | ||
| // The admin client will throw a TimeoutException because the brokers are offline during the bootstrap list |
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.
This code comment is not correct.
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.
Thank you for your comments.
Sure, this situation refers to the brokers being offline since they were cached during the bootstrap.
I updated the code comments.
|
@clarkwtc cloud you please move this test to clients-integration-tests module? |
| // The broker 1, originally cached during the bootstrap, is offline. | ||
| // The admin client will throw a TimeoutException because the brokers are offline during the bootstrap list | ||
| assertThrows(TimeoutException.class, () -> admin.listTopics().names().get(5, TimeUnit.SECONDS)); | ||
| // The admin client needs to wait the default timeout for other threads because the brokers are offline. |
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.
Ditto.
| // The admin client will throw a TimeoutException because the brokers are offline during the bootstrap list | ||
| assertThrows(TimeoutException.class, () -> admin.listTopics().names().get(5, TimeUnit.SECONDS)); | ||
| // The admin client needs to wait the default timeout for other threads because the brokers are offline. | ||
| admin.close(Duration.ofSeconds(0)); |
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.
nit: Duration.ZERO
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.
I've fixed it.
|
@chia7712 |
|
@clarkwtc please check the build error |
…_test-testing-scenario
|
@chia7712 |
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.
@clarkwtc thanks for your patch.
| private static final int PARTITIONS = 2; | ||
|
|
||
| @ClusterTest( | ||
| brokers = 2, |
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.
2 -> PARTITIONS
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.
Thank you for your comments.
I've fixed it.
| } | ||
|
|
||
| @ClusterTest( | ||
| brokers = 2, |
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.
ditto
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.
I've fixed it.
| brokers = 2, | ||
| types = {Type.KRAFT}, | ||
| serverProperties = { | ||
| @ClusterConfigProperty(key = TopicConfig.UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG, value = "true"), |
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.
we don't need those configs, since this test case does not use either producer or consumer.
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.
Sorry, I wrote the config for ProducerClientRebootstrapTest, but I messed up how to use it.
| brokers = 2, | ||
| types = {Type.KRAFT}, | ||
| serverProperties = { | ||
| @ClusterConfigProperty(key = TopicConfig.UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG, value = "true"), |
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.
ditto
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.
I've fixed it.
|
|
||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| public class AdminClientRebootstrapTest { |
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.
maybe we can rename it to ClientRebootstrapTest and merge producer/consumer into this class
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.
No problem;
I also changed ClientRebootstrapTest file location from org/apache/kafka/clients/admin to org/apache/kafka/clients and renamed functions.
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.
Thanks for this patch, a little comment
| admin.createTopics(List.of(new NewTopic(TOPIC, PARTITIONS, (short) 2))); | ||
|
|
||
| // Only the broker 1 is available for the admin client during the bootstrap. | ||
| Assertions.assertDoesNotThrow(() -> admin.listTopics().names().get(timeout, TimeUnit.SECONDS).contains(TOPIC)); |
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.
nit: static import
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.
Thank you for your comments.
I've fixed it.
- Change Assertions to static import - Redefine AdminClientRebootstrapTest to ClientRebootstrapTest - Remove unused config UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG
…_test-testing-scenario
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.
@clarkwtc thanks for this patch.
|
|
||
| public class ClientRebootstrapTest { | ||
| private static final String TOPIC = "topic"; | ||
| private static final int PARTITIONS = 2; |
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.
the purpose is to ensure each broker has a replica, and hence it should be renamed to "REPLICAS"
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.
I've fixed it.
| clusterInstance.shutdownBroker(broker0); | ||
|
|
||
| try (var admin = clusterInstance.admin()) { | ||
| admin.createTopics(List.of(new NewTopic(TOPIC, PARTITIONS, (short) 2))); |
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.
All we need is "one partition" and "two replicas", right?
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.
Sure, we only need one partition across two brokers because the topic will be replicated to both brokers.
Follow-up: #19094
We need to rewrite
AdminClientRebootstrapTestto cover the current scenario.Added the admin client with rebootstrap disabled, as the admin client uses the default
AdminClientRebootstrapconfiguration setting.Default
AdminClientRebootstrapconfig:The test case for the admin client with enabled rebootstrap

The test case for the admin client with disabled rebootstrap

Reviewers: Jhen-Yung Hsu jhenyunghsu@gmail.com, TengYao Chi kitingiao@gmail.com, Ken Huang s7133700@gmail.com, Chia-Ping Tsai chia7712@gmail.com