@Test
    public void testRecoveryRebuildsEpochCache() throws IOException {
        ElasticLogSegment seg = createOrLoadSegment(0);

        ElasticLeaderEpochCheckpoint checkpoint = new ElasticLeaderEpochCheckpoint(new ElasticLeaderEpochCheckpointMeta(0, new ArrayList<>()), meta -> {
        });
        LeaderEpochFileCache cache = new LeaderEpochFileCache(topicPartition, checkpoint, new MockScheduler(Time.SYSTEM));
        seg.append(105L, RecordBatch.NO_TIMESTAMP,
            104L, MemoryRecords.withRecords(104L, Compression.NONE, 0,
                new SimpleRecord("a".getBytes()), new SimpleRecord("b".getBytes())));

        seg.append(107L, RecordBatch.NO_TIMESTAMP,
            106L, MemoryRecords.withRecords(106L, Compression.NONE, 1,
                new SimpleRecord("a".getBytes()), new SimpleRecord("b".getBytes())));

        seg.append(109L, RecordBatch.NO_TIMESTAMP,
            108L, MemoryRecords.withRecords(108L, Compression.NONE, 1,
                new SimpleRecord("a".getBytes()), new SimpleRecord("b".getBytes())));

        seg.append(111L, RecordBatch.NO_TIMESTAMP,
            110, MemoryRecords.withRecords(110L, Compression.NONE, 2,
                new SimpleRecord("a".getBytes()), new SimpleRecord("b".getBytes())));

        seg.recover(newProducerStateManager(), Optional.of(cache));
        assertEquals(List.of(new EpochEntry(0, 104L),
                new EpochEntry(1, 106),
                new EpochEntry(2, 110)),
            cache.epochEntries());
    }
This test was intended to test truncation and rolling in LogSegment. However, truncation is not supported in
ElasticLogSegment. Therefore, we cut this test down to just verify the rolling and leave the test name as is.
core/src/test/java/kafka/log/streamaspect/ElasticLogSegmentTest.java