dajac commented on code in PR #18923:
URL: https://github.com/apache/kafka/pull/18923#discussion_r1962047980
##########
core/src/test/java/kafka/server/integration/EligibleLeaderReplicasIntegrationTest.java:
##########
@@ -417,11 +417,21 @@ public void
testLastKnownLeaderShouldBeElectedIfEmptyElr(String quorum) throws E
waitForIsrAndElr((isrSize, elrSize) -> {
return isrSize > 0 && elrSize == 0;
});
- topicPartitionInfo =
adminClient.describeTopics(Collections.singletonList(testTopicName))
- .allTopicNames().get().get(testTopicName).partitions().get(0);
- assertEquals(0, topicPartitionInfo.lastKnownElr().size());
- assertEquals(0, topicPartitionInfo.elr().size());
- assertEquals(lastKnownLeader, topicPartitionInfo.leader().id());
+
+ kafka.utils.TestUtils.waitUntilTrue(
+ () -> {
+ try {
+ TopicPartitionInfo partition =
adminClient.describeTopics(Collections.singletonList(testTopicName))
+
.allTopicNames().get().get(testTopicName).partitions().get(0);
+ if (partition.leader() == null) return false;
+ return partition.lastKnownElr().isEmpty() &&
partition.elr().isEmpty() && partition.leader().id() == lastKnownLeader;
+ } catch (Exception e) {
+ return false;
+ }
+ },
+ () -> String.format("Partition metadata for %s is not
correct", testTopicName),
+ org.apache.kafka.test.TestUtils.DEFAULT_MAX_WAIT_MS, 100L
Review Comment:
nit: Could we statically import `DEFAULT_MAX_WAIT_MS` and avoid the full
qualified name?
##########
core/src/test/java/kafka/server/integration/EligibleLeaderReplicasIntegrationTest.java:
##########
@@ -417,11 +417,21 @@ public void
testLastKnownLeaderShouldBeElectedIfEmptyElr(String quorum) throws E
waitForIsrAndElr((isrSize, elrSize) -> {
return isrSize > 0 && elrSize == 0;
});
- topicPartitionInfo =
adminClient.describeTopics(Collections.singletonList(testTopicName))
- .allTopicNames().get().get(testTopicName).partitions().get(0);
- assertEquals(0, topicPartitionInfo.lastKnownElr().size());
- assertEquals(0, topicPartitionInfo.elr().size());
- assertEquals(lastKnownLeader, topicPartitionInfo.leader().id());
+
+ kafka.utils.TestUtils.waitUntilTrue(
Review Comment:
Is it possible to avoid `kafka.utils.`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]