use of org.apache.hadoop.yarn.exceptions.ContainerNotFoundException in project hadoop by apache.
the class TestYarnCLI method testGetContainerReportException.
@Test
public void testGetContainerReportException() throws Exception {
ApplicationCLI cli = createAndGetAppCLI();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(applicationId, 1);
long cntId = 1;
ContainerId containerId1 = ContainerId.newContainerId(attemptId, cntId++);
when(client.getContainerReport(containerId1)).thenThrow(new ApplicationNotFoundException("History file for application" + applicationId + " is not found"));
int exitCode = cli.run(new String[] { "container", "-status", containerId1.toString() });
verify(sysOut).println("Application for Container with id '" + containerId1 + "' doesn't exist in RM or Timeline Server.");
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
ContainerId containerId2 = ContainerId.newContainerId(attemptId, cntId++);
when(client.getContainerReport(containerId2)).thenThrow(new ApplicationAttemptNotFoundException("History file for application attempt" + attemptId + " is not found"));
exitCode = cli.run(new String[] { "container", "-status", containerId2.toString() });
verify(sysOut).println("Application Attempt for Container with id '" + containerId2 + "' doesn't exist in RM or Timeline Server.");
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
ContainerId containerId3 = ContainerId.newContainerId(attemptId, cntId++);
when(client.getContainerReport(containerId3)).thenThrow(new ContainerNotFoundException("History file for container" + containerId3 + " is not found"));
exitCode = cli.run(new String[] { "container", "-status", containerId3.toString() });
verify(sysOut).println("Container with id '" + containerId3 + "' doesn't exist in RM or Timeline Server.");
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
}
Aggregations