@Test
  public void updateDiskSpaceOnReplicaAdditionTest() throws InterruptedException, StoreException {
    generateConfigs(true, false);
    MockDataNodeId localNode = clusterMap.getDataNodes().get(0);
    List<ReplicaId> localReplicas = clusterMap.getReplicaIds(localNode);
    MockClusterParticipant mockHelixParticipant = new MockClusterParticipant();
    StorageManager storageManager =
        createStorageManager(localNode, metricRegistry, Collections.singletonList(mockHelixParticipant));
    storageManager.start();
    PartitionId newPartition = clusterMap.createNewPartition(Collections.singletonList(localNode));
    // Get the replica that has been created for this new partition
    ReplicaId newReplica = newPartition.getReplicaIds()
        .stream()
        .filter(replicaId -> replicaId.getDataNodeId().equals(localNode))
        .findFirst()
        .get();
    // 1. Get disk space before adding the replica
    long diskSpaceBefore = newReplica.getDiskId().getAvailableSpaceInBytes();
    // 2. Induce state transition to add a replica
    mockHelixParticipant.onPartitionBecomeBootstrapFromOffline(newPartition.toPathString());
    // 3. Verify disk space is reduced after adding the replica
    assertEquals("Disk space should be reduced after replica addition",
        diskSpaceBefore - newReplica.getCapacityInBytes(), newReplica.getDiskId().getAvailableSpaceInBytes());
    shutdownAndAssertStoresInaccessible(storageManager, localReplicas);
  }
Test disk free space is decreased after replica is added.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java