@Test(timeout = 120000)
public void testPreemptionInfo() throws Exception {

  Configuration conf = new Configuration();
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 3);
  conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
      ResourceScheduler.class);
  int CONTAINER_MEMORY = 1024; // start RM
  MockRM rm1 = new MockRM(conf);
  rm1.start();
  // get scheduler
  CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();
  // start NM
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();
  // create app and launch the AM
  RMApp app0 = rm1.submitApp(CONTAINER_MEMORY);
  MockAM am0 = launchAM(app0, rm1, nm1);
  // get scheduler app
  FiCaSchedulerApp schedulerAppAttempt =
      cs.getSchedulerApplications().get(app0.getApplicationId())
          .getCurrentAppAttempt();
  // allocate some containers and launch them
  List<Container> allocatedContainers =
      am0.allocateAndWaitForContainers(3, CONTAINER_MEMORY, nm1);
  // kill the 3 containers
  for (Container c : allocatedContainers) {
    cs.killContainer(schedulerAppAttempt.getRMContainer(c.getId()));
  }
  // check values
  waitForAppPreemptionInfo(app0,
      Resource.newInstance(CONTAINER_MEMORY * 3, 3), 0, 3,
      Resource.newInstance(CONTAINER_MEMORY * 3, 3), false, 3);
  // kill app0-attempt0 AM container
  cs.killContainer(schedulerAppAttempt.getRMContainer(app0
      .getCurrentAppAttempt().getMasterContainer().getId()));
  // wait for app0 failed
  waitForNewAttemptCreated(app0, am0.getApplicationAttemptId());
  // check values
  waitForAppPreemptionInfo(app0,
      Resource.newInstance(CONTAINER_MEMORY * 4, 4), 1, 3,
      Resource.newInstance(0, 0), false, 0);
  // launch app0-attempt1
  MockAM am1 = launchAM(app0, rm1, nm1);
  schedulerAppAttempt =
      cs.getSchedulerApplications().get(app0.getApplicationId())
          .getCurrentAppAttempt();
  // allocate some containers and launch them
  allocatedContainers =
      am1.allocateAndWaitForContainers(3, CONTAINER_MEMORY, nm1);
  for (Container c : allocatedContainers) {
    cs.killContainer(schedulerAppAttempt.getRMContainer(c.getId()));
  }
  // check values
  waitForAppPreemptionInfo(app0,
      Resource.newInstance(CONTAINER_MEMORY * 7, 7), 1, 6,
      Resource.newInstance(CONTAINER_MEMORY * 3, 3), false, 3);
  rm1.stop();
}