ahuang98 commented on code in PR #18240: URL: https://github.com/apache/kafka/pull/18240#discussion_r1917365519
########## raft/src/test/java/org/apache/kafka/raft/RaftClientTestContext.java: ########## @@ -629,40 +681,67 @@ void pollUntilRequest() throws InterruptedException { } void assertVotedCandidate(int epoch, int candidateId) { + ReplicaKey candidateKey = ReplicaKey.of(candidateId, ReplicaKey.NO_DIRECTORY_ID); + assertVotedCandidate(epoch, candidateKey); + } + + void assertVotedCandidate(int epoch, ReplicaKey candidateKey) { assertEquals( ElectionState.withVotedCandidate( epoch, - ReplicaKey.of(candidateId, ReplicaKey.NO_DIRECTORY_ID), - startingVoters.voterIds() + persistedVotedKey(candidateKey, kraftVersion), + expectedVoters() ), quorumStateStore.readElectionState().get() ); } public void assertElectedLeader(int epoch, int leaderId) { - Set<Integer> voters = kraftVersion.isReconfigSupported() ? - Collections.emptySet() : startingVoters.voterIds(); assertEquals( - ElectionState.withElectedLeader(epoch, leaderId, voters), + ElectionState.withElectedLeader(epoch, leaderId, Optional.empty(), expectedVoters()), quorumStateStore.readElectionState().get() ); } - void assertUnknownLeader(int epoch) { + public void assertElectedLeaderAndVotedCandidate(int epoch, int leaderId, ReplicaKey candidateKey) { assertEquals( - ElectionState.withUnknownLeader(epoch, startingVoters.voterIds()), + new ElectionState( + epoch, + OptionalInt.of(leaderId), + Optional.of(persistedVotedKey(candidateKey, kraftVersion)), + expectedVoters() + ), quorumStateStore.readElectionState().get() ); } + private ReplicaKey persistedVotedKey(ReplicaKey replicaKey, KRaftVersion kraftVersion) { + if (kraftVersion.featureLevel() == 1) { + return replicaKey; + } Review Comment: I'll change the other variations of this method to do the same -- 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