dajac commented on code in PR #14985: URL: https://github.com/apache/kafka/pull/14985#discussion_r1433031924
########## core/src/test/scala/unit/kafka/coordinator/group/CoordinatorLoaderImplTest.scala: ########## @@ -511,4 +544,35 @@ class CoordinatorLoaderImplTest { new FetchDataInfo(new LogOffsetMetadata(startOffset), fileRecords) } + + private def logReadResult( + startOffset: Long, + producerId: Long, + producerEpoch: Short, + controlRecordType: ControlRecordType + ): FetchDataInfo = { + val fileRecords = mock(classOf[FileRecords]) + val memoryRecords = MemoryRecords.withEndTransactionMarker( + startOffset, + 0L, + RecordBatch.NO_PARTITION_LEADER_EPOCH, + producerId, + producerEpoch, + new EndTransactionMarker(controlRecordType, 0) + ) + + when(fileRecords.sizeInBytes).thenReturn(memoryRecords.sizeInBytes) + + val bufferCapture: ArgumentCaptor[ByteBuffer] = ArgumentCaptor.forClass(classOf[ByteBuffer]) + when(fileRecords.readInto( + bufferCapture.capture(), + ArgumentMatchers.anyInt()) + ).thenAnswer { _ => + val buffer = bufferCapture.getValue + buffer.put(memoryRecords.buffer.duplicate) + buffer.flip() + } + + new FetchDataInfo(new LogOffsetMetadata(startOffset), fileRecords) Review Comment: From an API perspective, we could get both FileRecords or MemoryRecords so we have to handle both. In practice, it is mainly FileRecords from your read from a real log. Testing with MemoryRecords is not so interesting as you can see. -- 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