瀏覽代碼

MAPREDUCE-5514. Fix TestRMContainerAllocator. Contributed by Zhijie Shen.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1526735 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 11 年之前
父節點
當前提交
96c11fe602

+ 2 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -181,6 +181,8 @@ Release 2.3.0 - UNRELEASED
     MAPREDUCE-5522. Incorrect oreder expected from JobQueueInfo (Jinghui Wang
     via bobby)
 
+    MAPREDUCE-5514. Fix TestRMContainerAllocator. (Zhijie Shen via acmurthy) 
+
 Release 2.2.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 10 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestRMContainerAllocator.java

@@ -432,11 +432,21 @@ public class TestRMContainerAllocator {
   }
 
   private static class MyResourceManager extends MockRM {
+
+    private static long fakeClusterTimeStamp = System.currentTimeMillis();
     
     public MyResourceManager(Configuration conf) {
       super(conf);
     }
 
+    @Override
+    public void serviceStart() throws Exception {
+      super.serviceStart();
+      // Ensure that the application attempt IDs for all the tests are the same
+      // The application attempt IDs will be used as the login user names
+      MyResourceManager.setClusterTimeStamp(fakeClusterTimeStamp);
+    }
+
     @Override
     protected Dispatcher createDispatcher() {
       return new DrainDispatcher();

+ 6 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java

@@ -168,7 +168,12 @@ public class ResourceManager extends CompositeService implements Recoverable {
   public static long getClusterTimeStamp() {
     return clusterTimeStamp;
   }
-  
+
+  @VisibleForTesting
+  protected static void setClusterTimeStamp(long timestamp) {
+    clusterTimeStamp = timestamp;
+  }
+
   @Override
   protected void serviceInit(Configuration conf) throws Exception {
     validateConfigs(conf);