jsancio commented on a change in pull request #10593:
URL: https://github.com/apache/kafka/pull/10593#discussion_r640805609



##########
File path: raft/src/test/java/org/apache/kafka/raft/RaftClientTestContext.java
##########
@@ -963,6 +952,20 @@ static void verifyLeaderChangeMessage(
             new HashSet<>(leaderChangeMessage.grantingVoters()));
     }
 
+    public void advanceLeaderHighWatermarkToEndOffset() throws 
InterruptedException {
+        Integer replicaId = null;
+        for (Integer voter: voters) {
+            if (voter != localId.getAsInt()) {
+                replicaId = voter;
+                break;
+            }
+        }
+        deliverRequest(fetchRequest(currentEpoch(), replicaId, 
log.endOffset().offset, currentEpoch(), 0));
+        pollUntilResponse();
+        assertSentFetchPartitionResponse(Errors.NONE, currentEpoch(), localId);
+        assertEquals(log.endOffset().offset, 
client.highWatermark().getAsLong());
+    }

Review comment:
       I needed something similar in a PR I am currently working and this is 
what I have if you want to adapt it to your PR:
   
   ```java
   public void advanceLocalLeaderHighWatermarkToLogEndOffset() throws 
InterruptedException {
       assertEquals(localId, currentLeader());
       long localLogEndOffset = log.endOffset().offset;
       Set<Integer> followers = voters.stream().filter(voter -> voter != 
localId.getAsInt()).collect(Collectors.toSet());
   
       // Send a request from every follower
       for (int follower : followers) {
           deliverRequest(
               fetchRequest(currentEpoch(), follower, localLogEndOffset, 
currentEpoch(), 0)
           );
           pollUntilResponse();
           assertSentFetchPartitionResponse(Errors.NONE, currentEpoch(), 
localId);
       }
   
       pollUntil(() -> 
OptionalLong.of(localLogEndOffset).equals(client.highWatermark()));
   }
   ```




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to