@Test
public void testSplitBasedOnHeadroomAndWeights() throws Exception {

  // Tests how the headroom info are used to split based on the capacity
  // each RM claims to give us.
  // Configure policy to be 50% headroom based and 50% weight based
  getPolicyInfo().setHeadroomAlpha(0.5f);
  initializePolicy();
  List<ResourceRequest> resourceRequests = createSimpleRequest();
  prepPolicyWithHeadroom(true);
  Map<SubClusterId, List<ResourceRequest>> response =
      ((FederationAMRMProxyPolicy) getPolicy()).splitResourceRequests(
          resourceRequests, new HashSet<SubClusterId>());
  // pretty print requests
  prettyPrintRequests(response);
  validateSplit(response, resourceRequests);
  // in this case the headroom allocates 50 containers, while weights allocate
  // the rest. due to weights we have 12.5 containers for each
  // sublcuster, the rest is due to headroom.
  checkExpectedAllocation(response, "subcluster0", 1, 42);  // 30 + 12.5
  checkExpectedAllocation(response, "subcluster1", 1, 12);  // 0 + 12.5
  checkExpectedAllocation(response, "subcluster2", 1, 20);  // 7.5 + 12.5
  checkExpectedAllocation(response, "subcluster3", -1, -1);
  checkExpectedAllocation(response, "subcluster4", -1, -1);
  checkExpectedAllocation(response, "subcluster5", 1, 25);  // 12.5 + 12.5
  checkTotalContainerAllocation(response, 100);
}