hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077291 - in /hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred: ./ pipes/
Date Fri, 04 Mar 2011 04:00:22 GMT
Author: omalley
Date: Fri Mar  4 04:00:21 2011
New Revision: 1077291

URL: http://svn.apache.org/viewvc?rev=1077291&view=rev
Log:
commit 96a7b461a605a8bf54b403e236b51a55300b53a2
Author: Vinod Kumar <vinodkv@yahoo-inc.com>
Date:   Fri Mar 5 15:41:57 2010 +0530

    MAPREDUCE-1421 from https://issues.apache.org/jira/secure/attachment/12437985/patch-1421-1-ydist.txt

Added:
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestKillSubProcessesWithLinuxTaskController.java
Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/ClusterWithLinuxTaskController.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobExecutionAsDifferentUser.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLinuxTaskController.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestTrackerDistributedCacheManagerWithLinuxTaskController.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipes.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipesAsDifferentUser.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/ClusterWithLinuxTaskController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/ClusterWithLinuxTaskController.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/ClusterWithLinuxTaskController.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/ClusterWithLinuxTaskController.java
Fri Mar  4 04:00:21 2011
@@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.UserGroupInformation;
 
 import junit.framework.TestCase;
@@ -45,7 +44,11 @@ import junit.framework.TestCase;
  * <ol>
  * <li>Build LinuxTaskController by not passing any
  * <code>-Dhadoop.conf.dir</code></li>
- * <li>Make the built binary to setuid executable</li>
+ * <li>Change ownership of the built binary to root:group1, where group1 is
+ * a secondary group of the test runner.</li>
+ * <li>Change permissions on the binary so that <em>others</em> component
does
+ * not have any permissions on binary</li> 
+ * <li>Make the built binary to setuid and setgid executable</li>
  * <li>Execute following targets:
  * <code>ant test -Dcompile.c++=true -Dtaskcontroller-path=<em>path to built
binary</em> 
  * -Dtaskcontroller-ugi=<em>user,group</em></code></li>
