You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/10/12 06:50:06 UTC

svn commit: r1397436 [7/7] - in /hadoop/common/branches/branch-1-win: ./ lib/ src/contrib/hod/conf/ src/contrib/index/sample/ src/contrib/index/src/java/org/apache/hadoop/contrib/index/example/ src/contrib/index/src/java/org/apache/hadoop/contrib/index...

Modified: hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLinuxTaskControllerOtherUser.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLinuxTaskControllerOtherUser.java?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLinuxTaskControllerOtherUser.java (original)
+++ hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLinuxTaskControllerOtherUser.java Fri Oct 12 04:50:05 2012
@@ -1,125 +1,125 @@
-/**
- * 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 org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
-import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.mapreduce.test.system.MRCluster;
-import org.apache.hadoop.mapreduce.test.system.JTProtocol;
-import org.apache.hadoop.mapreduce.test.system.JTClient;
-import org.apache.hadoop.examples.SleepJob;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.security.UserGroupInformation;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * Verifying the job submissions with original user and other user
- * with Linux task Controller.Original user should succeed and other
- * user should not.
- */
-public class TestLinuxTaskControllerOtherUser {
-  private static final Log LOG = LogFactory.
-      getLog(TestLinuxTaskControllerOtherUser.class);
-  private static MRCluster cluster = null;
-  private static JobClient jobClient = null;
-  private static JTProtocol remoteJTClient = null;
-  private static JTClient jtClient = null;
-  private static Configuration conf = new Configuration();
-  private static UserGroupInformation proxyUGI = null;
-  private static Path inputDir = new Path("input");
-  private static Path outputDir = new Path("output"); 
-
-  @BeforeClass
-  public static void before() throws Exception {
-    cluster = MRCluster.createCluster(conf);
-    cluster.setUp();
-    jtClient = cluster.getJTClient();
-    jobClient = jtClient.getClient();
-    remoteJTClient = cluster.getJTClient().getProxy();
-    conf = remoteJTClient.getDaemonConf();
-  }
-
-  @AfterClass
-  public static void after() throws Exception {
-    cluster.tearDown();
-    cleanup(inputDir, conf);
-    cleanup(outputDir, conf);
-  }
- 
-  /**
-   * Submit a Sleep Job with a diferent user id and verify it failure
-   * @param none
-   * @return void
-   */
-  @Test
-  public void testSubmitJobDifferentUserJobClient() throws Exception {
-    UserGroupInformation ugi = UserGroupInformation.getLoginUser();
-    LOG.info("LoginUser:" + ugi);
-    if (conf.get("mapred.task.tracker.task-controller").
-        equals("org.apache.hadoop.mapred.LinuxTaskController")) {
-      //Changing the User name
-      proxyUGI = UserGroupInformation.createRemoteUser(
-          "hadoop1");
- 
-      SleepJob job = new SleepJob();
-      job.setConf(conf);
-      final JobConf jobConf = job.setupJobConf(2, 1, 2000, 2000, 100, 100);
-      String error = null;
-      RunningJob runJob = null;
-      //Getting the jobClient with the changed remote user and 
-      //then submit the command.
-      try {
-        final JobClient jClient =
-            proxyUGI.doAs(new PrivilegedExceptionAction<JobClient>() {
-          public JobClient run() throws IOException {
-            return new JobClient(jobConf);
-          }
-        });
-
-        runJob = proxyUGI.doAs(
-          new PrivilegedExceptionAction<RunningJob>() {
-          public RunningJob run() throws IOException {
-            return jClient.submitJob(jobConf);
-          }
-        });
-      } catch (Exception e) {error = e.toString();}
-      //A error is expected to be thrown
-      if (error.indexOf("No valid credentials provided") != -1) {
-        LOG.info("e's value is :" + error);
-      } else {
-        Assert.fail("Some unknown error is thrown :" + error);
-      }
-      Assert.assertNull("Job is still running", runJob);
-    }
-  }
-
-  //Cleanup directories in dfs.
-  private static void cleanup(Path dir, Configuration conf)
-      throws IOException {
-    FileSystem fs = dir.getFileSystem(conf);
-    fs.delete(dir, true);
-  }
-}
+/**
+ * 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 org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Test;
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapreduce.test.system.MRCluster;
+import org.apache.hadoop.mapreduce.test.system.JTProtocol;
+import org.apache.hadoop.mapreduce.test.system.JTClient;
+import org.apache.hadoop.examples.SleepJob;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.security.UserGroupInformation;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Verifying the job submissions with original user and other user
+ * with Linux task Controller.Original user should succeed and other
+ * user should not.
+ */
+public class TestLinuxTaskControllerOtherUser {
+  private static final Log LOG = LogFactory.
+      getLog(TestLinuxTaskControllerOtherUser.class);
+  private static MRCluster cluster = null;
+  private static JobClient jobClient = null;
+  private static JTProtocol remoteJTClient = null;
+  private static JTClient jtClient = null;
+  private static Configuration conf = new Configuration();
+  private static UserGroupInformation proxyUGI = null;
+  private static Path inputDir = new Path("input");
+  private static Path outputDir = new Path("output"); 
+
+  @BeforeClass
+  public static void before() throws Exception {
+    cluster = MRCluster.createCluster(conf);
+    cluster.setUp();
+    jtClient = cluster.getJTClient();
+    jobClient = jtClient.getClient();
+    remoteJTClient = cluster.getJTClient().getProxy();
+    conf = remoteJTClient.getDaemonConf();
+  }
+
+  @AfterClass
+  public static void after() throws Exception {
+    cluster.tearDown();
+    cleanup(inputDir, conf);
+    cleanup(outputDir, conf);
+  }
+ 
+  /**
+   * Submit a Sleep Job with a diferent user id and verify it failure
+   * @param none
+   * @return void
+   */
+  @Test
+  public void testSubmitJobDifferentUserJobClient() throws Exception {
+    UserGroupInformation ugi = UserGroupInformation.getLoginUser();
+    LOG.info("LoginUser:" + ugi);
+    if (conf.get("mapred.task.tracker.task-controller").
+        equals("org.apache.hadoop.mapred.LinuxTaskController")) {
+      //Changing the User name
+      proxyUGI = UserGroupInformation.createRemoteUser(
+          "hadoop1");
+ 
+      SleepJob job = new SleepJob();
+      job.setConf(conf);
+      final JobConf jobConf = job.setupJobConf(2, 1, 2000, 2000, 100, 100);
+      String error = null;
+      RunningJob runJob = null;
+      //Getting the jobClient with the changed remote user and 
+      //then submit the command.
+      try {
+        final JobClient jClient =
+            proxyUGI.doAs(new PrivilegedExceptionAction<JobClient>() {
+          public JobClient run() throws IOException {
+            return new JobClient(jobConf);
+          }
+        });
+
+        runJob = proxyUGI.doAs(
+          new PrivilegedExceptionAction<RunningJob>() {
+          public RunningJob run() throws IOException {
+            return jClient.submitJob(jobConf);
+          }
+        });
+      } catch (Exception e) {error = e.toString();}
+      //A error is expected to be thrown
+      if (error.indexOf("No valid credentials provided") != -1) {
+        LOG.info("e's value is :" + error);
+      } else {
+        Assert.fail("Some unknown error is thrown :" + error);
+      }
+      Assert.assertNull("Job is still running", runJob);
+    }
+  }
+
+  //Cleanup directories in dfs.
+  private static void cleanup(Path dir, Configuration conf)
+      throws IOException {
+    FileSystem fs = dir.getFileSystem(conf);
+    fs.delete(dir, true);
+  }
+}

