@Before public void resetSystemExit() { ExitUtil.resetFirstExitException(); }
private void expectExit(String [] args) { try { // should throw exit exception NativeLibraryChecker.main(args); fail("should call exit"); } catch (ExitException e) { // pass ExitUtil.resetFirstExitException(); } }
private void expectExit(String [] args) { try { // should throw exit exception NativeLibraryChecker.main(args); fail("should call exit"); } catch (ExitException e) { // pass ExitUtil.resetFirstExitException(); } }
private void expectOutput(String [] args) { ExitUtil.disableSystemExit(); ByteArrayOutputStream outContent = new ByteArrayOutputStream(); PrintStream originalPs = System.out; System.setOut(new PrintStream(outContent)); try { NativeLibraryChecker.main(args); } catch (ExitException e) { ExitUtil.resetFirstExitException(); } finally { if (Shell.WINDOWS) { assertEquals(outContent.toString().indexOf("winutils: true") != -1, true); } if (NativeCodeLoader.isNativeCodeLoaded()) { assertEquals(outContent.toString().indexOf("hadoop: true") != -1, true); } System.setOut(originalPs); } } }
private void expectOutput(String [] args) { ExitUtil.disableSystemExit(); ByteArrayOutputStream outContent = new ByteArrayOutputStream(); PrintStream originalPs = System.out; System.setOut(new PrintStream(outContent)); try { NativeLibraryChecker.main(args); } catch (ExitException e) { ExitUtil.resetFirstExitException(); } finally { if (Shell.WINDOWS) { assertEquals(outContent.toString().indexOf("winutils: true") != -1, true); } if (NativeCodeLoader.isNativeCodeLoaded()) { assertEquals(outContent.toString().indexOf("hadoop: true") != -1, true); } System.setOut(originalPs); } } }
private static void expectDelegationTokenFetcherExit(String[] args) { try { DelegationTokenFetcher.main(args); fail("should call exit"); } catch (ExitException e) { ExitUtil.resetFirstExitException(); } catch (Exception ex) { fail("expectDelegationTokenFetcherExit ex error " + ex); } }
private static void expectJMXGetExit(String[] args) { try { JMXGet.main(args); fail("should call exit"); } catch (ExitException e) { ExitUtil.resetFirstExitException(); } catch (Exception ex) { fail("expectJMXGetExit ex error " + ex); } } }
/** * Shutdown all the nodes in the cluster. */ public void shutdown(boolean deleteDfsDir) { LOG.info("Shutting down the Mini HDFS Cluster"); if (checkExitOnShutdown) { if (ExitUtil.terminateCalled()) { LOG.fatal("Test resulted in an unexpected exit", ExitUtil.getFirstExitException()); ExitUtil.resetFirstExitException(); throw new AssertionError("Test resulted in an unexpected exit"); } } shutdownDataNodes(); for (NameNodeInfo nnInfo : nameNodes) { if (nnInfo == null) continue; NameNode nameNode = nnInfo.nameNode; if (nameNode != null) { nameNode.stop(); nameNode.join(); nameNode = null; } } if (deleteDfsDir) { base_dir.delete(); } else { base_dir.deleteOnExit(); } }
ExitUtil.resetFirstExitException(); assertEquals(-1, e.status); } catch (Exception e) {
@Test(timeout = 60000) public void testLaunch() throws Exception { ExitUtil.disableSystemExit(); try { auxService = PerNodeTimelineCollectorsAuxService.launchServer(new String[0], createCollectorManager(), conf); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); } }
ExitUtil.resetFirstExitException(); String msg = "Injected Exception"; doThrow(new RuntimeException(msg))
} catch (ExitException ee) { ExitUtil.resetFirstExitException(); assertEquals("Max retries", 1, secondary.getMergeErrorCount() - 1); } finally {
@Test(timeout = 60000) public void testLaunchWithArguments() throws Exception { ExitUtil.disableSystemExit(); ApplicationHistoryServer historyServer = null; try { // Not able to modify the config of this test case, // but others have been customized to avoid conflicts String[] args = new String[2]; args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000"; args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200"; historyServer = ApplicationHistoryServer.launchAppHistoryServer(args); Configuration conf = historyServer.getConfig(); assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS)); assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS)); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); } finally { if (historyServer != null) { historyServer.stop(); } } } @Test(timeout = 240000)
@Test(timeout = 60000) public void testLaunch() throws Exception { ExitUtil.disableSystemExit(); ApplicationHistoryServer historyServer = null; try { // Not able to modify the config of this test case, // but others have been customized to avoid conflicts historyServer = ApplicationHistoryServer.launchAppHistoryServer(new String[0]); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); } finally { if (historyServer != null) { historyServer.stop(); } } }