@Test
  public void getNewReplicaInFullAutoDiskUsageTest() throws Exception {
    assumeTrue(!useComposite && fullAutoCompatible);
    metricRegistry = new MetricRegistry();
    // Set the node to FullAuto
    List<String> resourceNames = helixCluster.getResources(localDc);
    String resourceName = resourceNames.get(0);
    String tag = "TAG_100000";
    IdealState idealState = helixCluster.getResourceIdealState(resourceName, localDc);
    idealState.setRebalanceMode(IdealState.RebalanceMode.FULL_AUTO);
    idealState.setInstanceGroupTag(tag);
    helixCluster.refreshIdealState();
    for (DataNode dataNode : testHardwareLayout.getAllDataNodesFromDc(localDc)) {
      String instanceName = ClusterMapUtils.getInstanceName(dataNode.getHostname(), dataNode.getPort());
      InstanceConfig instanceConfig =
          helixCluster.getHelixAdminFromDc(localDc).getInstanceConfig(helixCluster.getClusterName(), instanceName);
      instanceConfig.addTag(tag);
    }

    // Create Helix cluster manager
    HelixClusterManager helixClusterManager = new HelixClusterManager(clusterMapConfig, selfInstanceName,
        new MockHelixManagerFactory(helixCluster, null, null, useAggregatedView), metricRegistry);
    // Select a partition for getting the bootstrap replica
    PartitionId partition = helixClusterManager.getAllPartitionIds(null).get(0);
    // Get list of disks present on the node
    HelixClusterManager.HelixClusterManagerQueryHelper clusterManagerCallback =
        helixClusterManager.getManagerQueryHelper();
    AmbryDataNode ambryDataNode = helixClusterManager.getDataNodeId(currentNode.getHostname(), currentNode.getPort());
    List<AmbryDisk> disks = new ArrayList<>(clusterManagerCallback.getDisks(ambryDataNode));
    // Get replica capacity of new replica
    long replicaCapacity = partition.getReplicaIds().get(0).getCapacityInBytes();

    // 1. Verify all disks are used in round-robin fashion
    for (AmbryDisk disk : disks) {
      // Set each disk capacity equal to twice the replica capacity
      disk.setDiskAvailableSpace(2 * replicaCapacity);
    }
    Set<AmbryDisk> potentialDisks = new HashSet<>(disks);
    for (int i = 0; i < disks.size(); i++) {
      ReplicaId bootstrapReplica = helixClusterManager.getBootstrapReplica(partition.toPathString(), ambryDataNode);
      assertTrue("Correct disk is not used", potentialDisks.contains((AmbryDisk) bootstrapReplica.getDiskId()));
      potentialDisks.remove((AmbryDisk) bootstrapReplica.getDiskId());
    }

    // 2. Verify bootstrapping fails when disk space is empty
    for (AmbryDisk disk : disks) {
      disk.setDiskAvailableSpace(replicaCapacity - 100);
    }
    assertNull("Bootstrapping replica should be fail since no disk space is available",
        helixClusterManager.getBootstrapReplica(partition.toPathString(), ambryDataNode));

    // 3. Verify disk with the most space is used
    AmbryDisk expectedDisk = null;
    for (int i = 0; i < disks.size(); i++) {
      AmbryDisk disk = disks.get(i);
      if (i == 0) {
        expectedDisk = disk;
        disk.setDiskAvailableSpace(2 * replicaCapacity);
      } else {
        disk.setDiskAvailableSpace(replicaCapacity);
      }
    }
    helixClusterManager.clearBootstrapDiskSelectionMap();
    ReplicaId bootstrapReplica = helixClusterManager.getBootstrapReplica(partition.toPathString(), ambryDataNode);
    assertEquals("Mismatch in disk used", expectedDisk, bootstrapReplica.getDiskId());

    helixClusterManager.close();
  }
Test correct disk is used while getting new replica in full auto.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/HelixClusterManagerTest.java