@Test
  public void updateDiskSpaceOnReplicaRemovalTest() throws Exception {
    generateConfigs(true, false);
    MockDataNodeId localNode = clusterMap.getDataNodes().get(0);
    List<ReplicaId> localReplicas = clusterMap.getReplicaIds(localNode);
    ReplicaId oldReplica = localReplicas.get(0);
    MockClusterParticipant mockHelixParticipant = Mockito.spy(new MockClusterParticipant());
    doNothing().when(mockHelixParticipant).setPartitionDisabledState(anyString(), anyBoolean());
    StorageManager storageManager =
        createStorageManager(localNode, metricRegistry, Collections.singletonList(mockHelixParticipant));
    storageManager.start();
    // Get disk space before dropping the replica
    MockDiskId diskId = (MockDiskId) oldReplica.getDiskId();
    long originalSpace = diskId.getAvailableSpaceInBytes();
    storageManager.controlCompactionForBlobStore(oldReplica.getPartitionId(), false);
    storageManager.shutdownBlobStore(oldReplica.getPartitionId());
    mockHelixParticipant.onPartitionBecomeDroppedFromOffline(oldReplica.getPartitionId().toPathString());
    // Verify disk space is increased on removing replica
    assertEquals("Disk free space should be increased after removing replica",
        originalSpace + oldReplica.getCapacityInBytes(), oldReplica.getDiskId().getAvailableSpaceInBytes());
    shutdownAndAssertStoresInaccessible(storageManager, localReplicas);
  }
Test disk free space is increased after replica is removed.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java