iit2009060 commented on code in PR #15060:
URL: https://github.com/apache/kafka/pull/15060#discussion_r1435444785


##########
core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java:
##########
@@ -2161,6 +2167,86 @@ RecordBatch findFirstBatch(RemoteLogInputStream 
remoteLogInputStream, long offse
         }
     }
 
+    @Test
+    public void testReadForFirstBatchInLogCompaction() throws 
RemoteStorageException, IOException {
+        FileInputStream fileInputStream = mock(FileInputStream.class);
+        RemoteLogInputStream remoteLogInputStream = 
mock(RemoteLogInputStream.class);
+        ClassLoaderAwareRemoteStorageManager rsmManager = 
mock(ClassLoaderAwareRemoteStorageManager.class);
+        RemoteLogSegmentMetadata segmentMetadata = 
mock(RemoteLogSegmentMetadata.class);
+        LeaderEpochFileCache cache = mock(LeaderEpochFileCache.class);
+        when(cache.epochForOffset(anyLong())).thenReturn(OptionalInt.of(1));
+
+        
when(remoteStorageManager.fetchLogSegment(any(RemoteLogSegmentMetadata.class), 
anyInt()))
+                .thenAnswer(a -> fileInputStream);
+        when(mockLog.leaderEpochCache()).thenReturn(Option.apply(cache));
+
+        int fetchOffset = 0;
+        int fetchMaxBytes = 10;
+        int recordBatchSizeInBytes = fetchMaxBytes + 1;
+        RecordBatch firstBatch = mock(RecordBatch.class);
+        ArgumentCaptor<ByteBuffer> capture = 
ArgumentCaptor.forClass(ByteBuffer.class);
+
+        FetchRequest.PartitionData partitionData = new 
FetchRequest.PartitionData(
+                Uuid.randomUuid(), fetchOffset, 0, fetchMaxBytes, 
Optional.empty()
+        );
+
+        when(rsmManager.fetchLogSegment(any(), 
anyInt())).thenReturn(fileInputStream);
+        when(remoteLogMetadataManager.remoteLogSegmentMetadata(any(), 
anyInt(), anyLong())).thenReturn(Optional.of(segmentMetadata), 
Optional.of(segmentMetadata));

Review Comment:
   We are calling it two times in the Unit Test.So we need two times this value 
to be returned. 



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