|
@@ -944,6 +944,40 @@ public class TestNodeStatusUpdater {
|
|
|
Assert.assertTrue(containerIdSet.contains(runningContainerId));
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout = 10000)
|
|
|
+ public void testCompletedContainersIsRecentlyStopped() throws Exception {
|
|
|
+ NodeManager nm = new NodeManager();
|
|
|
+ nm.init(conf);
|
|
|
+ NodeStatusUpdaterImpl nodeStatusUpdater =
|
|
|
+ (NodeStatusUpdaterImpl) nm.getNodeStatusUpdater();
|
|
|
+ ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
|
+ Application completedApp = mock(Application.class);
|
|
|
+ when(completedApp.getApplicationState()).thenReturn(
|
|
|
+ ApplicationState.FINISHED);
|
|
|
+ ApplicationAttemptId appAttemptId =
|
|
|
+ ApplicationAttemptId.newInstance(appId, 0);
|
|
|
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
|
|
|
+ Token containerToken =
|
|
|
+ BuilderUtils.newContainerToken(containerId, "host", 1234, "user",
|
|
|
+ BuilderUtils.newResource(1024, 1), 0, 123,
|
|
|
+ "password".getBytes(), 0);
|
|
|
+ Container completedContainer = new ContainerImpl(conf, null,
|
|
|
+ null, null, null, null,
|
|
|
+ BuilderUtils.newContainerTokenIdentifier(containerToken)) {
|
|
|
+ @Override
|
|
|
+ public ContainerState getCurrentState() {
|
|
|
+ return ContainerState.COMPLETE;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ nm.getNMContext().getApplications().putIfAbsent(appId, completedApp);
|
|
|
+ nm.getNMContext().getContainers().put(containerId, completedContainer);
|
|
|
+
|
|
|
+ Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());
|
|
|
+ Assert.assertTrue(nodeStatusUpdater.isContainerRecentlyStopped(
|
|
|
+ containerId));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testCleanedupApplicationContainerCleanup() throws IOException {
|
|
|
NodeManager nm = new NodeManager();
|