diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index c066e6240a..b74e23838c 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -223,6 +223,9 @@ Release 2.3.0 - UNRELEASED MAPREDUCE-5625. TestFixedLengthInputFormat fails in jdk7 environment (Mariappan Asokan via jeagles) + MAPREDUCE-5631. TestJobEndNotifier.testNotifyRetries fails with Should + have taken more than 5 seconds in jdk7 (Jonathan Eagles via jlowe) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES 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 116c32cc7b..fd5bbf138e 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 @@ -38,6 +38,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.http.HttpServer; +import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.JobContext; import org.apache.hadoop.mapreduce.MRJobConfig; import org.apache.hadoop.mapreduce.v2.api.records.JobReport; @@ -160,8 +161,13 @@ protected boolean notifyURLOnce() { //Check retries happen as intended @Test public void testNotifyRetries() throws InterruptedException { - Configuration conf = new Configuration(); + JobConf conf = new JobConf(); + conf.set(MRJobConfig.MR_JOB_END_RETRY_ATTEMPTS, "0"); + conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_ATTEMPTS, "1"); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_URL, "http://nonexistent"); + conf.set(MRJobConfig.MR_JOB_END_RETRY_INTERVAL, "5000"); + conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_RETRY_INTERVAL, "5000"); + JobReport jobReport = mock(JobReport.class); long startTime = System.currentTimeMillis(); @@ -170,7 +176,7 @@ public void testNotifyRetries() throws InterruptedException { this.notify(jobReport); long endTime = System.currentTimeMillis(); Assert.assertEquals("Only 1 try was expected but was : " - + this.notificationCount, this.notificationCount, 1); + + this.notificationCount, 1, this.notificationCount); Assert.assertTrue("Should have taken more than 5 seconds it took " + (endTime - startTime), endTime - startTime > 5000); @@ -185,7 +191,7 @@ public void testNotifyRetries() throws InterruptedException { this.notify(jobReport); endTime = System.currentTimeMillis(); Assert.assertEquals("Only 3 retries were expected but was : " - + this.notificationCount, this.notificationCount, 3); + + this.notificationCount, 3, this.notificationCount); Assert.assertTrue("Should have taken more than 9 seconds it took " + (endTime - startTime), endTime - startTime > 9000); @@ -198,14 +204,14 @@ public void testNotificationOnLastRetryNormalShutdown() throws Exception { MRApp app = spy(new MRAppWithCustomContainerAllocator( 2, 2, true, this.getClass().getName(), true, 2, true)); doNothing().when(app).sysexit(); - Configuration conf = new Configuration(); + JobConf conf = new JobConf(); conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL, JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus"); JobImpl job = (JobImpl)app.submit(conf); app.waitForInternalState(job, JobStateInternal.SUCCEEDED); // Unregistration succeeds: successfullyUnregistered is set app.shutDownJob(); - Assert.assertEquals(true, app.isLastAMRetry()); + Assert.assertTrue(app.isLastAMRetry()); Assert.assertEquals(1, JobEndServlet.calledTimes); Assert.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED", JobEndServlet.requestUri.getQuery()); @@ -221,7 +227,7 @@ public void testAbsentNotificationOnNotLastRetryUnregistrationFailure() MRApp app = spy(new MRAppWithCustomContainerAllocator(2, 2, false, this.getClass().getName(), true, 1, false)); doNothing().when(app).sysexit(); - Configuration conf = new Configuration(); + JobConf conf = new JobConf(); conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL, JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus"); JobImpl job = (JobImpl)app.submit(conf); @@ -234,10 +240,10 @@ public void testAbsentNotificationOnNotLastRetryUnregistrationFailure() app.shutDownJob(); // Not the last AM attempt. So user should that the job is still running. app.waitForState(job, JobState.RUNNING); - Assert.assertEquals(false, app.isLastAMRetry()); + Assert.assertFalse(app.isLastAMRetry()); Assert.assertEquals(0, JobEndServlet.calledTimes); - Assert.assertEquals(null, JobEndServlet.requestUri); - Assert.assertEquals(null, JobEndServlet.foundJobState); + Assert.assertNull(JobEndServlet.requestUri); + Assert.assertNull(JobEndServlet.foundJobState); server.stop(); } @@ -248,7 +254,7 @@ public void testNotificationOnLastRetryUnregistrationFailure() MRApp app = spy(new MRAppWithCustomContainerAllocator(2, 2, false, this.getClass().getName(), true, 2, false)); doNothing().when(app).sysexit(); - Configuration conf = new Configuration(); + JobConf conf = new JobConf(); conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL, JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus"); JobImpl job = (JobImpl)app.submit(conf); @@ -259,7 +265,7 @@ public void testNotificationOnLastRetryUnregistrationFailure() // Now shutdown. User should see FAILED state. // Unregistration fails: isLastAMRetry is recalculated, this is app.shutDownJob(); - Assert.assertEquals(true, app.isLastAMRetry()); + Assert.assertTrue(app.isLastAMRetry()); Assert.assertEquals(1, JobEndServlet.calledTimes); Assert.assertEquals("jobid=" + job.getID() + "&status=FAILED", JobEndServlet.requestUri.getQuery());