YARN-10191. FS-CS converter: call System.exit function call for every code path in main method. Contributed by Peter Bacsko.
This commit is contained in:
parent
0b931f36ec
commit
0fd8bf5f6b
@ -42,8 +42,9 @@ public static void main(String[] args) {
|
|||||||
LOG.error(FATAL,
|
LOG.error(FATAL,
|
||||||
"Error while starting FS configuration conversion, " +
|
"Error while starting FS configuration conversion, " +
|
||||||
"see previous error messages for details!");
|
"see previous error messages for details!");
|
||||||
System.exit(exitCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.exit(exitCode);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
LOG.error(FATAL,
|
LOG.error(FATAL,
|
||||||
"Error while starting FS configuration conversion!", t);
|
"Error while starting FS configuration conversion!", t);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigConverterTestCommons.YARN_SITE_XML;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigConverterTestCommons.YARN_SITE_XML;
|
||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigConverterTestCommons.setupFSConfigConversionFiles;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigConverterTestCommons.setupFSConfigConversionFiles;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -40,11 +41,13 @@
|
|||||||
public class TestFSConfigToCSConfigConverterMain {
|
public class TestFSConfigToCSConfigConverterMain {
|
||||||
private FSConfigConverterTestCommons converterTestCommons;
|
private FSConfigConverterTestCommons converterTestCommons;
|
||||||
private SecurityManager originalSecurityManager;
|
private SecurityManager originalSecurityManager;
|
||||||
|
private ExitHandlerSecurityManager exitHandlerSecurityManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
originalSecurityManager = System.getSecurityManager();
|
originalSecurityManager = System.getSecurityManager();
|
||||||
System.setSecurityManager(new ExitHandlerSecurityManager());
|
exitHandlerSecurityManager = new ExitHandlerSecurityManager();
|
||||||
|
System.setSecurityManager(exitHandlerSecurityManager);
|
||||||
converterTestCommons = new FSConfigConverterTestCommons();
|
converterTestCommons = new FSConfigConverterTestCommons();
|
||||||
converterTestCommons.setUp();
|
converterTestCommons.setUp();
|
||||||
}
|
}
|
||||||
@ -82,6 +85,7 @@ public void testConvertFSConfigurationDefaults()
|
|||||||
|
|
||||||
assertTrue("capacity-scheduler.xml was not generated", csConfigExists);
|
assertTrue("capacity-scheduler.xml was not generated", csConfigExists);
|
||||||
assertTrue("yarn-site.xml was not generated", yarnSiteConfigExists);
|
assertTrue("yarn-site.xml was not generated", yarnSiteConfigExists);
|
||||||
|
assertEquals("Exit code", 0, exitHandlerSecurityManager.exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -141,12 +145,15 @@ private void verifyHelpText() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ExitHandlerSecurityManager extends SecurityManager {
|
class ExitHandlerSecurityManager extends SecurityManager {
|
||||||
|
int exitCode = Integer.MIN_VALUE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkExit(int status) {
|
public void checkExit(int status) {
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Exit code is not 0, it was " + status);
|
"Exit code is not 0, it was " + status);
|
||||||
}
|
}
|
||||||
|
exitCode = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user