@Test(timeout = 5000)
  public void testBucketingWaitTimeout() throws InterruptedException, StoreException {
    assumeTrue(bucketingEnabled);
    CountDownLatch scanStartedLatch = new CountDownLatch(1);
    CountDownLatch scanHoldLatch = new CountDownLatch(1);
    MockThrottler mockThrottler = new MockThrottler(scanStartedLatch, scanHoldLatch);
    throttlers.put(BlobStoreStats.IO_SCHEDULER_JOB_TYPE, mockThrottler);
    int expectedMinimumThrottleCount = 2 * state.referenceIndex.size();
    BlobStoreStats blobStoreStats =
        new BlobStoreStats("", state.index, 10, BUCKET_SPAN_IN_MS, 0, QUEUE_PROCESSOR_PERIOD_IN_Ms, 1, true, true,
            state.time, indexScannerScheduler, queueProcessorScheduler, diskIOScheduler, METRICS, 1, false);
    // proceed only when the scan is started
    assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS));
    advanceTimeToNextSecond();
    verifyContainerStorageStatsAndGetTotalValidSize(blobStoreStats, state.time.milliseconds());
    verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(state.time.milliseconds(), 0));
    scanHoldLatch.countDown();
    assertTrue("Throttle count is lower than the expected minimum throttle count",
        mockThrottler.throttleCount.get() >= expectedMinimumThrottleCount);
    blobStoreStats.close();
  }
Test to verify that separate scan is triggered to answer the request after waiting for scan timed out.
@throws InterruptedException
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/BlobStoreStatsTest.java