songnon commented on code in PR #12543: URL: https://github.com/apache/kafka/pull/12543#discussion_r959153232
########## core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala: ########## @@ -490,6 +490,41 @@ class ControllerIntegrationTest extends QuorumTestHarness { "failed to get expected partition state upon broker startup") } + @Test + def testAutoPreferredReplicaLeaderElectionWithReassigningPartitions(): Unit = { + servers = makeServers(3, autoLeaderRebalanceEnable = true) + val controllerId = TestUtils.waitUntilControllerElected(zkClient) + val leaderBrokerId = servers.map(_.config.brokerId).filter(_ != controllerId).head + val otherBrokerId = servers.map(_.config.brokerId).filter(e => e != controllerId && e != leaderBrokerId).head + val tp = new TopicPartition("t", 0) + val assignment = Map(tp.partition -> Seq(leaderBrokerId, controllerId)) + TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers) + val reassigningTp = new TopicPartition("reassigning", 0) + val reassigningTpAssignment = Map(reassigningTp.partition -> Seq(controllerId)) + + TestUtils.createTopic(zkClient, reassigningTp.topic, partitionReplicaAssignment = reassigningTpAssignment, servers = servers) + servers(leaderBrokerId).shutdown() + servers(leaderBrokerId).awaitShutdown() + + servers(otherBrokerId).shutdown() + servers(otherBrokerId).awaitShutdown() + waitForPartitionState(tp, firstControllerEpoch, controllerId, LeaderAndIsr.InitialLeaderEpoch + 1, + "failed to get expected partition state upon broker shutdown") + + val reassignment = Map(reassigningTp -> ReplicaAssignment(Seq(otherBrokerId), List(), List())) + zkClient.createPartitionReassignment(reassignment.map { case (k, v) => k -> v.replicas }) Review Comment: You are right. Thanks. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org