YARN-5377. Fix TestQueuingContainerManager.testKillMultipleOpportunisticContainers. (Konstantinos Karanasos via asuresh)

This commit is contained in:
Arun Suresh 2016-11-07 22:10:03 -08:00
parent 3fff158587
commit f38a6d03a1
2 changed files with 29 additions and 15 deletions

View File

@ -284,15 +284,17 @@ public abstract class BaseContainerManagerTest {
.build()); .build());
} }
public static void waitForContainerState(ContainerManagementProtocol containerManager, public static void waitForContainerState(
ContainerId containerID, ContainerState finalState) ContainerManagementProtocol containerManager, ContainerId containerID,
ContainerState finalState)
throws InterruptedException, YarnException, IOException { throws InterruptedException, YarnException, IOException {
waitForContainerState(containerManager, containerID, finalState, 20); waitForContainerState(containerManager, containerID, finalState, 20);
} }
public static void waitForContainerState(ContainerManagementProtocol containerManager, public static void waitForContainerState(
ContainerId containerID, ContainerState finalState, int timeOutMax) ContainerManagementProtocol containerManager, ContainerId containerID,
throws InterruptedException, YarnException, IOException { ContainerState finalState, int timeOutMax)
throws InterruptedException, YarnException, IOException {
List<ContainerId> list = new ArrayList<ContainerId>(); List<ContainerId> list = new ArrayList<ContainerId>();
list.add(containerID); list.add(containerID);
GetContainerStatusesRequest request = GetContainerStatusesRequest request =
@ -314,8 +316,9 @@ public abstract class BaseContainerManagerTest {
finalState, containerStatus.getState()); finalState, containerStatus.getState());
} }
static void waitForApplicationState(ContainerManagerImpl containerManager, public static void waitForApplicationState(
ApplicationId appID, ApplicationState finalState) ContainerManagerImpl containerManager, ApplicationId appID,
ApplicationState finalState)
throws InterruptedException { throws InterruptedException {
// Wait for app-finish // Wait for app-finish
Application app = Application app =
@ -344,7 +347,16 @@ public abstract class BaseContainerManagerTest {
public static void waitForNMContainerState(ContainerManagerImpl public static void waitForNMContainerState(ContainerManagerImpl
containerManager, ContainerId containerID, containerManager, ContainerId containerID,
org.apache.hadoop.yarn.server.nodemanager.containermanager org.apache.hadoop.yarn.server.nodemanager.containermanager
.container.ContainerState finalState, int timeOutMax) .container.ContainerState finalState, int timeOutMax)
throws InterruptedException, YarnException, IOException {
waitForNMContainerState(containerManager, containerID,
Arrays.asList(finalState), timeOutMax);
}
public static void waitForNMContainerState(ContainerManagerImpl
containerManager, ContainerId containerID,
List<org.apache.hadoop.yarn.server.nodemanager.containermanager
.container.ContainerState> finalStates, int timeOutMax)
throws InterruptedException, YarnException, IOException { throws InterruptedException, YarnException, IOException {
Container container = null; Container container = null;
org.apache.hadoop.yarn.server.nodemanager org.apache.hadoop.yarn.server.nodemanager
@ -358,15 +370,15 @@ public abstract class BaseContainerManagerTest {
currentState = container.getContainerState(); currentState = container.getContainerState();
} }
if (currentState != null) { if (currentState != null) {
LOG.info("Waiting for NM container to get into state " + finalState LOG.info("Waiting for NM container to get into one of the following " +
+ ". Current state is " + currentState); "states: " + finalStates + ". Current state is " + currentState);
} }
timeoutSecs += 2; timeoutSecs += 2;
} while (!currentState.equals(finalState) } while (!finalStates.contains(currentState)
&& timeoutSecs++ < timeOutMax); && timeoutSecs++ < timeOutMax);
LOG.info("Container state is " + currentState); LOG.info("Container state is " + currentState);
Assert.assertEquals("ContainerState is not correct (timedout)", Assert.assertTrue("ContainerState is not correct (timedout)",
finalState, currentState); finalStates.contains(currentState));
} }
public static Token createContainerToken(ContainerId cId, long rmIdentifier, public static Token createContainerToken(ContainerId cId, long rmIdentifier,

View File

@ -467,8 +467,10 @@ public class TestQueuingContainerManager extends BaseContainerManagerTest {
StartContainersRequest.newInstance(list); StartContainersRequest.newInstance(list);
containerManager.startContainers(allRequests); containerManager.startContainers(allRequests);
BaseContainerManagerTest.waitForNMContainerState(containerManager, BaseContainerManagerTest.waitForNMContainerState(
createContainerId(0), ContainerState.DONE, 40); containerManager, createContainerId(0),
Arrays.asList(ContainerState.DONE,
ContainerState.CONTAINER_CLEANEDUP_AFTER_KILL), 40);
Thread.sleep(5000); Thread.sleep(5000);
// Get container statuses. Container 0 should be killed, container 1 // Get container statuses. Container 0 should be killed, container 1