YARN-1673. Fix option parsing in YARN's application CLI after it is broken by YARN-967. Contributed by Mayank Bansal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1564188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2014-02-04 04:08:09 +00:00
parent dd7fa03719
commit a8c780d378
3 changed files with 8 additions and 5 deletions

View File

@ -165,6 +165,9 @@ Release 2.4.0 - UNRELEASED
YARN-1632. TestApplicationMasterServices should be under YARN-1632. TestApplicationMasterServices should be under
org.apache.hadoop.yarn.server.resourcemanager package (Chen He via jeagles) org.apache.hadoop.yarn.server.resourcemanager package (Chen He via jeagles)
YARN-1673. Fix option parsing in YARN's application CLI after it is broken
by YARN-967. (Mayank Bansal via vinodkv)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -197,7 +197,7 @@ public class ApplicationCLI extends YarnCLI {
listApplications(appTypes, appStates); listApplications(appTypes, appStates);
} }
} else if (cliParser.hasOption(KILL_CMD)) { } else if (cliParser.hasOption(KILL_CMD)) {
if (args.length != 2) { if (args.length != 3) {
printUsage(opts); printUsage(opts);
return exitCode; return exitCode;
} }

View File

@ -681,7 +681,7 @@ public class TestYarnCLI {
sysOutStream.reset(); sysOutStream.reset();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
result = result =
cli.run(new String[] { "-kill", applicationId.toString(), "args" }); cli.run(new String[] {"application", "-kill", applicationId.toString(), "args" });
verify(spyCli).printUsage(any(Options.class)); verify(spyCli).printUsage(any(Options.class));
Assert.assertEquals(createApplicationCLIHelpMessage(), Assert.assertEquals(createApplicationCLIHelpMessage(),
sysOutStream.toString()); sysOutStream.toString());
@ -717,7 +717,7 @@ public class TestYarnCLI {
FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null); FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn( when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport2); newApplicationReport2);
int result = cli.run(new String[] { "-kill", applicationId.toString() }); int result = cli.run(new String[] { "application","-kill", applicationId.toString() });
assertEquals(0, result); assertEquals(0, result);
verify(client, times(0)).killApplication(any(ApplicationId.class)); verify(client, times(0)).killApplication(any(ApplicationId.class));
verify(sysOut).println( verify(sysOut).println(
@ -730,7 +730,7 @@ public class TestYarnCLI {
FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null); FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn( when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
newApplicationReport); newApplicationReport);
result = cli.run(new String[] { "-kill", applicationId.toString() }); result = cli.run(new String[] { "application","-kill", applicationId.toString() });
assertEquals(0, result); assertEquals(0, result);
verify(client).killApplication(any(ApplicationId.class)); verify(client).killApplication(any(ApplicationId.class));
verify(sysOut).println("Killing application application_1234_0005"); verify(sysOut).println("Killing application application_1234_0005");
@ -740,7 +740,7 @@ public class TestYarnCLI {
.getApplicationReport(applicationId); .getApplicationReport(applicationId);
cli = createAndGetAppCLI(); cli = createAndGetAppCLI();
try { try {
cli.run(new String[] { "-kill", applicationId.toString() }); cli.run(new String[] { "application","-kill", applicationId.toString() });
Assert.fail(); Assert.fail();
} catch (Exception ex) { } catch (Exception ex) {
Assert.assertTrue(ex instanceof ApplicationNotFoundException); Assert.assertTrue(ex instanceof ApplicationNotFoundException);