@Test
public void testAllocationWithNodeLabels() throws Exception {

  ResourceBlacklistRequest blacklistRequest =
      ResourceBlacklistRequest.newInstance(
          new ArrayList<>(), new ArrayList<>());
  List<ResourceRequest> reqs =
      Arrays.asList(ResourceRequest.newInstance(PRIORITY_NORMAL,
          "*", CAPABILITY_1GB, 1, true, "label", OPPORTUNISTIC_REQ));
  ApplicationAttemptId appAttId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(0L, 1), 1);
  oppCntxt.updateNodeList(
      Arrays.asList(
          RemoteNode.newInstance(
              NodeId.newInstance("h1", 1234), "h1:1234", "/r1")));
  List<Container> containers = allocator.allocateContainers(
      blacklistRequest, reqs, appAttId, oppCntxt, 1L, "luser");
  /* Since there is no node satisfying node label constraints, requests
     won't get fulfilled.
  */
  Assert.assertEquals(0, containers.size());
  Assert.assertEquals(1, oppCntxt.getOutstandingOpReqs().size());
  oppCntxt.updateNodeList(
      Arrays.asList(
          RemoteNode.newInstance(
              NodeId.newInstance("h1", 1234), "h1:1234", "/r1",
              "label")));
  containers = allocator.allocateContainers(
      blacklistRequest, reqs, appAttId, oppCntxt, 1L, "luser");
  Assert.assertEquals(1, containers.size());
  Assert.assertEquals(0, oppCntxt.getOutstandingOpReqs().size());
}