HDFS-11739. Fix regression in tests caused by YARN-679. Contributed by Steve Loughran
This commit is contained in:
parent
d4631e466b
commit
83dded556d
@ -38,6 +38,10 @@ public final class ExitUtil {
|
||||
private static volatile boolean systemHaltDisabled = false;
|
||||
private static volatile ExitException firstExitException;
|
||||
private static volatile HaltException firstHaltException;
|
||||
/** Message raised from an exit exception if none were provided: {@value}. */
|
||||
public static final String EXIT_EXCEPTION_MESSAGE = "ExitException";
|
||||
/** Message raised from a halt exception if none were provided: {@value}. */
|
||||
public static final String HALT_EXCEPTION_MESSAGE = "HaltException";
|
||||
|
||||
private ExitUtil() {
|
||||
}
|
||||
@ -285,7 +289,7 @@ public static void halt(int status, Throwable t) throws HaltException {
|
||||
* @throws ExitException if {@link System#exit(int)} is disabled.
|
||||
*/
|
||||
public static void terminate(int status) throws ExitException {
|
||||
terminate(status, "");
|
||||
terminate(status, EXIT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,7 +310,7 @@ public static void terminate(int status, String msg) throws ExitException {
|
||||
* @throws HaltException if {@link Runtime#halt(int)} is disabled.
|
||||
*/
|
||||
public static void halt(int status) throws HaltException {
|
||||
halt(status, "");
|
||||
halt(status, HALT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,8 @@
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||
import org.apache.hadoop.util.ExitUtil;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -78,7 +80,7 @@ public void testMetadataVersionOutput() throws IOException {
|
||||
try {
|
||||
NameNode.createNameNode(new String[] { "-metadataVersion" }, conf);
|
||||
} catch (Exception e) {
|
||||
assertExceptionContains("ExitException", e);
|
||||
assertExceptionContains(ExitUtil.EXIT_EXCEPTION_MESSAGE, e);
|
||||
}
|
||||
/* Check if meta data version is printed correctly. */
|
||||
final String verNumStr = HdfsServerConstants.NAMENODE_LAYOUT_VERSION + "";
|
||||
|
@ -425,8 +425,9 @@ public void testSNNStartupWithRuntimeException() throws Exception {
|
||||
SecondaryNameNode.main(argv);
|
||||
fail("Failed to handle runtime exceptions during SNN startup!");
|
||||
} catch (ExitException ee) {
|
||||
GenericTestUtils.assertExceptionContains("ExitException", ee);
|
||||
assertTrue("Didn't termiated properly ", ExitUtil.terminateCalled());
|
||||
GenericTestUtils.assertExceptionContains(
|
||||
ExitUtil.EXIT_EXCEPTION_MESSAGE, ee);
|
||||
assertTrue("Didn't terminate properly ", ExitUtil.terminateCalled());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
import java.io.PrintStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestGridmixSubmission extends CommonJobTest {
|
||||
@ -185,7 +186,7 @@ public void testMain() throws Exception {
|
||||
DebugGridmix.main(argv);
|
||||
|
||||
} catch (ExitUtil.ExitException e) {
|
||||
assertEquals("ExitException", e.getMessage());
|
||||
assertExceptionContains(ExitUtil.EXIT_EXCEPTION_MESSAGE, e);
|
||||
ExitUtil.resetFirstExitException();
|
||||
} finally {
|
||||
System.setErr(oldOut);
|
||||
|
Loading…
Reference in New Issue
Block a user