MAPREDUCE-6897. Add Unit Test to ensure Job end notification gets sent even when appMaster stop gets YarnRuntimeException. Contributed by Gergely Novák
This commit is contained in:
parent
9ef2743fa1
commit
82bbcbf37f
@ -19,6 +19,7 @@
|
||||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -30,6 +31,7 @@
|
||||
import java.net.Proxy;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
@ -53,6 +55,7 @@
|
||||
import org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator;
|
||||
import org.apache.hadoop.mapreduce.v2.app.rm.RMHeartbeatHandler;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -197,8 +200,8 @@ public void testNotifyRetries() throws InterruptedException {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationOnLastRetryNormalShutdown() throws Exception {
|
||||
private void testNotificationOnLastRetry(boolean withRuntimeException)
|
||||
throws Exception {
|
||||
HttpServer2 server = startHttpServer();
|
||||
// Act like it is the second attempt. Default max attempts is 2
|
||||
MRApp app = spy(new MRAppWithCustomContainerAllocator(
|
||||
@ -210,16 +213,32 @@ public void testNotificationOnLastRetryNormalShutdown() throws Exception {
|
||||
JobImpl job = (JobImpl)app.submit(conf);
|
||||
app.waitForInternalState(job, JobStateInternal.SUCCEEDED);
|
||||
// Unregistration succeeds: successfullyUnregistered is set
|
||||
if (withRuntimeException) {
|
||||
YarnRuntimeException runtimeException = new YarnRuntimeException(
|
||||
new ClosedChannelException());
|
||||
doThrow(runtimeException).when(app).stop();
|
||||
}
|
||||
app.shutDownJob();
|
||||
Assert.assertTrue(app.isLastAMRetry());
|
||||
Assert.assertEquals(1, JobEndServlet.calledTimes);
|
||||
Assert.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED",
|
||||
JobEndServlet.requestUri.getQuery());
|
||||
Assert.assertEquals(JobState.SUCCEEDED.toString(),
|
||||
JobEndServlet.foundJobState);
|
||||
JobEndServlet.foundJobState);
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationOnLastRetryNormalShutdown() throws Exception {
|
||||
testNotificationOnLastRetry(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationOnLastRetryShutdownWithRuntimeException()
|
||||
throws Exception {
|
||||
testNotificationOnLastRetry(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsentNotificationOnNotLastRetryUnregistrationFailure()
|
||||
throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user