Beispiel #1
0
        public virtual 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);
            NUnit.Framework.Assert.AreEqual(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.DeprecatedUmaskLabel, "18");
            NUnit.Framework.Assert.AreEqual(18, FsPermission.GetUMask(conf).ToShort());
            // Test 3 - old configuration key overrides the new one
            conf = new Configuration();
            conf.Set(FsPermission.DeprecatedUmaskLabel, "18");
            conf.Set(FsPermission.UmaskLabel, "000");
            NUnit.Framework.Assert.AreEqual(18, FsPermission.GetUMask(conf).ToShort());
            // Test 4 - new configuration key is handled
            conf = new Configuration();
            conf.Set(FsPermission.UmaskLabel, "022");
            NUnit.Framework.Assert.AreEqual(18, FsPermission.GetUMask(conf).ToShort());
        }
Beispiel #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestLargeDirectory()
        {
            Configuration conf      = WebHdfsTestUtil.CreateConf();
            int           listLimit = 2;

            // force small chunking of directory listing
            conf.SetInt(DFSConfigKeys.DfsListLimit, listLimit);
            // force paths to be only owner-accessible to ensure ugi isn't changing
            // during listStatus
            FsPermission.SetUMask(conf, new FsPermission((short)0x3f));
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(3).Build();

            try
            {
                cluster.WaitActive();
                WebHdfsTestUtil.GetWebHdfsFileSystem(conf, WebHdfsFileSystem.Scheme).SetPermission
                    (new Path("/"), new FsPermission(FsAction.All, FsAction.All, FsAction.All));
                // trick the NN into not believing it's not the superuser so we can
                // tell if the correct user is used by listStatus
                UserGroupInformation.SetLoginUser(UserGroupInformation.CreateUserForTesting("not-superuser"
                                                                                            , new string[] { "not-supergroup" }));
                UserGroupInformation.CreateUserForTesting("me", new string[] { "my-group" }).DoAs
                    (new _PrivilegedExceptionAction_263(conf, listLimit));
            }
            finally
            {
                cluster.Shutdown();
            }
        }