You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2017/06/21 23:24:03 UTC

[16/50] [abbrv] hadoop git commit: MAPREDUCE-6897. Add Unit Test to ensure Job end notification gets sent even when appMaster stop gets YarnRuntimeException. Contributed by Gergely Novák

MAPREDUCE-6897. Add Unit Test to ensure Job end notification gets sent even when appMaster stop gets YarnRuntimeException. Contributed by Gergely Novák


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/82bbcbf3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/82bbcbf3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/82bbcbf3

Branch: refs/heads/HDFS-10467
Commit: 82bbcbf37f8137112a6270932b2ad7572785c387
Parents: 9ef2743
Author: Ravi Prakash <ra...@apache.org>
Authored: Fri Jun 16 14:25:12 2017 -0700
Committer: Ravi Prakash <ra...@apache.org>
Committed: Fri Jun 16 14:25:44 2017 -0700

----------------------------------------------------------------------
 .../mapreduce/v2/app/TestJobEndNotifier.java    | 25 +++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/82bbcbf3/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
index ecfa43c..d122a9b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
@@ -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.io.PrintStream;
 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.ContainerAllocatorEvent;
 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 class TestJobEndNotifier extends JobEndNotifier {
 
   }
 
-  @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,17 +213,33 @@ public class TestJobEndNotifier extends JobEndNotifier {
     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 {
     HttpServer2 server = startHttpServer();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org