private static int sizeInBytes(List<ApiMessageAndVersion> records) {
        int size = 0;
        for (ApiMessageAndVersion record : records) {
            ObjectSerializationCache cache = new ObjectSerializationCache();
            size += MetadataRecordSerde.INSTANCE.recordSize(record, cache);
        }
        return size;
    }
Create a batch reader for testing.

@param lastOffset the last offset of the given list of records
@param appendTimestamp the append timestamp for the batches created
@param records the records
@return a batch reader which will return the given records
metadata/src/test/java/org/apache/kafka/metadata/RecordTestUtils.java