瀏覽代碼

svn merge -c 1478524 from branch-1 for HADOOP-9543. TestFsShellReturnCode may fail if the hardcoded user "admin" is not a valid user in the loacl OS.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2@1478525 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 12 年之前
父節點
當前提交
409de8ec51
共有 2 個文件被更改,包括 7 次插入2 次删除
  1. 3 0
      CHANGES.txt
  2. 4 2
      src/test/org/apache/hadoop/fs/TestFsShellReturnCode.java

+ 3 - 0
CHANGES.txt

@@ -622,6 +622,9 @@ Release 1.2.0 - 2013.04.16
     HDFS-3817. Avoid printing stack information for SafeModeException.
     HDFS-3817. Avoid printing stack information for SafeModeException.
     (Brandon Li via suresh)
     (Brandon Li via suresh)
 
 
+    HADOOP-9543. TestFsShellReturnCode may fail if the hardcoded user "admin"
+    is not a valid user in the loacl OS.  (szetszwo)
+
 Release 1.1.2 - 2013.01.30
 Release 1.1.2 - 2013.01.30
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 4 - 2
src/test/org/apache/hadoop/fs/TestFsShellReturnCode.java

@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.Test;
 
 
@@ -150,7 +151,8 @@ public class TestFsShellReturnCode {
     assertTrue(fileSys.exists(p1));
     assertTrue(fileSys.exists(p1));
 
 
     // Test 1: exit code for chown on existing file is 0
     // Test 1: exit code for chown on existing file is 0
-    String argv[] = { "-chown", "admin", f1 };
+    final String username = UserGroupInformation.getCurrentUser().getShortUserName();
+    String argv[] = { "-chown", username, f1 };
     verify(fs, "-chown", argv, 1, fsShell, 0);
     verify(fs, "-chown", argv, 1, fsShell, 0);
 
 
     // Test 2: exit code for chown on non-existing path is 1
     // Test 2: exit code for chown on non-existing path is 1
@@ -170,7 +172,7 @@ public class TestFsShellReturnCode {
     assertTrue(fileSys.exists(p6));
     assertTrue(fileSys.exists(p6));
 
 
     // Test 4: exit code for chown on existing path with globbed input is 0
     // Test 4: exit code for chown on existing path with globbed input is 0
-    String argv4[] = { "-chown", "admin", f7 };
+    String argv4[] = { "-chown", username, f7 };
     verify(fs, "-chown", argv4, 1, fsShell, 0);
     verify(fs, "-chown", argv4, 1, fsShell, 0);
 
 
   }
   }