Skip to content

Commit 0afa3f6

Browse files
committed
Ensure tests wait for leadership movement
Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
1 parent 8c5c7cc commit 0afa3f6

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/executor

cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/executor/ExecutorTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,13 @@ private void executeAndVerifyProposals(AdminClient adminClient,
869869
topic.partitions().get(tp.partition()).replicas().stream().anyMatch(rep -> r.brokerId().equals(rep.id())));
870870
}
871871
}
872+
873+
// Wait for leader movement
874+
TopicDescription topicAfterLeaderMove = _cluster.waitForTopicMetadata(tp.topic(), Duration.ofSeconds(60),
875+
topicDescription -> topicDescription.partitions().get(tp.partition()).leader().id()
876+
== proposal.newLeader().brokerId());
872877
assertEquals("The leader should have moved for " + tp,
873-
proposal.newLeader().brokerId().intValue(), topic.partitions().get(tp.partition()).leader().id());
878+
proposal.newLeader().brokerId().intValue(), topicAfterLeaderMove.partitions().get(tp.partition()).leader().id());
874879

875880
}
876881
if (isTriggeredByUserRequest) {

0 commit comments

Comments
 (0)