YARN-5524. Yarn live log aggregation does not throw if command line arg is wrong. Contributed by Xuan Gong.
(cherry picked from commit 358341398a
)
This commit is contained in:
parent
0cb99db9d9
commit
e9ce2df1f2
|
@ -138,7 +138,7 @@ public class LogsCLI extends Configured implements Tool {
|
||||||
String localDir = null;
|
String localDir = null;
|
||||||
long bytes = Long.MAX_VALUE;
|
long bytes = Long.MAX_VALUE;
|
||||||
try {
|
try {
|
||||||
CommandLine commandLine = parser.parse(opts, args, true);
|
CommandLine commandLine = parser.parse(opts, args, false);
|
||||||
appIdStr = commandLine.getOptionValue(APPLICATION_ID_OPTION);
|
appIdStr = commandLine.getOptionValue(APPLICATION_ID_OPTION);
|
||||||
containerIdStr = commandLine.getOptionValue(CONTAINER_ID_OPTION);
|
containerIdStr = commandLine.getOptionValue(CONTAINER_ID_OPTION);
|
||||||
nodeAddress = commandLine.getOptionValue(NODE_ADDRESS_OPTION);
|
nodeAddress = commandLine.getOptionValue(NODE_ADDRESS_OPTION);
|
||||||
|
|
|
@ -125,6 +125,21 @@ public class TestLogsCLI {
|
||||||
assertTrue("Should return an error code", exitCode != 0);
|
assertTrue("Should return an error code", exitCode != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 1000l)
|
||||||
|
public void testInvalidOpts() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
|
YarnClient mockYarnClient = createMockYarnClient(
|
||||||
|
YarnApplicationState.FINISHED,
|
||||||
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
|
cli.setConf(conf);
|
||||||
|
|
||||||
|
int exitCode = cli.run( new String[] { "-InvalidOpts"});
|
||||||
|
assertTrue(exitCode == -1);
|
||||||
|
assertTrue(sysErrStream.toString().contains(
|
||||||
|
"options parsing failed: Unrecognized option: -InvalidOpts"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000l)
|
@Test(timeout = 5000l)
|
||||||
public void testInvalidApplicationId() throws Exception {
|
public void testInvalidApplicationId() throws Exception {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
|
|
Loading…
Reference in New Issue