Source:
public void testValidDataSizeAfterExpiration() throws InterruptedException, StoreException, IOException { state.advanceTime(Time.MsPerSec); long timeInMsBeforeExpiringPuts = state.time.milliseconds(); long totalLogSegmentValidSizeBeforePuts = verifyLogSegmentValidSize(new TimeRange(timeInMsBeforeExpiringPuts, 0L)); long totalContainerValidSizeBeforePuts = verifyContainerValidSize(); state.addPutEntries(3, CuratedLogIndexState.PUT_RECORD_SIZE, timeInMsBeforeExpiringPuts + 20 * Time.MsPerSec); state.advanceTime(21 * Time.MsPerSec); long timeInMsAfterExpiringPuts = state.time.milliseconds(); long totalLogSegmentValidSizeAfterPuts = verifyLogSegmentValidSize(new TimeRange(timeInMsAfterExpiringPuts, 0L)); long totalContainerValidSizeAfterPuts = verifyContainerValidSize(); assertEquals("Expired put entries are not properly counted for log segment valid size", totalLogSegmentValidSizeBeforePuts, totalLogSegmentValidSizeAfterPuts); assertEquals("Expired put entries are not properly counted for container valid size", totalContainerValidSizeBeforePuts, totalContainerValidSizeAfterPuts); }

Target:
public void testValidDataSizeAfterExpiration() throws InterruptedException, StoreException, IOException { advanceTimeToNextSecond(); long timeInMsBeforePuts = state.time.milliseconds(); long totalLogSegmentValidSizeBeforePuts = verifyAndGetLogSegmentValidSize(new TimeRange(timeInMsBeforePuts, 0L)); long totalContainerValidSizeBeforePuts = verifyAndGetContainerValidSize(); state.addPutEntries(1, CuratedLogIndexState.PUT_RECORD_SIZE, Utils.Infinite_Time); long expiresAtInMs = state.time.milliseconds() + 20 * Time.MsPerSec; state.addPutEntries(3, CuratedLogIndexState.PUT_RECORD_SIZE, expiresAtInMs); state.advanceTime(expiresAtInMs - state.time.milliseconds()); long expectedDeltaAfterPut = 4 * CuratedLogIndexState.PUT_RECORD_SIZE; long timeInMsAfterPuts = state.time.milliseconds(); long totalLogSegmentValidSizeAfterPuts = verifyAndGetLogSegmentValidSize(new TimeRange(timeInMsAfterPuts, 0L)); long totalContainerValidSizeAfterPuts = verifyAndGetContainerValidSize(); assertEquals("Put entries with expiry are not properly counted for log segment valid size", totalLogSegmentValidSizeAfterPuts, totalLogSegmentValidSizeBeforePuts + expectedDeltaAfterPut); assertEquals("Put entries with expiry are not properly counted for container valid size", totalContainerValidSizeAfterPuts, totalContainerValidSizeBeforePuts + expectedDeltaAfterPut); advanceTimeToNextSecond(); long expectedDeltaAfterExpiration = CuratedLogIndexState.PUT_RECORD_SIZE; long timeInMsAfterExpiration = state.time.milliseconds(); long totalLogSegmentValidSizeAfterExpiration = verifyAndGetLogSegmentValidSize(new TimeRange(timeInMsAfterExpiration, 0L)); long totalContainerValidSizeAfterExpiration = verifyAndGetContainerValidSize(); assertEquals("Expired put entries are not properly counted for log segment valid size", totalLogSegmentValidSizeAfterExpiration, totalLogSegmentValidSizeBeforePuts + expectedDeltaAfterExpiration); assertEquals("Expired put entries are not properly counted for container valid size", totalContainerValidSizeAfterExpiration, totalContainerValidSizeBeforePuts + expectedDeltaAfterExpiration); }