@Test
public void testIntegerAssignment() throws YarnException {

  float[] weights =
      new float[] {0, 0.1f, 0.2f, 0.2f, -0.1f, 0.1f, 0.2f, 0.1f, 0.1f};
  int[] expectedMin = new int[] {0, 1, 3, 3, 0, 1, 3, 1, 1};
  ArrayList<Float> weightsList = new ArrayList<>();
  for (float weight : weights) {
    weightsList.add(weight);
  }
  LocalityMulticastAMRMProxyPolicy policy =
      (LocalityMulticastAMRMProxyPolicy) getPolicy();
  for (int i = 0; i < 500000; i++) {
    ArrayList<Integer> allocations =
        policy.computeIntegerAssignment(19, weightsList);
    int sum = 0;
    for (int j = 0; j < weights.length; j++) {
      sum += allocations.get(j);
      if (allocations.get(j) < expectedMin[j]) {
        Assert.fail(allocations.get(j) + " at index " + j
            + " should be at least " + expectedMin[j] + ". Allocation array: "
            + printList(allocations));
      }
    }
    Assert.assertEquals(
        "Expect sum to be 19 in array: " + printList(allocations), 19, sum);
  }
}