-
Notifications
You must be signed in to change notification settings - Fork 14k
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-17986: Fix ConsumerRebootstrapTest and ProducerRebootstrapTest #18175
base: trunk
Are you sure you want to change the base?
Conversation
- Add unclean.leader.election.enable=true to topic configuration when creating test topic to ensure controller node has the correct setting - Set unclean.leader.election.interval.ms to 1ms (down from default 5 minutes) to speed up test execution in KRaft mode
@peterxcli I update the topic to match the changes. it is ok to file two PRs :) |
Properties topicProps = new Properties(); | ||
topicProps.put(TopicConfig.UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG, "true"); | ||
|
||
admin.createTopics(List.of(new NewTopic(topicName, 2, (short) 2).configs(Utils.propsToStringMap(topicProps)))).all().get(); |
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.
Should we need cluster.waitForTopic(topicName, 2);
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.
I think that's only necessary when the topic metadata has changed?
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.
Yes, but create topic will change metadata, 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.
Oh thanks, you're right.
But seems the old test infra doesn't wait for the metadata propagation explicitly.
So I think it's ok the skip that.
kafka/core/src/test/scala/unit/kafka/utils/TestUtils.scala
Lines 380 to 406 in 772aa24
def createTopicWithAdminRaw[B <: KafkaBroker]( | |
admin: Admin, | |
topic: String, | |
numPartitions: Int = 1, | |
replicationFactor: Int = 1, | |
replicaAssignment: collection.Map[Int, Seq[Int]] = Map.empty, | |
topicConfig: Properties = new Properties, | |
): Uuid = { | |
val configsMap = new util.HashMap[String, String]() | |
topicConfig.forEach((k, v) => configsMap.put(k.toString, v.toString)) | |
val result = if (replicaAssignment.isEmpty) { | |
admin.createTopics(Collections.singletonList(new NewTopic( | |
topic, numPartitions, replicationFactor.toShort).configs(configsMap))) | |
} else { | |
val assignment = new util.HashMap[Integer, util.List[Integer]]() | |
replicaAssignment.foreachEntry { case (k, v) => | |
val replicas = new util.ArrayList[Integer] | |
v.foreach(r => replicas.add(r.asInstanceOf[Integer])) | |
assignment.put(k.asInstanceOf[Integer], replicas) | |
} | |
admin.createTopics(Collections.singletonList(new NewTopic( | |
topic, assignment).configs(configsMap))) | |
} | |
result.topicId(topic).get() | |
} |
Add ability to configure fixed broker ports in test framework instead of using ephemeral ports. This helps with: - Debugging by making broker ports predictable and consistent - Avoiding port conflicts in certain test scenarios - Better control over broker port assignment Changes include: - Add fixedBrokerPorts flag to TestKitNodes and ClusterConfig - Add port selection logic in KafkaClusterTestKit - Add choosePort() utility method to TestUtils - Update ClusterTest annotation to support fixed ports configuration The change is backward compatible as fixedBrokerPorts defaults to false, maintaining existing behavior.
This reverts commit 33e7c12.
This reverts commit 5580f3e.
- Remove @disabled annotation from ConsumerRebootstrapTest - Add clarifying comment about leader shutdown in ProducerRebootstrapTest - Improve documentation in RebootstrapTest regarding unclean leader election - Clean up comment formatting
This PR only fix these two tests, will migrate them to |
Hi @chia7712, this PR is ready for review, PTAL. Thanks! |
As we discussed #18175 (comment), change this PR title back to "Fix ConsumerRebootstrapTest and ProducerRebootstrapTest". |
ProducerRebootstrapTest
has many issues in using kraft.it passes
unclean.leader.election.enable
as server config but it is not configured on controller node. We should append the config to topic in creating topic.it assumes
topic
is distributed on [0, 1]. If the order is not correct, the test can't pass. We should create the topic manually to ensure the distribution.in kraft mode, the time to trigger unclean election is 5 mins. it is too long to wait. We should configure controller to reduce the number.
More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.
Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.
Committer Checklist (excluded from commit message)