jsancio commented on code in PR #19416:
URL: https://github.com/apache/kafka/pull/19416#discussion_r2054351475


##########
raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java:
##########
@@ -609,6 +708,161 @@ public void testBeginQuorumEpochTimer(boolean 
withDirectoryId) {
         assertEquals(0, 
state.timeUntilBeginQuorumEpochTimerExpires(time.milliseconds()));
     }
 
+    @Test
+    public void testVolatileVoters() {
+        int follower1 = 1;
+        long epochStartOffset = 10L;
+
+        VoterSet voters = localWithRemoteVoterSet(IntStream.of(follower1), 
false);
+        LeaderState<?> state = newLeaderState(
+            voters,
+            epochStartOffset,
+            KRaftVersion.KRAFT_VERSION_0
+        );
+
+        var votersWithLeaderUpdated = state.volatileVoters().get();
+        assertEquals(
+            voters.updateVoterIgnoringDirectoryId(localVoterNode).get(),
+            votersWithLeaderUpdated.voters()
+        );
+
+        var updatedVoters = new KRaftVersionUpgrade.Voters(
+            votersWithLeaderUpdated
+                .voters()
+                
.updateVoterIgnoringDirectoryId(VoterSetTest.voterNode(follower1, true))
+                .get()
+        );
+
+        // Upate in-memory voter and check state
+        assertTrue(
+            state.compareAndSetVolatileVoters(votersWithLeaderUpdated, 
updatedVoters)
+        );
+        assertEquals(updatedVoters, state.volatileVoters().get());
+
+        // Unable to perform atomic update
+        assertFalse(
+            state.compareAndSetVolatileVoters(votersWithLeaderUpdated, 
updatedVoters)
+        );
+    }
+
+    @Test
+    public void testInvalidMaybeAppendUpgradedKRaftVersion() {
+        int follower1 = 1;
+        int follower2 = 2;
+        long epochStartOffset = 10L;
+
+        VoterSet persistedVoters = 
localWithRemoteVoterSet(IntStream.of(follower1, follower2), false);
+        LeaderState<?> state = newLeaderState(
+            persistedVoters,
+            epochStartOffset,
+            KRaftVersion.KRAFT_VERSION_0
+        );
+
+        assertThrows(

Review Comment:
   Fixed.



-- 
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

Reply via email to