HDFS-11739. Fix regression in tests caused by YARN-679. Contributed by Steve Loughran

This commit is contained in:
Mingliang Liu 2017-05-03 11:22:44 -07:00
parent d4631e466b
commit 83dded556d
4 changed files with 14 additions and 6 deletions

View File

@ -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);
}
/**

View File

@ -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 + "";

View File

@ -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());
}
}

View File

@ -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);