diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java index 692924c01d6..2688987ed50 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java @@ -69,18 +69,17 @@ public class TestSignalContainer { //kick the scheduler nm1.nodeHeartbeat(true); - List conts = null; - int contReceived = 0; + List conts = new ArrayList<>(request); int waitCount = 0; - while (contReceived < request && waitCount++ < 200) { - LOG.info("Got " + contReceived + " containers. Waiting to get " + while (conts.size() < request && waitCount++ < 200) { + LOG.info("Got " + conts.size() + " containers. Waiting to get " + request); Thread.sleep(100); - conts = am.allocate(new ArrayList(), + List allocation = am.allocate(new ArrayList(), new ArrayList()).getAllocatedContainers(); - contReceived += conts.size(); + conts.addAll(allocation); } - Assert.assertEquals(request, contReceived); + Assert.assertEquals(request, conts.size()); for(Container container : conts) { rm.signalToContainer(container.getId(),