@Test
  public void unrecognizedDirsOnDiskTest() throws Exception {
    MockDataNodeId dataNode = clusterMap.getDataNodes().get(0);
    List<ReplicaId> replicas = clusterMap.getReplicaIds(dataNode);
    Set<String> createdMountPaths = new HashSet<>();
    Set<File> extraDirs = new HashSet<>();
    for (ReplicaId replicaId : replicas) {
      if (createdMountPaths.add(replicaId.getMountPath())) {
        int count = TestUtils.RANDOM.nextInt(6) + 5;
        Pair<List<File>, List<File>> filesAndDirectories =
            createFilesAndDirsAtPath(new File(replicaId.getDiskId().getMountPath()), count - 1, count);
        //  the extra files should not get reported
        extraDirs.addAll(filesAndDirectories.getSecond());
      }
    }
    StorageManager storageManager = createStorageManager(dataNode, metricRegistry, null);
    storageManager.start();
    assertEquals("There should be some unexpected partitions reported", extraDirs.size(),
        getNumUnrecognizedPartitionsReported());
    checkStoreAccessibility(replicas, null, storageManager);
    for (File extraDir : extraDirs) {
      Assert.assertTrue("Directory" + extraDir.getAbsolutePath() + " shouldn't be deleted", extraDir.exists());
    }
    shutdownAndAssertStoresInaccessible(storageManager, replicas);
  }
Tests that unrecognized directories are reported correctly
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java