satishd commented on code in PR #14340:
URL: https://github.com/apache/kafka/pull/14340#discussion_r1316738717


##########
core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java:
##########
@@ -1387,6 +1390,112 @@ public void testStopPartitionsWithDeletion() throws 
RemoteStorageException {
         verify(remoteLogMetadataManager, 
times(16)).updateRemoteLogSegmentMetadata(any());
     }
 
+    /**
+     * This test asserts that the newly elected leader for a partition is able 
to find the log-start-offset.
+     * Note that the case tested here is that the previous leader deleted the 
log segments up-to offset 500. And, the
+     * log-start-offset didn't propagate to the replicas before the 
leader-election.
+     */
+    @Test
+    public void testFindLogStartOffset() throws RemoteStorageException, 
IOException {
+        List<EpochEntry> epochEntries = new ArrayList<>();
+        epochEntries.add(new EpochEntry(0, 0L));
+        epochEntries.add(new EpochEntry(1, 250L));
+        epochEntries.add(new EpochEntry(2, 550L));
+        checkpoint.write(epochEntries);
+
+        LeaderEpochFileCache cache = new 
LeaderEpochFileCache(leaderTopicIdPartition.topicPartition(), checkpoint);
+        when(mockLog.leaderEpochCache()).thenReturn(Option.apply(cache));
+
+        long timestamp = time.milliseconds();
+        int segmentSize = 1024;
+        List<RemoteLogSegmentMetadata> segmentMetadataList = Arrays.asList(
+                new RemoteLogSegmentMetadata(new 
RemoteLogSegmentId(leaderTopicIdPartition, Uuid.randomUuid()),
+                        500, 599, timestamp, brokerId, timestamp, segmentSize, 
truncateAndGetLeaderEpochs(epochEntries, 500L, 599L)),
+                new RemoteLogSegmentMetadata(new 
RemoteLogSegmentId(leaderTopicIdPartition, Uuid.randomUuid()),

Review Comment:
   This segment contains records with epoch 2 instead of 1 but we are returning 
this for epoch 1.



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