@Test
    public void testFindOffsetByTimestamp() throws IOException {
        int messageSize = records(0, "msg00").sizeInBytes();
        ElasticLogSegment seg = createOrLoadSegment(40, messageSize * 2 - 1, Time.SYSTEM);
        // Produce some messages
        for (int i = 40; i < 50; i++) {
            seg.append(i, i * 10, i, records(i, "msg" + i));
        }

        assertEquals(490, seg.largestTimestamp());
        // Search for an indexed timestamp
        assertEquals(42, seg.findOffsetByTimestamp(420, 0).get().offset);
        assertEquals(43, seg.findOffsetByTimestamp(421, 0).get().offset);
        // Search for an un-indexed timestamp
        assertEquals(43, seg.findOffsetByTimestamp(430, 0).get().offset);
        assertEquals(44, seg.findOffsetByTimestamp(431, 0).get().offset);
        // Search beyond the last timestamp
        assertTrue(seg.findOffsetByTimestamp(491, 0).isEmpty());
        // Search before the first indexed timestamp
        assertEquals(41, seg.findOffsetByTimestamp(401, 0).get().offset);
        // Search before the first timestamp
        assertEquals(40, seg.findOffsetByTimestamp(399, 0).get().offset);
    }
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