@Test
public void testRoundRobinRackLocalAllocationSameSchedKey() throws Exception {

  ResourceBlacklistRequest blacklistRequest =
      ResourceBlacklistRequest.newInstance(
          new ArrayList<>(), new ArrayList<>());
  List<ResourceRequest> reqs =
      Arrays.asList(
          ResourceRequest.newInstance(PRIORITY_NORMAL, "*",
              CAPABILITY_1GB, 2, true, null, OPPORTUNISTIC_REQ),
          ResourceRequest.newInstance(PRIORITY_NORMAL, "h1",
              CAPABILITY_1GB, 2, true, null, OPPORTUNISTIC_REQ),
          ResourceRequest.newInstance(PRIORITY_NORMAL, "/r1",
              CAPABILITY_1GB, 2, true, null, OPPORTUNISTIC_REQ));
  ApplicationAttemptId appAttId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(0L, 1), 1);
  oppCntxt.updateNodeList(
      Arrays.asList(
          RemoteNode.newInstance(
              NodeId.newInstance("h3", 1234), "h3:1234", "/r2"),
          RemoteNode.newInstance(
              NodeId.newInstance("h2", 1234), "h2:1234", "/r1"),
          RemoteNode.newInstance(
              NodeId.newInstance("h5", 1234), "h5:1234", "/r1"),
          RemoteNode.newInstance(
              NodeId.newInstance("h4", 1234), "h4:1234", "/r2")));
  List<Container> containers = allocator.allocateContainers(
      blacklistRequest, reqs, appAttId, oppCntxt, 1L, "luser");
  Set<String> allocatedHosts = new HashSet<>();
  for (Container c : containers) {
    allocatedHosts.add(c.getNodeHttpAddress());
  }
  LOG.info("Containers: {}", containers);
  Assert.assertTrue(allocatedHosts.contains("h2:1234"));
  Assert.assertTrue(allocatedHosts.contains("h5:1234"));
  Assert.assertFalse(allocatedHosts.contains("h3:1234"));
  Assert.assertFalse(allocatedHosts.contains("h4:1234"));
  Assert.assertEquals(2, containers.size());
}