Source:
public void testValidDataSizeAfterDeletes() throws InterruptedException, StoreException, IOException { state.addPutEntries(5, CuratedLogIndexState.PUT_RECORD_SIZE, Utils.Infinite_Time); state.advanceTime(Time.MsPerSec); long timeInMsBeforeDeletes = state.time.milliseconds(); long totalLogSegmentValidSizeBeforeDeletes = verifyLogSegmentValidSize(new TimeRange(timeInMsBeforeDeletes, 0L)); long totalContainerValidSizeBeforeDeletes = verifyContainerValidSize(); state.addDeleteEntry(state.getIdToDeleteFromIndexSegment(state.referenceIndex.lastKey())); state.addDeleteEntry(state.getIdToDeleteFromIndexSegment(state.referenceIndex.lastKey())); state.advanceTime(Time.MsPerSec); long timeInMsAfterDeletes = state.time.milliseconds(); long totalLogSegmentValidSizeAfterDeletes = verifyLogSegmentValidSize(new TimeRange(timeInMsAfterDeletes, 0L)); long totalContainerValidSizeAfterDeletes = verifyContainerValidSize(); long expectedLogSegmentDecrement = 2 * (CuratedLogIndexState.PUT_RECORD_SIZE - CuratedLogIndexState.DELETE_RECORD_SIZE); long expectedContainerDecrement = 2 * CuratedLogIndexState.PUT_RECORD_SIZE; assertEquals("Delete entries are not properly counted for log segment valid size", totalLogSegmentValidSizeAfterDeletes, totalLogSegmentValidSizeBeforeDeletes - expectedLogSegmentDecrement); assertEquals("Delete entries are not properly counted for container valid size", totalContainerValidSizeAfterDeletes, totalContainerValidSizeBeforeDeletes - expectedContainerDecrement); }

Target:
public void testValidDataSizeAfterDeletes() throws InterruptedException, StoreException, IOException { state.addPutEntries(5, CuratedLogIndexState.PUT_RECORD_SIZE, Utils.Infinite_Time); TimeRange timeBeforeDeletes = new TimeRange(state.time.milliseconds(), 0L); long totalLogSegmentValidSizeBeforeDeletes = verifyAndGetLogSegmentValidSize(timeBeforeDeletes); long totalContainerValidSizeBeforeDeletes = verifyAndGetContainerValidSize(); advanceTimeToNextSecond(); state.addDeleteEntry(state.getIdToDeleteFromIndexSegment(state.referenceIndex.lastKey())); state.addDeleteEntry(state.getIdToDeleteFromIndexSegment(state.referenceIndex.lastKey())); long expectedDeltaBeforeDeletesRelevant = 2 * CuratedLogIndexState.DELETE_RECORD_SIZE; long totalLogSegmentValidSizeBeforeDeletesRelevant = verifyAndGetLogSegmentValidSize(timeBeforeDeletes); long totalContainerValidSizeBeforeDeletesRelevant = verifyAndGetContainerValidSize(); assertEquals("Delete entries are not properly counted for log segment valid size", totalLogSegmentValidSizeBeforeDeletesRelevant, totalLogSegmentValidSizeBeforeDeletes + expectedDeltaBeforeDeletesRelevant); assertEquals("Delete entries are not properly counted for container valid size", totalContainerValidSizeBeforeDeletesRelevant, totalContainerValidSizeBeforeDeletes); advanceTimeToNextSecond(); long timeInMsAfterDeletes = state.time.milliseconds(); long totalLogSegmentValidSizeAfterDeletes = verifyAndGetLogSegmentValidSize(new TimeRange(timeInMsAfterDeletes, 0L)); long totalContainerValidSizeAfterDeletes = verifyAndGetContainerValidSize(); long expectedLogSegmentDecrement = 2 * (CuratedLogIndexState.PUT_RECORD_SIZE - CuratedLogIndexState.DELETE_RECORD_SIZE); long expectedContainerDecrement = 2 * CuratedLogIndexState.PUT_RECORD_SIZE; assertEquals("Delete entries are not properly counted for log segment valid size", totalLogSegmentValidSizeAfterDeletes, totalLogSegmentValidSizeBeforeDeletes - expectedLogSegmentDecrement); assertEquals("Delete entries are not properly counted for container valid size", totalContainerValidSizeAfterDeletes, totalContainerValidSizeBeforeDeletes - expectedContainerDecrement); }