@Test
public void testAllocationIncrementCustomResource() {

  try {
    initResourceTypes();
    Configuration conf = new Configuration();
    conf.set(YarnConfiguration.RESOURCE_TYPES + ".a-custom-resource" +
        FairSchedulerConfiguration.INCREMENT_ALLOCATION, "10");
    FairSchedulerConfiguration fsc = new FairSchedulerConfiguration(conf);
    Resource increment = fsc.getIncrementAllocation();
    DominantResourceCalculator calculator =
        new DominantResourceCalculator();
    Resource min = Resources.createResource(0L, 0);
    Resource max = Resource.newInstance(Long.MAX_VALUE,
        Integer.MAX_VALUE, Collections.singletonMap(A_CUSTOM_RESOURCE,
            Long.MAX_VALUE / UnitsConversionUtil.convert("k", "", 1L)));
    assertEquals(customResourceInformation(10000L, ""),
        calculator.normalize(customResource(9999L, ""), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
    assertEquals(customResourceInformation(10000L, ""),
        calculator.normalize(customResource(10000L, ""), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
    assertEquals(customResourceInformation(20000L, ""),
        calculator.normalize(customResource(19999L, ""), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
    assertEquals(customResourceInformation(10L, "k"),
        calculator.normalize(customResource(9L, "k"), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
    assertEquals(customResourceInformation(10L, "k"),
        calculator.normalize(customResource(10L, "k"), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
    assertEquals(customResourceInformation(20L, "k"),
        calculator.normalize(customResource(11L, "k"), min, max, increment)
          .getResourceInformation(A_CUSTOM_RESOURCE));
  } finally {
    ResourceUtils.resetResourceTypes(new Configuration());
  }
}