Browse Source

commit 619ed4b364fb4ede1fb2e3d4f8f74466f78ddf95
Author: Iyappan Srinivasan <iyappans@yahoo-inc.com>
Date: Tue May 18 08:06:40 2010 +0000

MAPREDUCE-1677 from https://issues.apache.org/jira/secure/attachment/12444390/TestDistributedCachePrivateFile.patch


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077470 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
f976a8a423

+ 24 - 4
src/test/system/java/org/apache/hadoop/mapred/TestDistributedCachePrivateFile.java

@@ -123,6 +123,10 @@ public class TestDistributedCachePrivateFile {
     Configuration conf = new Configuration(cluster.getConf());
     JTProtocol wovenClient = cluster.getJTClient().getProxy();
 
+    String jobTrackerUserName = wovenClient.getDaemonUser();
+
+    LOG.info("jobTrackerUserName is :" + jobTrackerUserName);
+
     //This counter will check for count of a loop,
     //which might become infinite.
     int count = 0;
@@ -224,8 +228,16 @@ public class TestDistributedCachePrivateFile {
               fileStatusMapredLocalDirUserName.getPath();
           FsPermission fsPermMapredLocalDirUserName =
               fileStatusMapredLocalDirUserName.getPermission();
-          Assert.assertTrue("Directory Permission is not 700",
-            fsPermMapredLocalDirUserName.equals(new FsPermission("700")));
+          //If userName of Jobtracker is same as username
+          //of jobSubmission, then the permissions are 770.
+          //Otherwise 570
+          if ( userName.compareTo(jobTrackerUserName) == 0 ) {
+            Assert.assertTrue("Directory Permission is not 770",
+              fsPermMapredLocalDirUserName.equals(new FsPermission("770")));
+          } else {
+            Assert.assertTrue("Directory Permission is not 570",
+              fsPermMapredLocalDirUserName.equals(new FsPermission("570")));
+          }
 
           //Get file status of all the directories 
           //and files under that path.
@@ -245,8 +257,16 @@ public class TestDistributedCachePrivateFile {
               distributedFileCount++;
               String filename = path.getName();
               FsPermission fsPerm = fileStatus.getPermission();
-              Assert.assertTrue("File Permission is not 777",
-                fsPerm.equals(new FsPermission("777")));
+              //If userName of Jobtracker is same as username
+              //of jobSubmission, then the permissions are 770.
+              //Otherwise 570
+              if ( userName.compareTo(jobTrackerUserName) == 0 ) {
+                Assert.assertTrue("File Permission is not 770",
+                  fsPerm.equals(new FsPermission("770")));
+              } else {
+                Assert.assertTrue("File Permission is not 570",
+                  fsPerm.equals(new FsPermission("570")));
+              }
             }
           }
         }