Browse Source

MAPREDUCE-4699. Fixed unit test failures - TestFairScheduler and TestCapacityScheduler. (Contributed by Gopal V)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1417677 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Seth 12 years ago
parent
commit
e91e72bcd9

+ 3 - 0
CHANGES.txt

@@ -360,6 +360,9 @@ Release 1.1.2 - Unreleased
     MAPREDUCE-4697. Fixed a failing unit test - TestMapredHeartbeat.
     (Gopal V via sseth)
 
+    MAPREDUCE-4699. Fixed unit test failures - TestFairScheduler and 
+    TestCapacityScheduler. (Gopal V via sseth)
+
 Release 1.1.1 - 2012.11.18
 
   INCOMPATIBLE CHANGES

+ 4 - 0
src/contrib/fairscheduler/src/test/org/apache/hadoop/mapred/TestFairScheduler.java

@@ -559,6 +559,10 @@ public class TestFairScheduler extends TestCase {
     clock = new FakeClock();
     try {
       jobTracker = new JobTracker(conf, clock);
+      jobTracker.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_ENTER);
+      jobTracker.initializeFilesystem();
+      jobTracker.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_LEAVE);
+      jobTracker.initialize();
     } catch (Exception e) {
       throw new RuntimeException("Could not start JT", e);
     }

+ 6 - 3
src/mapred/org/apache/hadoop/mapred/JobTracker.java

@@ -54,6 +54,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
@@ -1899,8 +1900,9 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
       conf.setBoolean(DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_KEY, false);
     }
   }
-  
-  private void initializeFilesystem() throws IOException, InterruptedException {
+ 
+  @InterfaceAudience.Private
+  void initializeFilesystem() throws IOException, InterruptedException {
     // Connect to HDFS NameNode
     while (!Thread.currentThread().isInterrupted() && fs == null) {
       try {
@@ -1928,7 +1930,8 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
     }
   }
   
-  private void initialize() 
+  @InterfaceAudience.Private
+  void initialize() 
       throws IOException, InterruptedException {
     // initialize history parameters.
     final JobTracker jtFinal = this;

+ 8 - 0
src/test/org/apache/hadoop/mapred/UtilsForTests.java

@@ -843,6 +843,10 @@ public class UtilsForTests {
     JobConf conf = new JobConf();
     conf.set("mapred.job.tracker", "localhost:0");
     conf.set("mapred.job.tracker.http.address", "0.0.0.0:0");
+    return getJobTracker(conf, qm);
+  }
+
+  static JobTracker getJobTracker(JobConf conf, QueueManager qm) {
     JobTracker jt;
     try {
       if (qm == null) {
@@ -850,6 +854,10 @@ public class UtilsForTests {
       } else {
         jt = new JobTracker(conf, qm);
       }
+      jt.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_ENTER);
+      jt.initializeFilesystem();
+      jt.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_LEAVE);
+      jt.initialize();
       return jt;
     } catch (Exception e) {
       throw new RuntimeException("Could not start jt", e);