@@ -69,10 +72,7 @@ public class ClusterWithLinuxTaskControl
     @Override
     public void setup() throws IOException {
       // get the current ugi and set the task controller group owner
-      Groups groups = new Groups(new Configuration());
-      String ttGroup = groups.getGroups(
-          UserGroupInformation.getCurrentUser().getUserName()).get(0);
-      getConf().set(TT_GROUP, ttGroup);
+      getConf().set(TT_GROUP, taskTrackerSpecialGroup);
 
       // write configuration file
       configurationFile = createTaskControllerConf(System
@@ -110,6 +110,21 @@ public class ClusterWithLinuxTaskControl
   private static File configurationFile = null;
 
   protected UserGroupInformation taskControllerUser;
+  
+  protected static String taskTrackerSpecialGroup = null;
+  static {
+    if (isTaskExecPathPassed()) {
+      try {
+        taskTrackerSpecialGroup = FileSystem.getLocal(new Configuration())
+            .getFileStatus(
+                new Path(System.getProperty(TASKCONTROLLER_PATH),
+                    "task-controller")).getGroup();
+      } catch (IOException e) {
+        LOG.warn("Could not get group of the binary", e);
+        fail("Could not get group of the binary");
+      }
+    }
+  }
 
   /*
    * Utility method which subclasses use to start and configure the MR Cluster

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobExecutionAsDifferentUser.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobExecutionAsDifferentUser.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobExecutionAsDifferentUser.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobExecutionAsDifferentUser.java
Fri Mar  4 04:00:21 2011
@@ -19,6 +19,7 @@
 package org.apache.hadoop.mapred;
 
 import java.io.IOException;
+import java.security.PrivilegedExceptionAction;
 
 import org.apache.hadoop.examples.SleepJob;
 import org.apache.hadoop.fs.FileSystem;
@@ -40,57 +41,68 @@ public class TestJobExecutionAsDifferent
       return;
     }
     startCluster();
-    Path inDir = new Path("input");
-    Path outDir = new Path("output");
+    taskControllerUser.doAs(new PrivilegedExceptionAction<Object>() {
+      public Object run() throws Exception {
+        Path inDir = new Path("input");
+        Path outDir = new Path("output");
+
+        RunningJob job;
+
+        // Run a job with zero maps/reduces
+        job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 0, 0);
+        job.waitForCompletion();
+        assertTrue("Job failed", job.isSuccessful());
+        assertOwnerShip(outDir);
 
-    RunningJob job;
+        // Run a job with 1 map and zero reduces
+        job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 1, 0);
+        job.waitForCompletion();
+        assertTrue("Job failed", job.isSuccessful());
+        assertOwnerShip(outDir);
 
-    // Run a job with zero maps/reduces
-    job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 0, 0);
-    job.waitForCompletion();
-    assertTrue("Job failed", job.isSuccessful());
-    assertOwnerShip(outDir);
-
-    // Run a job with 1 map and zero reduces
-    job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 1, 0);
-    job.waitForCompletion();
-    assertTrue("Job failed", job.isSuccessful());
-    assertOwnerShip(outDir);
-
-    // Run a normal job with maps/reduces
-    job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 1, 1);
-    job.waitForCompletion();
-    assertTrue("Job failed", job.isSuccessful());
-    assertOwnerShip(outDir);
-
-    // Run a job with jvm reuse
-    JobConf myConf = getClusterConf();
-    myConf.set("mapred.job.reuse.jvm.num.tasks", "-1");
-    String[] args = { "-m", "6", "-r", "3", "-mt", "1000", "-rt", "1000" };
-    assertEquals(0, ToolRunner.run(myConf, new SleepJob(), args));
+        // Run a normal job with maps/reduces
+        job = UtilsForTests.runJob(getClusterConf(), inDir, outDir, 1, 1);
+        job.waitForCompletion();
+        assertTrue("Job failed", job.isSuccessful());
+        assertOwnerShip(outDir);
+
+        // Run a job with jvm reuse
+        JobConf myConf = getClusterConf();
+        myConf.set("mapred.job.reuse.jvm.num.tasks", "-1");
+        String[] args = { "-m", "6", "-r", "3", "-mt", "1000", "-rt", "1000" };
+        assertEquals(0, ToolRunner.run(myConf, new SleepJob(), args));
+        return null;
+      }
+    });
   }
-  
+
   public void testEnvironment() throws Exception {
     if (!shouldRun()) {
       return;
     }
     startCluster();
-    TestMiniMRChildTask childTask = new TestMiniMRChildTask();
-    Path inDir = new Path("input1");
-    Path outDir = new Path("output1");
-    try {
-      childTask.runTestTaskEnv(getClusterConf(), inDir, outDir, false);
-    } catch (IOException e) {
-      fail("IOException thrown while running enviroment test."
-          + e.getMessage());
-    } finally {
-      FileSystem outFs = outDir.getFileSystem(getClusterConf());
-      if (outFs.exists(outDir)) {
-        assertOwnerShip(outDir);
-        outFs.delete(outDir, true);
-      } else {
-        fail("Output directory does not exist" + outDir.toString());
+    taskControllerUser.doAs(new PrivilegedExceptionAction<Object>() {
+      public Object run() throws Exception {
+
+        TestMiniMRChildTask childTask = new TestMiniMRChildTask();
+        Path inDir = new Path("input1");
+        Path outDir = new Path("output1");
+        try {
+          childTask.runTestTaskEnv(getClusterConf(), inDir, outDir, false);
+        } catch (IOException e) {
+          fail("IOException thrown while running enviroment test."
+              + e.getMessage());
+        } finally {
+          FileSystem outFs = outDir.getFileSystem(getClusterConf());
+          if (outFs.exists(outDir)) {
+            assertOwnerShip(outDir);
+            outFs.delete(outDir, true);
+          } else {
+            fail("Output directory does not exist" + outDir.toString());
+          }
+          return null;
+        }
       }
-    }
+    });
   }
 }

Added: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestKillSubProcessesWithLinuxTaskController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestKillSubProcessesWithLinuxTaskController.java?rev=1077291&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestKillSubProcessesWithLinuxTaskController.java
(added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestKillSubProcessesWithLinuxTaskController.java
Fri Mar  4 04:00:21 2011
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Test killing of child processes spawned by the jobs with LinuxTaskController
+ * running the jobs as a user different from the user running the cluster. 
+ * See {@link ClusterWithLinuxTaskController}
+ */
+
+public class TestKillSubProcessesWithLinuxTaskController extends 
+  ClusterWithLinuxTaskController {
+
+  public void testKillSubProcess() throws Exception{
+    if(!shouldRun()) {
+      return;
+    }
+    startCluster();
+    taskControllerUser.doAs(new PrivilegedExceptionAction<Object>() {
+      public Object run() throws Exception {
+        JobConf myConf = getClusterConf();
+        JobTracker jt = mrCluster.getJobTrackerRunner().getJobTracker();
+
+        TestKillSubProcesses.mr = mrCluster;
+        TestKillSubProcesses sbProc = new TestKillSubProcesses();
+        sbProc.runTests(myConf, jt);
+        return null;
+      }
+    });
+  }
+}

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLinuxTaskController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLinuxTaskController.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLinuxTaskController.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLinuxTaskController.java
Fri Mar  4 04:00:21 2011
@@ -22,8 +22,6 @@ import java.io.IOException;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.security.Groups;
-import org.apache.hadoop.security.UserGroupInformation;
 
 import junit.framework.TestCase;
 
@@ -96,11 +94,8 @@ public class TestLinuxTaskController ext
         conf);
     validateTaskControllerSetup(controller, true);
 
-    // get the current ugi and set the task controller group owner in conf
-    Groups groups = new Groups(new Configuration());
-    String ttGroup = groups.getGroups(
-        UserGroupInformation.getCurrentUser().getUserName()).get(0);
-    conf.set(ClusterWithLinuxTaskController.TT_GROUP, ttGroup);
+    conf.set(ClusterWithLinuxTaskController.TT_GROUP,
+        ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     // write the task-controller's conf file
     ClusterWithLinuxTaskController.createTaskControllerConf(taskControllerPath,
         conf);

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
Fri Mar  4 04:00:21 2011
@@ -41,8 +41,6 @@ public class TestLocalizationWithLinuxTa
 
   private File configFile;
 
-  private static String taskTrackerSpecialGroup;
-
   @Override
   protected boolean canRun() {
     return ClusterWithLinuxTaskController.shouldRun();
@@ -63,7 +61,6 @@ public class TestLocalizationWithLinuxTa
         System.getProperty(ClusterWithLinuxTaskController.TASKCONTROLLER_PATH);
     String execPath = path + "/task-controller";
     ((MyLinuxTaskController) taskController).setTaskControllerExe(execPath);
-    taskTrackerSpecialGroup = getFilePermissionAttrs(execPath)[2];
     taskController.setConf(trackerFConf);
     taskController.setup();
 
@@ -121,13 +118,13 @@ public class TestLocalizationWithLinuxTa
       assertTrue("user-dir in taskTrackerSubdir " + taskTrackerSubDir
           + "is not created!", userDir.exists());
       checkFilePermissions(userDir.getAbsolutePath(), "dr-xrws---", task
-          .getUser(), taskTrackerSpecialGroup);
+          .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
 
       File jobCache = new File(userDir, TaskTracker.JOBCACHE);
       assertTrue("jobcache in the userDir " + userDir + " isn't created!",
           jobCache.exists());
       checkFilePermissions(jobCache.getAbsolutePath(), "dr-xrws---", task
-          .getUser(), taskTrackerSpecialGroup);
+          .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
 
       // Verify the distributed cache dir.
       File distributedCacheDir =
@@ -136,7 +133,8 @@ public class TestLocalizationWithLinuxTa
       assertTrue("distributed cache dir " + distributedCacheDir
           + " doesn't exists!", distributedCacheDir.exists());
       checkFilePermissions(distributedCacheDir.getAbsolutePath(),
-          "dr-xrws---", task.getUser(), taskTrackerSpecialGroup);
+          "dr-xrws---", task.getUser(),
+          ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
   }
 
@@ -149,7 +147,7 @@ public class TestLocalizationWithLinuxTa
               .toString()));
       // check the private permissions on the job directory
       checkFilePermissions(jobDir.getAbsolutePath(), "dr-xrws---", task
-          .getUser(), taskTrackerSpecialGroup);
+          .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
 
     // check the private permissions of various directories
