@Test
public void testAbsoluteResourceWithChangeInClusterResource()
    throws Exception {

  // Setup queue configs
  setupSingleLevelQueuesWithAbsoluteResource(csConf);
  CSQueueStore queues = new CSQueueStore();
  CSQueue root = CapacitySchedulerQueueManager.parseQueue(csContext, csConf,
      null, CapacitySchedulerConfiguration.ROOT, queues, queues,
      TestUtils.spyHook);
  // Setup some nodes
  final int memoryPerNode = 10;
  int coresPerNode = 16;
  int numNodes = 2;
  Resource clusterResource = Resources.createResource(
      numNodes * (memoryPerNode * GB), numNodes * coresPerNode);
  when(csContext.getNumClusterNodes()).thenReturn(numNodes);
  root.updateClusterResource(clusterResource,
      new ResourceLimits(clusterResource));
  // Start testing
  LeafQueue a = (LeafQueue) queues.get(A);
  LeafQueue b = (LeafQueue) queues.get(B);
  assertEquals(a.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_A_RESOURCE);
  assertEquals(b.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_B_RESOURCE);
  assertEquals(a.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_A_RESOURCE);
  assertEquals(b.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_B_RESOURCE);
  numNodes = 1;
  clusterResource = Resources.createResource(numNodes * (memoryPerNode * GB),
      numNodes * coresPerNode);
  when(csContext.getNumClusterNodes()).thenReturn(numNodes);
  root.updateClusterResource(clusterResource,
      new ResourceLimits(clusterResource));
  Resource QUEUE_B_RESOURCE_HALF = Resource.newInstance(7 * 1024, 11);
  Resource QUEUE_A_RESOURCE_HALF = Resource.newInstance(3 * 1024, 5);
  assertEquals(a.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_A_RESOURCE);
  assertEquals(b.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_B_RESOURCE);
  assertEquals(a.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_A_RESOURCE_HALF);
  assertEquals(b.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_B_RESOURCE_HALF);
  coresPerNode = 40;
  clusterResource = Resources.createResource(numNodes * (memoryPerNode * GB),
      numNodes * coresPerNode);
  when(csContext.getNumClusterNodes()).thenReturn(numNodes);
  root.updateClusterResource(clusterResource,
      new ResourceLimits(clusterResource));
  Resource QUEUE_B_RESOURCE_70PERC = Resource.newInstance(7 * 1024, 27);
  Resource QUEUE_A_RESOURCE_30PERC = Resource.newInstance(3 * 1024, 12);
  assertEquals(a.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_A_RESOURCE);
  assertEquals(b.getQueueResourceQuotas().getConfiguredMinResource(),
      QUEUE_B_RESOURCE);
  assertEquals(a.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_A_RESOURCE_30PERC);
  assertEquals(b.getQueueResourceQuotas().getEffectiveMinResource(),
      QUEUE_B_RESOURCE_70PERC);
}