ahuang98 commented on code in PR #16079:
URL: https://github.com/apache/kafka/pull/16079#discussion_r1628083453


##########
raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java:
##########
@@ -272,20 +280,109 @@ public void testUpdateHighWatermarkQuorumSizeThree() {
         assertEquals(Optional.empty(), state.highWatermark());
         assertTrue(state.updateReplicaState(node2, 0, new 
LogOffsetMetadata(15L)));
         assertEquals(Optional.of(new LogOffsetMetadata(15L)), 
state.highWatermark());
-        assertFalse(state.updateLocalState(new LogOffsetMetadata(20L)));
+        assertFalse(state.updateLocalState(new LogOffsetMetadata(20L), 
voterSet));
         assertEquals(Optional.of(new LogOffsetMetadata(15L)), 
state.highWatermark());
         assertTrue(state.updateReplicaState(node1, 0, new 
LogOffsetMetadata(20L)));
         assertEquals(Optional.of(new LogOffsetMetadata(20L)), 
state.highWatermark());
         assertFalse(state.updateReplicaState(node2, 0, new 
LogOffsetMetadata(20L)));
         assertEquals(Optional.of(new LogOffsetMetadata(20L)), 
state.highWatermark());
     }
 
+    @Test
+    public void testUpdateHighWatermarkAddingFollowerToVoterStates() {
+        int node1 = 1;
+        int node2 = 2;
+        Set<Integer> originalVoterSet = mkSet(localId, node1);
+        LeaderState<?> state = newLeaderState(originalVoterSet, 10L);
+        assertFalse(state.updateLocalState(new LogOffsetMetadata(15L), 
originalVoterSet));
+        assertFalse(state.updateReplicaState(node1, 0, new 
LogOffsetMetadata(10L)));
+        assertEquals(Optional.empty(), state.highWatermark());

Review Comment:
   `if (highWatermarkUpdateOffset > epochStartOffset)` condition is not met by 
the voters, so the HWM won't increase



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