@Test
  public void storeRemoveDirectoryAndRestartTestWithStaleBlobStore() throws Exception {
    // Make sure that we use segmented log files
    generateConfigs(true, false);
    Field field = StoreConfig.class.getDeclaredField("storeBlockStaleBlobStoreToStart");
    field.setAccessible(true);
    field.set(storeConfig, true);

    MockDataNodeId dataNode = clusterMap.getDataNodes().get(0);
    ReplicaId replica = clusterMap.getReplicaIds(dataNode).get(0);
    // Just start the storage manager and this will make sure all the replicas' directories are created
    // and the first log segment file is also created for each replica.
    StorageManager storageManager = createStorageManager(dataNode, metricRegistry, null);
    storageManager.start();
    assertNotNull(storageManager.getStore(replica.getPartitionId(), false));

    // Now shutdown the storage manager and change all files' last modified timestamp to be older than the
    // stale threshold.
    storageManager.shutdown();
    changeAllFileMTimesForReplica(replica,
        System.currentTimeMillis() - TimeUnit.DAYS.toMillis(storeConfig.storeStaleTimeInDays) * 2);

    // Now restart the storage manager
    storageManager = createStorageManager(dataNode, metricRegistry, null);
    storageManager.start();
    assertEquals(1,
        getCounterValue(metricRegistry.getCounters(), DiskManager.class.getName(), "TotalStoreStartFailures"));
    assertNull(storageManager.getStore(replica.getPartitionId(), false));

    storageManager.shutdown();

    // Now enable the feature to remove directory and restart blob store
    generateConfigs(true, false, false, 2, true, false);
    storageManager = createStorageManager(dataNode, metricRegistry, null);
    storageManager.start();
    assertNotNull(storageManager.getStore(replica.getPartitionId(), false));
    storageManager.shutdown();
  }
Test the case where the blob store can't get started and we need to remove the directory and then restart the blobstore.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java