@Test
    public void testTruncateEmptySegment() throws IOException {
        // This tests the scenario in which the follower truncates to an empty segment. In this
        // case we must ensure that the index is resized so that the log segment is not mistakenly
        // rolled due to a full index

        long maxSegmentMs = 300000;
        Time time = new MockTime();
        ElasticLogSegment seg = createOrLoadSegment(0, 10, time);
        seg.close();

        ElasticLogSegment reopened = createOrLoadSegment(0, 10, time);
        assertEquals(0, seg.timeIndex().sizeInBytes());

        assertFalse(reopened.timeIndex().isFull());

        RollParams rollParams = new RollParams(maxSegmentMs, Integer.MAX_VALUE, RecordBatch.NO_TIMESTAMP,
            100L, 1024, time.milliseconds());
        assertFalse(reopened.shouldRoll(rollParams));

        // The segment should not be rolled even if maxSegmentMs has been exceeded
        time.sleep(maxSegmentMs + 1);
        assertEquals(maxSegmentMs + 1, reopened.timeWaitedForRoll(time.milliseconds(), RecordBatch.NO_TIMESTAMP));
        rollParams = new RollParams(maxSegmentMs, Integer.MAX_VALUE, RecordBatch.NO_TIMESTAMP,
            100L, 1024, time.milliseconds());
        assertFalse(reopened.shouldRoll(rollParams));

        // But we should still roll the segment if we cannot fit the next offset
        rollParams = new RollParams(maxSegmentMs, Integer.MAX_VALUE, RecordBatch.NO_TIMESTAMP,
            Integer.MAX_VALUE + 200L, 1024, time.milliseconds());
        assertTrue(reopened.shouldRoll(rollParams));
    }
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