@Test(timeout = 3000000)
public void testRMIdentifierOnContainerAllocation() throws Exception {

  MockRM rm = new MockRM(conf);
  rm.start();
  // Register node1
  MockNM nm1 = rm.registerNode("127.0.0.1:1234", 6 * GB);
  // Submit an application
  RMApp app1 = rm.submitApp(2048);
  // kick the scheduling
  nm1.nodeHeartbeat(true);
  RMAppAttempt attempt1 = app1.getCurrentAppAttempt();
  MockAM am1 = rm.sendAMLaunched(attempt1.getAppAttemptId());
  am1.registerAppAttempt();
  am1.addRequests(new String[] { "127.0.0.1" }, GB, 1, 1);
  AllocateResponse alloc1Response = am1.schedule(); // send the request
  // kick the scheduler
  nm1.nodeHeartbeat(true);
  while (alloc1Response.getAllocatedContainers().size() < 1) {
    LOG.info("Waiting for containers to be created for app 1...");
    sleep(1000);
    alloc1Response = am1.schedule();
  }
  // assert RMIdentifer is set properly in allocated containers
  Container allocatedContainer =
      alloc1Response.getAllocatedContainers().get(0);
  ContainerTokenIdentifier tokenId =
      BuilderUtils.newContainerTokenIdentifier(allocatedContainer
        .getContainerToken());
  Assert.assertEquals(MockRM.getClusterTimeStamp(), tokenId.getRMIdentifer());
  rm.stop();
}