private static void checkRackUsage(List<PartitionId> allocatedPartitions) {
    for (PartitionId partition : allocatedPartitions) {
      Map<String, Set<String>> rackSetByDatacenter = new HashMap<>();
      for (ReplicaId replica : partition.getReplicaIds()) {
        String datacenter = replica.getDataNodeId().getDatacenterName();
        Set<String> rackSet = rackSetByDatacenter.computeIfAbsent(datacenter, k -> new HashSet<>());

        String rackId = replica.getDataNodeId().getRackId();
        if (rackId != null) {
          assertFalse("Allocation was not on unique racks", rackSet.contains(rackId));
          rackSet.add(rackId);
        }
      }
    }
  }
Verify that the partitions in the list are on unique racks for each datacenter.

@param allocatedPartitions the list of partitions to check
ambry-clustermap/src/test/java/com/github/ambry/clustermap/StaticClusterManagerTest.java