Modified: hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLostTaskTracker.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLostTaskTracker.java?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLostTaskTracker.java (original)
+++ hadoop/common/branches/branch-1-win/src/test/system/java/org/apache/hadoop/mapred/TestLostTaskTracker.java Fri Oct 12 04:50:05 2012
@@ -1,258 +1,258 @@
-package org.apache.hadoop.mapred;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.examples.SleepJob;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.permission.FsAction;
-import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.hadoop.mapreduce.test.system.JTProtocol;
-import org.apache.hadoop.mapreduce.test.system.JobInfo;
-import org.apache.hadoop.mapreduce.test.system.MRCluster;
-import org.apache.hadoop.mapreduce.test.system.JTClient; 
-import org.apache.hadoop.mapreduce.test.system.TTClient;
-import org.apache.hadoop.mapreduce.test.system.TTProtocol;
-import org.apache.hadoop.mapreduce.test.system.TaskInfo;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Hashtable;
-
-public class TestLostTaskTracker {
-  private static final Log LOG = LogFactory
-      .getLog(TestLostTaskTracker.class);
-  private static MRCluster cluster;
-  private static Configuration conf = new Configuration();
-  private static Path inputDir = new Path("input");
-  private static Path outputDir = new Path("output");
-  private static String confFile = "mapred-site.xml";
-  private JTProtocol wovenClient = null;
-  private JobID jID = null;
-  private JobInfo jInfo = null;
-  private JTClient jtClient = null;
-
-  @BeforeClass
-  public static void before() throws Exception {
-    String [] expExcludeList = {"java.net.ConnectException",
-        "java.io.IOException"};
-    cluster = MRCluster.createCluster(conf);
-    cluster.setExcludeExpList(expExcludeList);
-    cluster.setUp();
-    Hashtable<String,Object> prop = new Hashtable<String,Object>();
-    prop.put("mapred.tasktracker.expiry.interval",30000L);
-    prop.put("mapreduce.job.complete.cancel.delegation.tokens",false);
-    cluster.restartClusterWithNewConfig(prop, confFile);
-    UtilsForTests.waitFor(1000);
-    conf = cluster.getJTClient().getProxy().getDaemonConf();
-    createInput(inputDir, conf);
-  }
-
-  @AfterClass
-  public static void after() throws Exception {
-    cleanup(inputDir, conf);
-    cleanup(outputDir, conf);
-    cluster.tearDown();
-    cluster.restart();
-  }
-  /**
-   * Verify the job status whether it is succeed or not when 
-   * lost task tracker is alive before the timeout.
-   * @throws IOException if an I/O error occurs.
-   */
-  @Test
-  public void testJobStatusOfLostTaskTracker1() throws
-      Exception{
-    String testName = "LTT1";
-    setupJobAndRun();
-    JobStatus jStatus = verifyLostTaskTrackerJobStatus(testName);    
-    Assert.assertEquals("Job has not been succeeded...", 
-         JobStatus.SUCCEEDED, jStatus.getRunState());
-  }
-  
-  /**
-   * Verify the job status whether it is succeeded or not when 
-   * the lost task trackers time out for all four attempts of a task. 
-   * @throws IOException if an I/O error occurs.
-   */
-  @Test
-  public void testJobStatusOfLostTracker2()  throws 
-      Exception {
-    String testName = "LTT2";
-    setupJobAndRun();
-    JobStatus jStatus = verifyLostTaskTrackerJobStatus(testName);
-    Assert.assertEquals("Job has not been failed...", 
-            JobStatus.SUCCEEDED, jStatus.getRunState());
-  }
-
-  private void setupJobAndRun() throws IOException { 
-    SleepJob job = new SleepJob();
-    job.setConf(conf);
-    conf = job.setupJobConf(3, 1, 60000, 100, 60000, 100);
-    JobConf jobConf = new JobConf(conf);
-    cleanup(outputDir, conf);
-    jtClient = cluster.getJTClient();
-    JobClient client = jtClient.getClient();
-    wovenClient = cluster.getJTClient().getProxy();
-    RunningJob runJob = client.submitJob(jobConf);
-    jID = runJob.getID();
-    jInfo = wovenClient.getJobInfo(jID);
-    Assert.assertNotNull("Job information is null",jInfo);
-    Assert.assertTrue("Job has not been started for 1 min.", 
-        jtClient.isJobStarted(jID));
-    JobStatus jobStatus = jInfo.getStatus();
-    // Make sure that job should run and completes 40%. 
-    while (jobStatus.getRunState() != JobStatus.RUNNING && 
-      jobStatus.mapProgress() < 0.4f) {
-      UtilsForTests.waitFor(100);
-      jobStatus = wovenClient.getJobInfo(jID).getStatus();
-    }
-  }
-  
-  private JobStatus verifyLostTaskTrackerJobStatus(String testName) 
-      throws IOException{
-    TaskInfo taskInfo = null;
-    TaskID tID = null;
-    String[] taskTrackers = null;
-    TaskInfo[] taskInfos = wovenClient.getTaskInfo(jID);
-    for (TaskInfo taskinfo : taskInfos) {
-      if (!taskinfo.isSetupOrCleanup()) {
-        taskInfo = taskinfo;
-        break;
-      }
-    }
-    Assert.assertTrue("Task has not been started for 1 min.",
-            jtClient.isTaskStarted(taskInfo));
-    tID = TaskID.downgrade(taskInfo.getTaskID());
-    TTClient ttClient = getTTClientIns(taskInfo);
-    int counter = 0;
-    while (counter < 30) {
-      if (ttClient != null) {
-        break;
-      }else{
-         taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());  
-         ttClient = getTTClientIns(taskInfo); 
-      }
-      counter ++;
-    }
-    Assert.assertNotNull("TaskTracker has not been found",ttClient);
-    if (testName.equals("LTT1")) {
-        ttClient.kill();
-        waitForTTStop(ttClient);
-        UtilsForTests.waitFor(20000);
-        ttClient.start();
-        waitForTTStart(ttClient);
-    } else {
-       int index = 0 ;
-       while(index++ < 4 ) {
-           ttClient.kill();
-           waitForTTStop(ttClient);
-           UtilsForTests.waitFor(40000);
-           ttClient.start();
-           waitForTTStart(ttClient);
-           taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
-           ttClient = getTTClientIns(taskInfo);
-           counter = 0;
-           while (counter < 30) {
-             if (ttClient != null) {
-               break;
-             }else{
-                taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());  
-                ttClient = getTTClientIns(taskInfo); 
-             }
-             counter ++;
-           }
-           Assert.assertNotNull("TaskTracker has not been found",ttClient);
-           LOG.info("Task killed attempts:" + 
-               taskInfo.numKilledAttempts());
-       }
-       Assert.assertEquals("Task killed attempts are not matched ",
-           4, taskInfo.numKilledAttempts());
-    }
-    LOG.info("Waiting till the job is completed...");
-    while (!jInfo.getStatus().isJobComplete()) {
-      UtilsForTests.waitFor(1000);
-      jInfo = wovenClient.getJobInfo(jID);
-    }
-    return jInfo.getStatus();
-  }
-
-  private TTClient getTTClientIns(TaskInfo taskInfo) throws IOException{
-    String [] taskTrackers = taskInfo.getTaskTrackers();
-    int counter = 0;
-    TTClient ttClient = null;
-    while (counter < 60) {
-      if (taskTrackers.length != 0) {
-        break;
-      }
-      UtilsForTests.waitFor(100);
-      taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
-      taskTrackers = taskInfo.getTaskTrackers();
-      counter ++;
-    }
-    if ( taskTrackers.length != 0) {
-      String hostName = taskTrackers[0].split("_")[1];
-      hostName = hostName.split(":")[0];
-      ttClient = cluster.getTTClient(hostName);
-    }
-    return ttClient;
-  }
-  private void waitForTTStart(TTClient ttClient) throws 
-     IOException {
-    LOG.debug(ttClient.getHostName() + " is waiting to come up.");
-    while (true) { 
-      try {
-        ttClient.ping();
-        LOG.info("TaskTracker : " + ttClient.getHostName() + " is pinging...");
-        break;
-      } catch (Exception exp) {
-        LOG.debug(ttClient.getHostName() + " is waiting to come up.");
-        UtilsForTests.waitFor(10000);
-      }
-    }
-  }
-  
-  private void waitForTTStop(TTClient ttClient) throws 
-     IOException {
-    LOG.info("Waiting for Tasktracker:" + ttClient.getHostName() 
-        + " to stop.....");
-    while (true) {
-      try {
-        ttClient.ping();
-        LOG.debug(ttClient.getHostName() +" is waiting state to stop.");
-        UtilsForTests.waitFor(10000);
-      } catch (Exception exp) {
-        LOG.info("TaskTracker : " + ttClient.getHostName() + " is stopped...");
-        break;
-      } 
-    }
-  }
-  
-  private static void cleanup(Path dir, Configuration conf) throws 
-      IOException {
-    FileSystem fs = dir.getFileSystem(conf);
-    fs.delete(dir, true);
-  }
-
-  private static void createInput(Path inDir, Configuration conf) throws 
-      IOException {
-    String input = "Hadoop is framework for data intensive distributed " 
-        + "applications.\nHadoop enables applications to" 
-        + " work with thousands of nodes.";
-    FileSystem fs = inDir.getFileSystem(conf);
-    if (!fs.mkdirs(inDir)) {
-      throw new IOException("Failed to create the input directory:" 
-          + inDir.toString());
-    }
-    fs.setPermission(inDir, new FsPermission(FsAction.ALL, 
-        FsAction.ALL, FsAction.ALL));
-    DataOutputStream file = fs.create(new Path(inDir, "data.txt"));
-    file.writeBytes(input);
-    file.close();
-  }
-}
+package org.apache.hadoop.mapred;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.examples.SleepJob;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.mapreduce.test.system.JTProtocol;
+import org.apache.hadoop.mapreduce.test.system.JobInfo;
+import org.apache.hadoop.mapreduce.test.system.MRCluster;
+import org.apache.hadoop.mapreduce.test.system.JTClient; 
+import org.apache.hadoop.mapreduce.test.system.TTClient;
+import org.apache.hadoop.mapreduce.test.system.TTProtocol;
+import org.apache.hadoop.mapreduce.test.system.TaskInfo;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+
+public class TestLostTaskTracker {
+  private static final Log LOG = LogFactory
+      .getLog(TestLostTaskTracker.class);
+  private static MRCluster cluster;
+  private static Configuration conf = new Configuration();
+  private static Path inputDir = new Path("input");
+  private static Path outputDir = new Path("output");
+  private static String confFile = "mapred-site.xml";
+  private JTProtocol wovenClient = null;
+  private JobID jID = null;
+  private JobInfo jInfo = null;
+  private JTClient jtClient = null;
+
+  @BeforeClass
+  public static void before() throws Exception {
+    String [] expExcludeList = {"java.net.ConnectException",
+        "java.io.IOException"};
+    cluster = MRCluster.createCluster(conf);
+    cluster.setExcludeExpList(expExcludeList);
+    cluster.setUp();
+    Hashtable<String,Object> prop = new Hashtable<String,Object>();
+    prop.put("mapred.tasktracker.expiry.interval",30000L);
+    prop.put("mapreduce.job.complete.cancel.delegation.tokens",false);
+    cluster.restartClusterWithNewConfig(prop, confFile);
+    UtilsForTests.waitFor(1000);
+    conf = cluster.getJTClient().getProxy().getDaemonConf();
+    createInput(inputDir, conf);
+  }
+
+  @AfterClass
+  public static void after() throws Exception {
+    cleanup(inputDir, conf);
+    cleanup(outputDir, conf);
+    cluster.tearDown();
+    cluster.restart();
+  }
+  /**
+   * Verify the job status whether it is succeed or not when 
+   * lost task tracker is alive before the timeout.
+   * @throws IOException if an I/O error occurs.
+   */
+  @Test
+  public void testJobStatusOfLostTaskTracker1() throws
+      Exception{
+    String testName = "LTT1";
+    setupJobAndRun();
+    JobStatus jStatus = verifyLostTaskTrackerJobStatus(testName);    
+    Assert.assertEquals("Job has not been succeeded...", 
+         JobStatus.SUCCEEDED, jStatus.getRunState());
+  }
+  
+  /**
+   * Verify the job status whether it is succeeded or not when 
+   * the lost task trackers time out for all four attempts of a task. 
+   * @throws IOException if an I/O error occurs.
+   */
+  @Test
+  public void testJobStatusOfLostTracker2()  throws 
+      Exception {
+    String testName = "LTT2";
+    setupJobAndRun();
+    JobStatus jStatus = verifyLostTaskTrackerJobStatus(testName);
+    Assert.assertEquals("Job has not been failed...", 
+            JobStatus.SUCCEEDED, jStatus.getRunState());
+  }
+
+  private void setupJobAndRun() throws IOException { 
+    SleepJob job = new SleepJob();
+    job.setConf(conf);
+    conf = job.setupJobConf(3, 1, 60000, 100, 60000, 100);
+    JobConf jobConf = new JobConf(conf);
+    cleanup(outputDir, conf);
+    jtClient = cluster.getJTClient();
+    JobClient client = jtClient.getClient();
+    wovenClient = cluster.getJTClient().getProxy();
+    RunningJob runJob = client.submitJob(jobConf);
+    jID = runJob.getID();
+    jInfo = wovenClient.getJobInfo(jID);
+    Assert.assertNotNull("Job information is null",jInfo);
+    Assert.assertTrue("Job has not been started for 1 min.", 
+        jtClient.isJobStarted(jID));
+    JobStatus jobStatus = jInfo.getStatus();
+    // Make sure that job should run and completes 40%. 
+    while (jobStatus.getRunState() != JobStatus.RUNNING && 
+      jobStatus.mapProgress() < 0.4f) {
+      UtilsForTests.waitFor(100);
+      jobStatus = wovenClient.getJobInfo(jID).getStatus();
+    }
+  }
+  
+  private JobStatus verifyLostTaskTrackerJobStatus(String testName) 
+      throws IOException{
+    TaskInfo taskInfo = null;
+    TaskID tID = null;
+    String[] taskTrackers = null;
+    TaskInfo[] taskInfos = wovenClient.getTaskInfo(jID);
+    for (TaskInfo taskinfo : taskInfos) {
+      if (!taskinfo.isSetupOrCleanup()) {
+        taskInfo = taskinfo;
+        break;
+      }
+    }
+    Assert.assertTrue("Task has not been started for 1 min.",
+            jtClient.isTaskStarted(taskInfo));
+    tID = TaskID.downgrade(taskInfo.getTaskID());
+    TTClient ttClient = getTTClientIns(taskInfo);
+    int counter = 0;
+    while (counter < 30) {
+      if (ttClient != null) {
+        break;
+      }else{
+         taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());  
+         ttClient = getTTClientIns(taskInfo); 
+      }
+      counter ++;
+    }
+    Assert.assertNotNull("TaskTracker has not been found",ttClient);
+    if (testName.equals("LTT1")) {
+        ttClient.kill();
+        waitForTTStop(ttClient);
+        UtilsForTests.waitFor(20000);
+        ttClient.start();
+        waitForTTStart(ttClient);
+    } else {
+       int index = 0 ;
+       while(index++ < 4 ) {
+           ttClient.kill();
+           waitForTTStop(ttClient);
+           UtilsForTests.waitFor(40000);
+           ttClient.start();
+           waitForTTStart(ttClient);
+           taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
+           ttClient = getTTClientIns(taskInfo);
+           counter = 0;
+           while (counter < 30) {
+             if (ttClient != null) {
+               break;
+             }else{
+                taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());  
+                ttClient = getTTClientIns(taskInfo); 
+             }
+             counter ++;
+           }
+           Assert.assertNotNull("TaskTracker has not been found",ttClient);
+           LOG.info("Task killed attempts:" + 
+               taskInfo.numKilledAttempts());
+       }
+       Assert.assertEquals("Task killed attempts are not matched ",
+           4, taskInfo.numKilledAttempts());
+    }
+    LOG.info("Waiting till the job is completed...");
+    while (!jInfo.getStatus().isJobComplete()) {
+      UtilsForTests.waitFor(1000);
+      jInfo = wovenClient.getJobInfo(jID);
+    }
+    return jInfo.getStatus();
+  }
+
+  private TTClient getTTClientIns(TaskInfo taskInfo) throws IOException{
+    String [] taskTrackers = taskInfo.getTaskTrackers();
+    int counter = 0;
+    TTClient ttClient = null;
+    while (counter < 60) {
+      if (taskTrackers.length != 0) {
+        break;
+      }
+      UtilsForTests.waitFor(100);
+      taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
+      taskTrackers = taskInfo.getTaskTrackers();
+      counter ++;
+    }
+    if ( taskTrackers.length != 0) {
+      String hostName = taskTrackers[0].split("_")[1];
+      hostName = hostName.split(":")[0];
+      ttClient = cluster.getTTClient(hostName);
+    }
+    return ttClient;
+  }
+  private void waitForTTStart(TTClient ttClient) throws 
+     IOException {
+    LOG.debug(ttClient.getHostName() + " is waiting to come up.");
+    while (true) { 
+      try {
+        ttClient.ping();
+        LOG.info("TaskTracker : " + ttClient.getHostName() + " is pinging...");
+        break;
+      } catch (Exception exp) {
+        LOG.debug(ttClient.getHostName() + " is waiting to come up.");
+        UtilsForTests.waitFor(10000);
+      }
+    }
+  }
+  
+  private void waitForTTStop(TTClient ttClient) throws 
+     IOException {
+    LOG.info("Waiting for Tasktracker:" + ttClient.getHostName() 
+        + " to stop.....");
+    while (true) {
+      try {
+        ttClient.ping();
+        LOG.debug(ttClient.getHostName() +" is waiting state to stop.");
+        UtilsForTests.waitFor(10000);
+      } catch (Exception exp) {
+        LOG.info("TaskTracker : " + ttClient.getHostName() + " is stopped...");
+        break;
+      } 
+    }
+  }
+  
+  private static void cleanup(Path dir, Configuration conf) throws 
+      IOException {
+    FileSystem fs = dir.getFileSystem(conf);
+    fs.delete(dir, true);
+  }
+
+  private static void createInput(Path inDir, Configuration conf) throws 
+      IOException {
+    String input = "Hadoop is framework for data intensive distributed " 
+        + "applications.\nHadoop enables applications to" 
+        + " work with thousands of nodes.";
+    FileSystem fs = inDir.getFileSystem(conf);
+    if (!fs.mkdirs(inDir)) {
+      throw new IOException("Failed to create the input directory:" 
+          + inDir.toString());
+    }
+    fs.setPermission(inDir, new FsPermission(FsAction.ALL, 
+        FsAction.ALL, FsAction.ALL));
+    DataOutputStream file = fs.create(new Path(inDir, "data.txt"));
+    file.writeBytes(input);
+    file.close();
+  }
+}

