@Test
public void testResendRequestsOnRMRestart()
    throws YarnException, IOException {

  ContainerId c1 = createContainerId(1);
  ContainerId c2 = createContainerId(2);
  ContainerId c3 = createContainerId(3);
  // Ask for two containers, one with location preference
  this.asks.add(createResourceRequest(0, "node1", 2048, 1, 1,
      ExecutionType.GUARANTEED, 1));
  this.asks.add(createResourceRequest(0, "rack", 2048, 1, 1,
      ExecutionType.GUARANTEED, 1));
  this.asks.add(createResourceRequest(0, ResourceRequest.ANY, 2048, 1, 1,
      ExecutionType.GUARANTEED, 2));
  this.releases.add(c1);
  this.blacklistAdditions.add("node1");
  this.blacklistRemoval.add("node0");
  // 1. a fully loaded request
  this.relayer.allocate(getAllocateRequest());
  assertAsksAndReleases(3, 1);
  assertBlacklistAdditionsAndRemovals(1, 1);
  clearAllocateRequestLists();
  // 2. empty request
  this.relayer.allocate(getAllocateRequest());
  assertAsksAndReleases(0, 0);
  assertBlacklistAdditionsAndRemovals(0, 0);
  clearAllocateRequestLists();
  // Set RM restart and failover flag
  this.mockAMS.setFailoverFlag();
  // More requests
  this.blacklistAdditions.add("node2");
  this.releases.add(c2);
  this.relayer.allocate(getAllocateRequest());
  // verify pending requests are fully re-sent
  assertAsksAndReleases(3, 2);
  assertBlacklistAdditionsAndRemovals(2, 0);
  clearAllocateRequestLists();
}