@Test
  public void getNewReplicaInFullAutoBasicTest() throws Exception {
    assumeTrue(!useComposite && fullAutoCompatible);
    metricRegistry = new MetricRegistry();

    // Set the resource and all data nodes in local dc to FULL_AUTO
    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
    Properties props = getProperties(overrideEnabled, listenCrossColo, useAggregatedView);
    long defaultReplicaCapacity = 50L * 1024 * 1024 * 1024;
    props.setProperty("clustermap.default.replica.capacity.in.bytes", String.valueOf(defaultReplicaCapacity));
    MockHelixManagerFactory helixFactory = new MockHelixManagerFactory(helixCluster, null, null, useAggregatedView);
    ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props));
    HelixClusterManager helixClusterManager =
        new HelixClusterManager(clusterMapConfig, selfInstanceName, helixFactory, metricRegistry);

    // Case 1. We are creating a bootstrap replica for an exiting partition
    PartitionId partitionOfNewReplica = helixClusterManager.getAllPartitionIds(null).get(0);
    long expectedCapacity = partitionOfNewReplica.getReplicaIds().get(0).getCapacityInBytes();
    AmbryDataNode ambryDataNode = helixClusterManager.getDataNodeId(currentNode.getHostname(), currentNode.getPort());
    ReplicaId bootstrapReplica =
        helixClusterManager.getBootstrapReplica(partitionOfNewReplica.toPathString(), ambryDataNode);
    assertNotNull("New replica should be created successfully", bootstrapReplica);
    assertEquals("Bootstrap replica of existing partition should has peers' capacity", expectedCapacity,
        bootstrapReplica.getCapacityInBytes());
    assertEquals("There should be exactly one entry in bootstrap replica map", 1,
        helixClusterManager.getBootstrapReplicaMap().size());

    // Case 2. We are creating a bootstrap replica for a new partition
    String newPartitionId = String.valueOf(idealState.getNumPartitions() + 1001);
    bootstrapReplica = helixClusterManager.getBootstrapReplica(newPartitionId, ambryDataNode);
    assertNotNull(bootstrapReplica);
    assertEquals(defaultReplicaCapacity, bootstrapReplica.getCapacityInBytes());
    assertEquals("There should be 2 entries in bootstrap replica map", 2,
        helixClusterManager.getBootstrapReplicaMap().size());

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