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