Author: suresh
Date: Sat Apr 24 07:29:06 2010
New Revision: 937599
URL: http://svn.apache.org/viewvc?rev=937599&view=rev
Log:
HDFS-1099. Add test for umask backward compatibility. Contributed by Suresh
Srinivas.
Modified:
hadoop/hdfs/trunk/CHANGES.txt
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
Modified: hadoop/hdfs/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=937599&r1=937598&r2=937599&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Sat Apr 24 07:29:06 2010
@@ -140,6 +140,8 @@ Trunk (unreleased changes)
HDFS-1083. Update TestHDFSCLI not to expect exception class name
in error messages. (suresh)
+ HDFS-1099. Add test for umask backward compatibility. (suresh)
+
OPTIMIZATIONS
HDFS-946. NameNode should not return full path name when lisitng a
Modified:
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
URL:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java?rev=937599&r1=937598&r2=937599&view=diff
==============================================================================
---
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
(original)
+++
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
Sat Apr 24 07:29:06 2010
@@ -61,6 +61,39 @@ public class TestPermission extends Test
return s.getPermission();
}
+ /**
+ * Tests backward compatibility. Configuration can be
+ * either set with old param dfs.umask that takes decimal umasks
+ * or dfs.umaskmode that takes symbolic or octal umask.
+ */
+ public void testBackwardCompatibility() {
+ // Test 1 - old configuration key with decimal
+ // umask value should be handled when set using
+ // FSPermission.setUMask() API
+ FsPermission perm = new FsPermission((short)18);
+ Configuration conf = new Configuration();
+ FsPermission.setUMask(conf, perm);
+ assertEquals(18, FsPermission.getUMask(conf).toShort());
+
+ // Test 2 - old configuration key set with decimal
+ // umask value should be handled
+ perm = new FsPermission((short)18);
+ conf = new Configuration();
+ conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
+ assertEquals(18, FsPermission.getUMask(conf).toShort());
+
+ // Test 3 - old configuration key overrides the new one
+ conf = new Configuration();
+ conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
+ conf.set(FsPermission.UMASK_LABEL, "000");
+ assertEquals(18, FsPermission.getUMask(conf).toShort());
+
+ // Test 4 - new configuration key is handled
+ conf = new Configuration();
+ conf.set(FsPermission.UMASK_LABEL, "022");
+ assertEquals(18, FsPermission.getUMask(conf).toShort());
+ }
+
public void testCreate() throws Exception {
Configuration conf = new HdfsConfiguration();
conf.setBoolean(DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY, true);