@@ -161,7 +159,8 @@ public class TestLocalizationWithLinuxTa
     dirs.add(new Path(jarsDir, "lib"));
     for (Path dir : dirs) {
       checkFilePermissions(dir.toUri().getPath(), "dr-xrws---",
-          task.getUser(), taskTrackerSpecialGroup);
+          task.getUser(),
+          ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
 
     // job-work dir needs user writable permissions
@@ -169,7 +168,7 @@ public class TestLocalizationWithLinuxTa
         lDirAlloc.getLocalPathToRead(TaskTracker.getJobWorkDir(task.getUser(),
             jobId.toString()), trackerFConf);
     checkFilePermissions(jobWorkDir.toUri().getPath(), "drwxrws---", task
-        .getUser(), taskTrackerSpecialGroup);
+        .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
 
     // check the private permissions of various files
     List<Path> files = new ArrayList<Path>();
@@ -181,7 +180,7 @@ public class TestLocalizationWithLinuxTa
     files.add(new Path(jarsDir, "lib" + Path.SEPARATOR + "lib2.jar"));
     for (Path file : files) {
       checkFilePermissions(file.toUri().getPath(), "-r-xrwx---", task
-          .getUser(), taskTrackerSpecialGroup);
+          .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
   }
 
@@ -197,7 +196,8 @@ public class TestLocalizationWithLinuxTa
     dirs.add(new Path(attemptLogFiles[1].getParentFile().getAbsolutePath()));
     for (Path dir : dirs) {
       checkFilePermissions(dir.toUri().getPath(), "drwxrws---",
-          task.getUser(), taskTrackerSpecialGroup);
+          task.getUser(),
+          ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
 
     // check the private permissions of various files
@@ -207,7 +207,7 @@ public class TestLocalizationWithLinuxTa
         task.isTaskCleanupTask()), trackerFConf));
     for (Path file : files) {
       checkFilePermissions(file.toUri().getPath(), "-rwxrwx---", task
-          .getUser(), taskTrackerSpecialGroup);
+          .getUser(), ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
     }
   }
 }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestTrackerDistributedCacheManagerWithLinuxTaskController.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestTrackerDistributedCacheManagerWithLinuxTaskController.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestTrackerDistributedCacheManagerWithLinuxTaskController.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestTrackerDistributedCacheManagerWithLinuxTaskController.java
