From 2e2afd22f955e3a8799c006291050e34e73e84dc Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Wed, 16 Jan 2013 00:15:59 +0000 Subject: [PATCH] MAPREDUCE-4924. flakey test: org.apache.hadoop.mapred.TestClusterMRNotification.testMR. (rkanter via tucu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1433759 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../hadoop/mapred/NotificationTestCase.java | 22 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index b7e98b4c4d0..8f95ad59552 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -97,6 +97,9 @@ Release 2.0.3-alpha - Unreleased MAPREDUCE-4936. JobImpl uber checks for cpu are wrong (Arun C Murthy via jlowe) + MAPREDUCE-4924. flakey test: org.apache.hadoop.mapred.TestClusterMRNotification.testMR. + (rkanter via tucu) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/NotificationTestCase.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/NotificationTestCase.java index 8c1ba60763c..d2ea74e6940 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/NotificationTestCase.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/NotificationTestCase.java @@ -90,8 +90,8 @@ public abstract class NotificationTestCase extends HadoopTestCase { } public static class NotificationServlet extends HttpServlet { - public static int counter = 0; - public static int failureCounter = 0; + public static volatile int counter = 0; + public static volatile int failureCounter = 0; private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest req, HttpServletResponse res) @@ -155,7 +155,11 @@ public abstract class NotificationTestCase extends HadoopTestCase { System.out.println(launchWordCount(this.createJobConf(), "a b c d e f g h", 1, 1)); - Thread.sleep(2000); + boolean keepTrying = true; + for (int tries = 0; tries < 30 && keepTrying; tries++) { + Thread.sleep(50); + keepTrying = !(NotificationServlet.counter == 2); + } assertEquals(2, NotificationServlet.counter); assertEquals(0, NotificationServlet.failureCounter); @@ -173,14 +177,22 @@ public abstract class NotificationTestCase extends HadoopTestCase { // run a job with KILLED status System.out.println(UtilsForTests.runJobKill(this.createJobConf(), inDir, outDir).getID()); - Thread.sleep(2000); + keepTrying = true; + for (int tries = 0; tries < 30 && keepTrying; tries++) { + Thread.sleep(50); + keepTrying = !(NotificationServlet.counter == 4); + } assertEquals(4, NotificationServlet.counter); assertEquals(0, NotificationServlet.failureCounter); // run a job with FAILED status System.out.println(UtilsForTests.runJobFail(this.createJobConf(), inDir, outDir).getID()); - Thread.sleep(2000); + keepTrying = true; + for (int tries = 0; tries < 30 && keepTrying; tries++) { + Thread.sleep(50); + keepTrying = !(NotificationServlet.counter == 6); + } assertEquals(6, NotificationServlet.counter); assertEquals(0, NotificationServlet.failureCounter); }