Modified: hadoop/common/branches/branch-1-win/src/winutils/tests/test-all.bat
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/tests/test-all.bat?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/tests/test-all.bat (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/tests/test-all.bat Fri Oct 12 04:50:05 2012
@@ -1,19 +1,19 @@
-:: 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.
-::
-@echo off
-call test-winutils-basics
-call test-winutils-chown
-call test-winutils-chmod
+:: 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.
+::
+@echo off
+call test-winutils-basics
+call test-winutils-chown
+call test-winutils-chmod

Modified: hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-basics.bat
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-basics.bat?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-basics.bat (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-basics.bat Fri Oct 12 04:50:05 2012
@@ -1,95 +1,95 @@
-:: 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.
-::
-@echo off
-echo Test most basic security settings are working
-setlocal
-set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
-set TESTDIR=winutils-test
-
-:: Setup test directory
-::
-if not exist %TESTDIR% md %TESTDIR%
-pushd %TESTDIR%
-
-:: Test cases
-::
-echo Test case 1:
-::  - Create a file.
-::  - Change mode to 377 so owner does not have read permission.
-::  - Verify the owner truly does not have the permissions to read.
-if exist a goto Failure
-type NUL>a
-%WINUTILS% chmod 377 a
-if not %ERRORLEVEL% == 0 goto Failure
-type a
-if %ERRORLEVEL% == 0 goto Failure
-del a
-if not %ERRORLEVEL% == 0 goto Failure
-echo passed.
-
-echo Test case 2:
-::  - Create a file.
-::  - Change mode to 577 so owner does not have write permission.
-::  - Verify the owner truly does not have the permissions to write.
-if exist a goto Failure
-type NUL>a
-%WINUTILS% chmod 577 a
-if not %ERRORLEVEL% == 0 goto Failure
-cmd /C "echo a>>a"
-if %ERRORLEVEL% == 0 goto Failure
-del a
-if not %ERRORLEVEL% == 0 goto Failure
-echo passed.
-
-echo Test case 3:
-::  - Copy WINUTILS to a new executable file, a.exe.
-::  - Change mode to 677 so owner does not have execute permission.
-::  - Verify the owner truly does not have the permissions to execute the file.
-if exist a.exe goto Failure
-copy %WINUTILS% a.exe >NUL
-%WINUTILS% chmod 677 a.exe
-if not %ERRORLEVEL% == 0 goto Failure
-.\a.exe ls
-if %ERRORLEVEL% == 0 goto Failure
-del a.exe
-if not %ERRORLEVEL% == 0 goto Failure
-echo passed.
-
-
-:: Cleanup
-::
-popd
-rd %TESTDIR%
-goto Success
-
-
-:: -----------------------------------------------------------------------------
-:: -- Function section starts below here
-:: -----------------------------------------------------------------------------
-
-::  Failure
-::  - Report test failure
-::
-:Failure
-echo Test failed.
-exit /B 1
-
-::  Success
-::  - Report test success
-::
-:Success
-echo Test succeeded.
-exit /B 0
+:: 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.
+::
+@echo off
+echo Test most basic security settings are working
+setlocal
+set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
+set TESTDIR=winutils-test
+
+:: Setup test directory
+::
+if not exist %TESTDIR% md %TESTDIR%
+pushd %TESTDIR%
+
+:: Test cases
+::
+echo Test case 1:
+::  - Create a file.
+::  - Change mode to 377 so owner does not have read permission.
+::  - Verify the owner truly does not have the permissions to read.
+if exist a goto Failure
+type NUL>a
+%WINUTILS% chmod 377 a
+if not %ERRORLEVEL% == 0 goto Failure
+type a
+if %ERRORLEVEL% == 0 goto Failure
+del a
+if not %ERRORLEVEL% == 0 goto Failure
+echo passed.
+
+echo Test case 2:
+::  - Create a file.
+::  - Change mode to 577 so owner does not have write permission.
+::  - Verify the owner truly does not have the permissions to write.
+if exist a goto Failure
+type NUL>a
+%WINUTILS% chmod 577 a
+if not %ERRORLEVEL% == 0 goto Failure
+cmd /C "echo a>>a"
+if %ERRORLEVEL% == 0 goto Failure
+del a
+if not %ERRORLEVEL% == 0 goto Failure
+echo passed.
+
+echo Test case 3:
+::  - Copy WINUTILS to a new executable file, a.exe.
+::  - Change mode to 677 so owner does not have execute permission.
+::  - Verify the owner truly does not have the permissions to execute the file.
+if exist a.exe goto Failure
+copy %WINUTILS% a.exe >NUL
+%WINUTILS% chmod 677 a.exe
+if not %ERRORLEVEL% == 0 goto Failure
+.\a.exe ls
+if %ERRORLEVEL% == 0 goto Failure
+del a.exe
+if not %ERRORLEVEL% == 0 goto Failure
+echo passed.
+
+
+:: Cleanup
+::
+popd
+rd %TESTDIR%
+goto Success
+
+
+:: -----------------------------------------------------------------------------
+:: -- Function section starts below here
+:: -----------------------------------------------------------------------------
+
+::  Failure
+::  - Report test failure
+::
+:Failure
+echo Test failed.
+exit /B 1
+
+::  Success
+::  - Report test success
+::
+:Success
+echo Test succeeded.
+exit /B 0

Modified: hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chmod.bat
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chmod.bat?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chmod.bat (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chmod.bat Fri Oct 12 04:50:05 2012
@@ -1,174 +1,174 @@
-:: 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.
-::
-@echo off
-echo Test various chmod operations
-setlocal
-set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
-set TESTDIR=winutils-test
-
-:: Setup test directory
-::
-if not exist %TESTDIR% md %TESTDIR%
-pushd %TESTDIR%
-
-:: Test cases
-::
-echo Test case 1:
-call:TestChmod "7" "------rwx"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 2:
-call:TestChmod "70" "---rwx---"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 3:
-call:TestChmod "u-x,g+r,o=g" "rw-r--r--"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 4:
-call:TestChmod "u-x,g+rw" "rw-rw----"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 5:
-call:TestChmod "u-x,g+rwx-x,o=u" "rw-rw-rw-"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 6:
-call:TestChmodR "755" "rwxr-xr-x" "rwxr-xr-x"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 7:
-call:TestChmodR "u-x,g+r,o=g" "rw-r--r--" "rw-r--r--"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 8:
-call:TestChmodR "u-x,g+rw" "rw-rw----" "rw-rw----"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 9:
-call:TestChmodR "u-x,g+rwx-x,o=u" "rw-rw-rw-" "rw-rw-rw-"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 10:
-call:TestChmodR "a+rX" "rw-r--r--" "rwxr-xr-x"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-echo Test case 11:
-call:TestChmod "+" "rwx------"
-if %ERRORLEVEL% neq 0 goto Failure
-echo passed.
-
-:: Cleanup
-::
-popd
-rd %TESTDIR%
-goto Success
-
-
-:: -----------------------------------------------------------------------------
-:: -- Function section starts below here
-:: -----------------------------------------------------------------------------
-
-
-::  TestChmod
-::  - Test 'chmod' mode or octal mode string of a single file
-::  - The new permission will be compared with the expected result
-::
-:TestChmod :: [mode|octal mode] [expected permission]
-if exist a exit /B 1
-type NUL>a
-%WINUTILS% chmod 700 a
-%WINUTILS% chmod %~1 a
-call:CmpPerm "a" %~2
-if not %ERRORLEVEL% == 0 exit /B 1
-del a
-exit /B 0
-
-
-::  TestChmodR
-::  - Test 'chmod' mode or octal mode string with recursive option
-::  - The new permission will be compared with the expected results
-::  - The permissions could be different due to 'X' in mode string
-::
-:TestChmodR :: [mode|octal mode] [expected permission] [expected permission x]
-if exist a exit /B 1
-md a
-%WINUTILS% chmod 700 a
-type NUL>a\a
-%WINUTILS% chmod 600 a\a
-md a\b
-%WINUTILS% chmod 700 a\b
-md a\b\a
-%WINUTILS% chmod 700 a\b\a
-type NUL>a\b\b
-%WINUTILS% chmod 600 a\b\b
-type NUL>a\b\x
-%WINUTILS% chmod u+x a\b\x
-
-%WINUTILS% chmod -R %~1 a
-
-call:CmpPerm "a" %~3
-if not %ERRORLEVEL% == 0 exit /B 1
-call:CmpPerm "a\a" %~2
-if not %ERRORLEVEL% == 0 exit /B 1
-call:CmpPerm "a\b" %~3
-if not %ERRORLEVEL% == 0 exit /B 1
-call:CmpPerm "a\b\a" %~3
-if not %ERRORLEVEL% == 0 exit /B 1
-call:CmpPerm "a\b\b" %~2
-if not %ERRORLEVEL% == 0 exit /B 1
-call:CmpPerm "a\b\x" %~3
-if not %ERRORLEVEL% == 0 exit /B 1
-
-rd /S /Q a
-exit /B 0
-
-
-::  CmpPerm
-::  - Compare file permission against given permission
-::  - Use 'ls' to get the new permission
-::  - Exit with errorlevel > 0 on failure
-::
-:CmpPerm :: [file] [perm]
-for /F "tokens=1" %%A in ('call %WINUTILS% ls %~1') do set PERM=%%A
-if not %ERRORLEVEL% == 0 exit /B 1
-if not %PERM:~-9%==%~2 exit /B 1
-exit /B 0 
-
-
-::  Failure
-::  - Report test failure
-::
-:Failure
-echo Test failed.
-exit /B 1
-
-::  Success
-::  - Report test success
-::
-:Success
-echo Test succeeded.
-exit /B 0
+:: 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.
+::
+@echo off
+echo Test various chmod operations
+setlocal
+set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
+set TESTDIR=winutils-test
+
+:: Setup test directory
+::
+if not exist %TESTDIR% md %TESTDIR%
+pushd %TESTDIR%
+
+:: Test cases
+::
+echo Test case 1:
+call:TestChmod "7" "------rwx"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 2:
+call:TestChmod "70" "---rwx---"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 3:
+call:TestChmod "u-x,g+r,o=g" "rw-r--r--"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 4:
+call:TestChmod "u-x,g+rw" "rw-rw----"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 5:
+call:TestChmod "u-x,g+rwx-x,o=u" "rw-rw-rw-"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 6:
+call:TestChmodR "755" "rwxr-xr-x" "rwxr-xr-x"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 7:
+call:TestChmodR "u-x,g+r,o=g" "rw-r--r--" "rw-r--r--"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 8:
+call:TestChmodR "u-x,g+rw" "rw-rw----" "rw-rw----"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 9:
+call:TestChmodR "u-x,g+rwx-x,o=u" "rw-rw-rw-" "rw-rw-rw-"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 10:
+call:TestChmodR "a+rX" "rw-r--r--" "rwxr-xr-x"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+echo Test case 11:
+call:TestChmod "+" "rwx------"
+if %ERRORLEVEL% neq 0 goto Failure
+echo passed.
+
+:: Cleanup
+::
+popd
+rd %TESTDIR%
+goto Success
+
+
+:: -----------------------------------------------------------------------------
+:: -- Function section starts below here
+:: -----------------------------------------------------------------------------
+
+
+::  TestChmod
+::  - Test 'chmod' mode or octal mode string of a single file
+::  - The new permission will be compared with the expected result
+::
+:TestChmod :: [mode|octal mode] [expected permission]
+if exist a exit /B 1
+type NUL>a
+%WINUTILS% chmod 700 a
+%WINUTILS% chmod %~1 a
+call:CmpPerm "a" %~2
+if not %ERRORLEVEL% == 0 exit /B 1
+del a
+exit /B 0
+
+
+::  TestChmodR
+::  - Test 'chmod' mode or octal mode string with recursive option
+::  - The new permission will be compared with the expected results
+::  - The permissions could be different due to 'X' in mode string
+::
+:TestChmodR :: [mode|octal mode] [expected permission] [expected permission x]
+if exist a exit /B 1
+md a
+%WINUTILS% chmod 700 a
+type NUL>a\a
+%WINUTILS% chmod 600 a\a
+md a\b
+%WINUTILS% chmod 700 a\b
+md a\b\a
+%WINUTILS% chmod 700 a\b\a
+type NUL>a\b\b
+%WINUTILS% chmod 600 a\b\b
+type NUL>a\b\x
+%WINUTILS% chmod u+x a\b\x
+
+%WINUTILS% chmod -R %~1 a
+
+call:CmpPerm "a" %~3
+if not %ERRORLEVEL% == 0 exit /B 1
+call:CmpPerm "a\a" %~2
+if not %ERRORLEVEL% == 0 exit /B 1
+call:CmpPerm "a\b" %~3
+if not %ERRORLEVEL% == 0 exit /B 1
+call:CmpPerm "a\b\a" %~3
+if not %ERRORLEVEL% == 0 exit /B 1
+call:CmpPerm "a\b\b" %~2
+if not %ERRORLEVEL% == 0 exit /B 1
+call:CmpPerm "a\b\x" %~3
+if not %ERRORLEVEL% == 0 exit /B 1
+
+rd /S /Q a
+exit /B 0
+
+
+::  CmpPerm
+::  - Compare file permission against given permission
+::  - Use 'ls' to get the new permission
+::  - Exit with errorlevel > 0 on failure
+::
+:CmpPerm :: [file] [perm]
+for /F "tokens=1" %%A in ('call %WINUTILS% ls %~1') do set PERM=%%A
+if not %ERRORLEVEL% == 0 exit /B 1
+if not %PERM:~-9%==%~2 exit /B 1
+exit /B 0 
+
+
+::  Failure
+::  - Report test failure
+::
+:Failure
+echo Test failed.
+exit /B 1
+
+::  Success
+::  - Report test success
+::
+:Success
+echo Test succeeded.
+exit /B 0

Modified: hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chown.bat
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chown.bat?rev=1397436&r1=1397435&r2=1397436&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chown.bat (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/tests/test-winutils-chown.bat Fri Oct 12 04:50:05 2012
@@ -1,95 +1,95 @@
-:: 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.
-::
-@echo off
-echo Test chown operations
-setlocal
-set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
-set TESTDIR=winutils-test
-
-:: Setup test directory
-::
-if not exist %TESTDIR% md %TESTDIR%
-pushd %TESTDIR%
-
-:: Get username
-::
-for /F "tokens=1" %%A in ('call whoami') do set USER=%%A
-
-:: Test cases
-::
-echo Test case 1:
-if exist a goto Failure
-type NUL>a
-%WINUTILS% chown %USER%:Administrators a
-if not %ERRORLEVEL% == 0 goto Failure
-call:CmpOwn "a" "%USER%" "BUILTIN\Administrators"
-if not %ERRORLEVEL% == 0 goto Failure
-del a
-if not %ERRORLEVEL% == 0 goto Failure
-echo passed.
-
-echo Test case 2:
-if exist a goto Failure
-type NUL>a
-%WINUTILS% chown %USER% a
-if not %ERRORLEVEL% == 0 goto Failure
-%WINUTILS% chown :Administrators a
-if not %ERRORLEVEL% == 0 goto Failure
-call:CmpOwn "a" "%USER%" "BUILTIN\Administrators"
-if not %ERRORLEVEL% == 0 goto Failure
-del a
-if not %ERRORLEVEL% == 0 goto Failure
-echo passed.
-
-
-:: Cleanup
-::
-popd
-rd %TESTDIR%
-goto Success
-
-:: -----------------------------------------------------------------------------
-:: -- Function section starts below here
-:: -----------------------------------------------------------------------------
-
-::  CmpOwn
-::  - Compare file ownership against expected owner
-::  - Use 'ls' to get the ownership
-::  - Exit with errorlevel > 0 on failure
-::
-:CmpOwn :: [file] [expected user owner] [expected group owner]
-for /F "tokens=3" %%A in ('call %WINUTILS% ls %~1') do set OWNER=%%A
-if not %ERRORLEVEL% == 0 exit /B 1
-for /F "tokens=4" %%A in ('call %WINUTILS% ls %~1') do set GROUP=%%A
-if not %ERRORLEVEL% == 0 exit /B 1
-if /I not %OWNER%==%~2 exit /B 1
-if /I not %GROUP%==%~3 exit /B 1
-exit /B 0 
-
-
-::  Failure
-::  - Report test failure
-::
-:Failure
-echo Test failed.
-exit /B 1
-
-::  Success
-::  - Report test success
-::
-:Success
-echo Test succeeded.
-exit /B 0
+:: 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.
+::
+@echo off
+echo Test chown operations
+setlocal
+set WINUTILS="%HADOOP_HOME%\bin\winutils.exe"
+set TESTDIR=winutils-test
+
+:: Setup test directory
+::
+if not exist %TESTDIR% md %TESTDIR%
+pushd %TESTDIR%
+
+:: Get username
+::
+for /F "tokens=1" %%A in ('call whoami') do set USER=%%A
+
+:: Test cases
+::
+echo Test case 1:
+if exist a goto Failure
+type NUL>a
+%WINUTILS% chown %USER%:Administrators a
+if not %ERRORLEVEL% == 0 goto Failure
+call:CmpOwn "a" "%USER%" "BUILTIN\Administrators"
+if not %ERRORLEVEL% == 0 goto Failure
+del a
+if not %ERRORLEVEL% == 0 goto Failure
+echo passed.
+
+echo Test case 2:
+if exist a goto Failure
+type NUL>a
+%WINUTILS% chown %USER% a
+if not %ERRORLEVEL% == 0 goto Failure
+%WINUTILS% chown :Administrators a
+if not %ERRORLEVEL% == 0 goto Failure
+call:CmpOwn "a" "%USER%" "BUILTIN\Administrators"
+if not %ERRORLEVEL% == 0 goto Failure
+del a
+if not %ERRORLEVEL% == 0 goto Failure
+echo passed.
+
+
+:: Cleanup
+::
+popd
+rd %TESTDIR%
+goto Success
+
+:: -----------------------------------------------------------------------------
+:: -- Function section starts below here
+:: -----------------------------------------------------------------------------
+
+::  CmpOwn
+::  - Compare file ownership against expected owner
+::  - Use 'ls' to get the ownership
+::  - Exit with errorlevel > 0 on failure
+::
+:CmpOwn :: [file] [expected user owner] [expected group owner]
+for /F "tokens=3" %%A in ('call %WINUTILS% ls %~1') do set OWNER=%%A
+if not %ERRORLEVEL% == 0 exit /B 1
+for /F "tokens=4" %%A in ('call %WINUTILS% ls %~1') do set GROUP=%%A
+if not %ERRORLEVEL% == 0 exit /B 1
+if /I not %OWNER%==%~2 exit /B 1
+if /I not %GROUP%==%~3 exit /B 1
+exit /B 0 
+
+
+::  Failure
+::  - Report test failure
+::
+:Failure
+echo Test failed.
+exit /B 1
+
+::  Success
+::  - Report test success
+::
+:Success
+echo Test succeeded.
+exit /B 0