Fri Mar  4 04:00:21 2011
@@ -37,7 +37,6 @@ public class TestTrackerDistributedCache
     TestTrackerDistributedCacheManager {
 
   private File configFile;
-  private String taskTrackerSpecialGroup;
 
   private static final Log LOG =
       LogFactory
@@ -65,9 +64,6 @@ public class TestTrackerDistributedCache
     ((MyLinuxTaskController)taskController).setTaskControllerExe(execPath);
     taskController.setConf(conf);
     taskController.setup();
-
-    taskTrackerSpecialGroup =
-        TestTaskTrackerLocalization.getFilePermissionAttrs(execPath)[2];
   }
 
   @Override
@@ -113,7 +109,8 @@ public class TestTrackerDistributedCache
     for (Path p : localCacheFiles) {
       // First make sure that the cache file has proper permissions.
       TestTaskTrackerLocalization.checkFilePermissions(p.toUri().getPath(),
-          "-r-xrwx---", userName, taskTrackerSpecialGroup);
+          "-r-xrwx---", userName,
+          ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
       // Now. make sure that all the path components also have proper
       // permissions.
       checkPermissionOnPathComponents(p.toUri().getPath(), userName);
@@ -148,7 +145,8 @@ public class TestTrackerDistributedCache
     File path = new File(cachedFilePath).getParentFile();
     while (!path.getAbsolutePath().equals(leadingStringForFirstFile)) {
       TestTaskTrackerLocalization.checkFilePermissions(path.getAbsolutePath(),
-          "dr-xrws---", userName, taskTrackerSpecialGroup);
+          "dr-xrws---", userName, 
+          ClusterWithLinuxTaskController.taskTrackerSpecialGroup);
       path = path.getParentFile();
     }
   }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipes.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipes.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipes.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipes.java
Fri Mar  4 04:00:21 2011
@@ -73,8 +73,8 @@ public class TestPipes extends TestCase 
     }
     MiniDFSCluster dfs = null;
     MiniMRCluster mr = null;
