Source:
<code>public void testBucketingCoverageTransition() throws InterruptedException, StoreException, IOException { assumeTrue(bucketingEnabled); CountDownLatch scanStartedLatch = new CountDownLatch(1); MockThrottler mockThrottler = new MockThrottler(scanStartedLatch, new CountDownLatch(0)); throttlers.put(BlobStoreStats.IO_SCHEDULER_JOB_TYPE, mockThrottler); long initialScanTimeInMs = state.time.milliseconds(); BlobStoreStats blobStoreStats = setupBlobStoreStats(2, 0); assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); state.advanceTime(TimeUnit.SECONDS.toMillis(20)); CountDownLatch scanHoldLatch = new CountDownLatch(1); scanStartedLatch = new CountDownLatch(1); mockThrottler.holdLatch = scanHoldLatch; mockThrottler.startedLatch = scanStartedLatch; mockThrottler.isThrottlerStarted = false; assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); <START> int throttleCountBeforeRequests = mockThrottler.throttleCount.get(); <END> verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); assertEquals("Throttle count shouldn't have changed", throttleCountBeforeRequests, mockThrottler.throttleCount.get()); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(0L, 0L)); verifyAndGetContainerValidSize(blobStoreStats, 0L); scanHoldLatch.countDown(); blobStoreStats.close(); }</code><technical_language>Guess is a slim chance queueProcessor counted latch, guaranteed blob is accounted in scan results. I right</technical_language>

Target:
public void testBucketingCoverageTransition() throws InterruptedException, StoreException, IOException { assumeTrue(bucketingEnabled); CountDownLatch scanStartedLatch = new CountDownLatch(1); MockThrottler mockThrottler = new MockThrottler(scanStartedLatch, new CountDownLatch(0), 50, 100); throttlers.put(BlobStoreStats.IO_SCHEDULER_JOB_TYPE, mockThrottler); long expiresAtInMs = state.time.milliseconds() + TimeUnit.SECONDS.toMillis(20); state.addPutEntries(1, CuratedLogIndexState.PUT_RECORD_SIZE, expiresAtInMs); long initialScanTimeInMs = state.time.milliseconds(); BlobStoreStats blobStoreStats = setupBlobStoreStats(1, 0); int expectedThrottleCount = state.referenceIndex.size(); assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); state.advanceTime(expiresAtInMs - state.time.milliseconds()); CountDownLatch scanHoldLatch = new CountDownLatch(1); scanStartedLatch = new CountDownLatch(1); mockThrottler.holdLatch = scanHoldLatch; mockThrottler.startedLatch = scanStartedLatch; mockThrottler.isThrottlerStarted = false; assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); assertEquals("Throttle count mismatch from expected value", expectedThrottleCount + 1, mockThrottler.throttleCount.get()); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(0L, 0L)); verifyAndGetContainerValidSize(blobStoreStats, 0L); scanHoldLatch.countDown(); verifyAndGetContainerValidSize(blobStoreStats, state.time.milliseconds()); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(state.time.milliseconds(), 0L)); expectedThrottleCount = (2 + 3) * expectedThrottleCount; assertEquals("Throttle count mismatch from expected value", expectedThrottleCount, mockThrottler.throttleCount.get()); blobStoreStats.close(); }