Author: tucu
Date: Wed Jan 16 01:07:35 2013
New Revision: 1433782

URL: http://svn.apache.org/viewvc?rev=1433782&view=rev
Log:
MAPREDUCE-4924. flakey test: 
org.apache.hadoop.mapred.TestClusterMRNotification.testMR. (rkanter via tucu)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/NotificationTestCase.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1433782&r1=1433781&r2=1433782&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Wed Jan 16 01:07:35 2013
@@ -431,6 +431,9 @@ Release 1.2.0 - unreleased
     MAPREDUCE-4930. Backport MAPREDUCE-4678 and MAPREDUCE-4925 to branch-1.
     (Karthik Kambatla and Chris McConnell via harsh)
 
+    MAPREDUCE-4924. flakey test: 
org.apache.hadoop.mapred.TestClusterMRNotification.testMR. 
+    (rkanter via tucu)
+
 Release 1.1.2 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/NotificationTestCase.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/NotificationTestCase.java?rev=1433782&r1=1433781&r2=1433782&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/NotificationTestCase.java
 (original)
+++ 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/NotificationTestCase.java
 Wed Jan 16 01:07:35 2013
@@ -95,7 +95,7 @@ public abstract class NotificationTestCa
   }
 
   public static class NotificationServlet extends HttpServlet {
-    public static int counter = 0;
+    public static volatile int counter = 0;
 
     protected void doGet(HttpServletRequest req, HttpServletResponse res)
       throws ServletException, IOException {
@@ -159,9 +159,10 @@ public abstract class NotificationTestCa
   public void testMR() throws Exception {
     System.out.println(launchWordCount(this.createJobConf(),
                                        "a b c d e f g h", 1, 1));
-    synchronized(Thread.currentThread()) {
-      stdPrintln("Sleeping for 2 seconds to give time for retry");
-      Thread.currentThread().sleep(2000);
+    boolean keepTrying = true;
+    for (int tries = 0; tries < 30 && keepTrying; tries++) {
+      Thread.sleep(50);
+      keepTrying = !(NotificationServlet.counter == 2);
     }
     assertEquals(2, NotificationServlet.counter);
     
@@ -179,18 +180,20 @@ public abstract class NotificationTestCa
     // run a job with KILLED status
     System.out.println(UtilsForTests.runJobKill(this.createJobConf(), inDir,
                                                 outDir).getID());
-    synchronized(Thread.currentThread()) {
-      stdPrintln("Sleeping for 2 seconds to give time for retry");
-      Thread.currentThread().sleep(2000);
+    keepTrying = true;
+    for (int tries = 0; tries < 30 && keepTrying; tries++) {
+      Thread.sleep(50);
+      keepTrying = !(NotificationServlet.counter == 4);
     }
     assertEquals(4, NotificationServlet.counter);
     
     // run a job with FAILED status
     System.out.println(UtilsForTests.runJobFail(this.createJobConf(), inDir,
                                                 outDir).getID());
-    synchronized(Thread.currentThread()) {
-      stdPrintln("Sleeping for 2 seconds to give time for retry");
-      Thread.currentThread().sleep(2000);
+    keepTrying = true;
+    for (int tries = 0; tries < 30 && keepTrying; tries++) {
+      Thread.sleep(50);
+      keepTrying = !(NotificationServlet.counter == 6);
     }
     assertEquals(6, NotificationServlet.counter);
   }


Reply via email to