-    Path inputPath = new Path("/testing/in");
-    Path outputPath = new Path("/testing/out");
+    Path inputPath = new Path("testing/in");
+    Path outputPath = new Path("testing/out");
     try {
       final int numSlaves = 2;
       Configuration conf = new Configuration();
@@ -151,7 +151,7 @@ public class TestPipes extends TestCase 
                           int numMaps, int numReduces, String[] expectedResults,
                           JobConf conf
                          ) throws IOException {
-    Path wordExec = new Path("/testing/bin/application");
+    Path wordExec = new Path("testing/bin/application");
     JobConf job = null;
     if(conf == null) {
       job = mr.createJobConf();
@@ -231,7 +231,7 @@ public class TestPipes extends TestCase 
                             "pipes");
     Path inDir = new Path(testDir, "input");
     nonPipedOutDir = new Path(testDir, "output");
-    Path wordExec = new Path("/testing/bin/application");
+    Path wordExec = new Path("testing/bin/application");
     Path jobXml = new Path(testDir, "job.xml");
     {
       FileSystem fs = dfs.getFileSystem();

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipesAsDifferentUser.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipesAsDifferentUser.java?rev=1077291&r1=1077290&r2=1077291&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipesAsDifferentUser.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/pipes/TestPipesAsDifferentUser.java
Fri Mar  4 04:00:21 2011
@@ -18,6 +18,8 @@
 
 package org.apache.hadoop.mapred.pipes;
 
+import java.security.PrivilegedExceptionAction;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileSystem;
@@ -46,29 +48,35 @@ public class TestPipesAsDifferentUser ex
     }
 
     super.startCluster();
-    JobConf clusterConf = getClusterConf();
-    Path inputPath = new Path(homeDirectory, "in");
-    Path outputPath = new Path(homeDirectory, "out");
-
-    TestPipes.writeInputFile(FileSystem.get(clusterConf), inputPath);
-    TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountSimple,
-        inputPath, outputPath, 3, 2, TestPipes.twoSplitOutput, clusterConf);
-    assertOwnerShip(outputPath);
-    TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
-
-    TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountSimple,
-        inputPath, outputPath, 3, 0, TestPipes.noSortOutput, clusterConf);
-    assertOwnerShip(outputPath);
-    TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
-
-    TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountPart,
-        inputPath, outputPath, 3, 2, TestPipes.fixedPartitionOutput,
-        clusterConf);
-    assertOwnerShip(outputPath);
-    TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
-
-    TestPipes.runNonPipedProgram(mrCluster, dfsCluster,
-        TestPipes.wordCountNoPipes, clusterConf);
-    assertOwnerShip(TestPipes.nonPipedOutDir, FileSystem.getLocal(clusterConf));
+    taskControllerUser.doAs(new PrivilegedExceptionAction<Object>() {
+      public Object run() throws Exception {
+        JobConf clusterConf = getClusterConf();
+        Path inputPath = new Path(homeDirectory, "in");
+        Path outputPath = new Path(homeDirectory, "out");
+
+        TestPipes.writeInputFile(FileSystem.get(clusterConf), inputPath);
+        TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountSimple,
+            inputPath, outputPath, 3, 2, TestPipes.twoSplitOutput, clusterConf);
+        assertOwnerShip(outputPath);
+        TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
+
+        TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountSimple,
+            inputPath, outputPath, 3, 0, TestPipes.noSortOutput, clusterConf);
+        assertOwnerShip(outputPath);
+        TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
+
+        TestPipes.runProgram(mrCluster, dfsCluster, TestPipes.wordCountPart,
+            inputPath, outputPath, 3, 2, TestPipes.fixedPartitionOutput,
+            clusterConf);
+        assertOwnerShip(outputPath);
+        TestPipes.cleanup(dfsCluster.getFileSystem(), outputPath);
+
+        TestPipes.runNonPipedProgram(mrCluster, dfsCluster,
+            TestPipes.wordCountNoPipes, clusterConf);
+        assertOwnerShip(TestPipes.nonPipedOutDir, FileSystem
+            .getLocal(clusterConf));
+        return null;
+      }
+    });
   }
 }



Mime
View raw message