@Test
    public void testCreateWithInitFileSizeClearShutdown() throws IOException {

        ElasticLogSegment seg = createOrLoadSegment(40, 10, Time.SYSTEM);

        MemoryRecords ms = records(40, "hello", "there");
        seg.append(41, RecordBatch.NO_TIMESTAMP, -1L, ms);
        MemoryRecords ms2 = records(42, "alpha", "beta");
        seg.append(43, RecordBatch.NO_TIMESTAMP, -1L, ms2);
        FetchDataInfo read = seg.read(42, 200);
        checkEquals(ms2.records().iterator(), read.records.records().iterator());
        int oldSize = seg.size();
        seg.close();

        ElasticLogSegment segReopen = createOrLoadSegment(40, 10, Time.SYSTEM);

        FetchDataInfo readAgain = segReopen.read(42, 200);
        checkEquals(ms2.records().iterator(), readAgain.records.records().iterator());
        int size = segReopen.size();

        assertEquals(oldSize, size);
    }
This test was intended to check file size and positions after closing and reopening a segment.
Since there is no log file in ElasticLogSegment, we only test the segment size when reopening.
The method name is kept the same for compatibility.
core/src/test/java/kafka/log/streamaspect/ElasticLogSegmentTest.java