|
@@ -71,6 +71,7 @@ import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat;
|
|
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogsRequest;
|
|
|
import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
|
|
|
import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers;
|
|
|
+import org.codehaus.jettison.json.JSONObject;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
@@ -131,6 +132,28 @@ public class TestLogsCLI {
|
|
|
assertTrue(sysErrStream.toString().startsWith("Invalid ApplicationId specified"));
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout = 5000L)
|
|
|
+ public void testInvalidAMContainerId() throws Exception {
|
|
|
+ Configuration conf = new YarnConfiguration();
|
|
|
+ conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true);
|
|
|
+ YarnClient mockYarnClient =
|
|
|
+ createMockYarnClient(YarnApplicationState.FINISHED,
|
|
|
+ UserGroupInformation.getCurrentUser().getShortUserName());
|
|
|
+ LogsCLI cli = spy(new LogsCLIForTest(mockYarnClient));
|
|
|
+ List<JSONObject> list = Arrays.asList(new JSONObject());
|
|
|
+ doReturn(list).when(cli)
|
|
|
+ .getAMContainerInfoForRMWebService(any(Configuration.class),
|
|
|
+ any(String.class));
|
|
|
+ cli.setConf(conf);
|
|
|
+
|
|
|
+ int exitCode = cli.run(
|
|
|
+ new String[] {"-applicationId", "application_1465862913885_0027",
|
|
|
+ "-am", "1000" });
|
|
|
+ assertTrue(exitCode == -1);
|
|
|
+ assertTrue(sysErrStream.toString()
|
|
|
+ .contains("exceeds the number of AM containers"));
|
|
|
+ }
|
|
|
+
|
|
|
@Test(timeout = 5000l)
|
|
|
public void testUnknownApplicationId() throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|