kevin-wu24 commented on code in PR #23168:
URL: https://github.com/apache/kafka/pull/23168#discussion_r4348795252
##########
raft/src/test/java/org/apache/kafka/raft/FollowerStateTest.java:
##########
@@ -122,6 +122,24 @@ public void
testPreVoteAfterSuccessfulFetchFromLeader(boolean isLogUpToDate) {
assertFalse(state.canGrantVote(ReplicaKey.of(10,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, false));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testPreVoteAfterLeaderResigned(boolean isLogUpToDate) {
+ FollowerState state = newFollowerState(Set.of(1, 2, 3));
+ state.resetFetchTimeoutForSuccessfulFetch(time.milliseconds());
+ state.setLeaderHasResigned();
+
+ assertEquals(isLogUpToDate, state.canGrantVote(ReplicaKey.of(1,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, true));
+ assertEquals(isLogUpToDate, state.canGrantVote(ReplicaKey.of(2,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, true));
+ assertEquals(isLogUpToDate, state.canGrantVote(ReplicaKey.of(3,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, true));
+ assertEquals(isLogUpToDate, state.canGrantVote(ReplicaKey.of(10,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, true));
+
+ assertFalse(state.canGrantVote(ReplicaKey.of(1,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, false));
+ assertFalse(state.canGrantVote(ReplicaKey.of(2,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, false));
+ assertFalse(state.canGrantVote(ReplicaKey.of(3,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, false));
+ assertFalse(state.canGrantVote(ReplicaKey.of(10,
ReplicaKey.NO_DIRECTORY_ID), isLogUpToDate, false));
+ }
Review Comment:
> I kept the FollowerStateTest case as a state-level check, since Mickael
asked for it.
Yeah that is fine to keep.
--
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]