Пример #1
0
 public virtual void TestCreateDelete()
 {
     // Create file
     fileContextTestHelper.CreateFileNonRecursive(fc, "/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/foo")));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "foo")));
     // Create file with recursive dir
     fileContextTestHelper.CreateFile(fc, "/newDir/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/newDir/foo"
                                                           )));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "newDir/foo")));
     // Delete the created file
     Assert.True(fc.Delete(new Path("/newDir/foo"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/newDir/foo"
                                                                              )));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "newDir/foo")));
     // Create file with a 2 component dirs recursively
     fileContextTestHelper.CreateFile(fc, "/newDir/newDir2/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/newDir/newDir2/foo"
                                                           )));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "newDir/newDir2/foo")));
     // Delete the created file
     Assert.True(fc.Delete(new Path("/newDir/newDir2/foo"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/newDir/newDir2/foo"
                                                                              )));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "newDir/newDir2/foo")));
 }
Пример #2
0
 public virtual void SetUp()
 {
     InitializeTargetTestRoot();
     // Make  user and data dirs - we creates links to them in the mount table
     fcTarget.Mkdir(new Path(targetTestRoot, "user"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "data"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "dir2"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "dir3"), FileContext.DefaultPerm, true);
     FileContextTestHelper.CreateFile(fcTarget, new Path(targetTestRoot, "aFile"));
     // Now we use the mount fs to set links to user and dir
     // in the test root
     // Set up the defaultMT in the config with our mount point links
     conf = new Configuration();
     ConfigUtil.AddLink(conf, "/targetRoot", targetTestRoot.ToUri());
     ConfigUtil.AddLink(conf, "/user", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/user2", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/data", new Path(targetTestRoot, "data").ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/linkToDir2", new Path(targetTestRoot, "dir2"
                                                                  ).ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/internalDir2/linkToDir3", new Path(targetTestRoot
                                                                               , "dir3").ToUri());
     ConfigUtil.AddLink(conf, "/danglingLink", new Path(targetTestRoot, "missingTarget"
                                                        ).ToUri());
     ConfigUtil.AddLink(conf, "/linkToAFile", new Path(targetTestRoot, "aFile").ToUri(
                            ));
     fcView = FileContext.GetFileContext(FsConstants.ViewfsUri, conf);
 }
Пример #3
0
        public virtual void TestGetBlockLocations()
        {
            Path targetFilePath = new Path(targetTestRoot, "data/largeFile");

            FileContextTestHelper.CreateFile(fcTarget, targetFilePath, 10, 1024);
            Path viewFilePath = new Path("/data/largeFile");

            FileContextTestHelper.CheckFileStatus(fcView, viewFilePath.ToString(), FileContextTestHelper.FileType
                                                  .isFile);
            BlockLocation[] viewBL = fcView.GetFileBlockLocations(viewFilePath, 0, 10240 + 100
                                                                  );
            Assert.Equal(SupportsBlocks ? 10 : 1, viewBL.Length);
            BlockLocation[] targetBL = fcTarget.GetFileBlockLocations(targetFilePath, 0, 10240
                                                                      + 100);
            CompareBLs(viewBL, targetBL);
            // Same test but now get it via the FileStatus Parameter
            fcView.GetFileBlockLocations(viewFilePath, 0, 10240 + 100);
            targetBL = fcTarget.GetFileBlockLocations(targetFilePath, 0, 10240 + 100);
            CompareBLs(viewBL, targetBL);
        }
Пример #4
0
        public virtual void TestOperationsThroughMountLinks()
        {
            // Create file
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/user/foo");
            Assert.True("Create file should be file", FileContextTestHelper.IsFile
                            (fcView, new Path("/user/foo")));
            Assert.True("Target of created file should be type file", FileContextTestHelper.IsFile
                            (fcTarget, new Path(targetTestRoot, "user/foo")));
            // Delete the created file
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/foo"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("File should not exist after delete", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/foo")));
            NUnit.Framework.Assert.IsFalse("Target File should not exist after delete", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/foo")));
            // Create file with a 2 component dirs
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/internalDir/linkToDir2/foo"
                                                         );
            Assert.True("Created file should be type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/linkToDir2/foo")));
            Assert.True("Target of created file should be type file", FileContextTestHelper.IsFile
                            (fcTarget, new Path(targetTestRoot, "dir2/foo")));
            // Delete the created file
            Assert.True("Delete should suceed", fcView.Delete(new Path("/internalDir/linkToDir2/foo"
                                                                       ), false));
            NUnit.Framework.Assert.IsFalse("File should not exist after deletion", FileContextTestHelper.Exists
                                               (fcView, new Path("/internalDir/linkToDir2/foo")));
            NUnit.Framework.Assert.IsFalse("Target should not exist after deletion", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "dir2/foo")));
            // Create file with a 3 component dirs
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/internalDir/internalDir2/linkToDir3/foo"
                                                         );
            Assert.True("Created file should be of type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
            Assert.True("Target of created file should also be type file",
                        FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot, "dir3/foo")));
            // Recursive Create file with missing dirs
            fileContextTestHelper.CreateFile(fcView, "/internalDir/linkToDir2/missingDir/miss2/foo"
                                             );
            Assert.True("Created file should be of type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
            Assert.True("Target of created file should also be type file",
                        FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot, "dir2/missingDir/miss2/foo"
                                                                        )));
            // Delete the created file
            Assert.True("Delete should succeed", fcView.Delete(new Path("/internalDir/internalDir2/linkToDir3/foo"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
            NUnit.Framework.Assert.IsFalse("Target of deleted file should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "dir3/foo")));
            // mkdir
            fcView.Mkdir(fileContextTestHelper.GetTestRootPath(fcView, "/user/dirX"), FileContext
                         .DefaultPerm, false);
            Assert.True("New dir should be type dir", FileContextTestHelper.IsDir
                            (fcView, new Path("/user/dirX")));
            Assert.True("Target of new dir should be of type dir", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirX")));
            fcView.Mkdir(fileContextTestHelper.GetTestRootPath(fcView, "/user/dirX/dirY"), FileContext
                         .DefaultPerm, false);
            Assert.True("New dir should be type dir", FileContextTestHelper.IsDir
                            (fcView, new Path("/user/dirX/dirY")));
            Assert.True("Target of new dir should be of type dir", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirX/dirY")));
            // Delete the created dir
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/dirX/dirY"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirX/dirY")));
            NUnit.Framework.Assert.IsFalse("Deleted Target should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirX/dirY")));
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/dirX"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirX")));
            NUnit.Framework.Assert.IsFalse("Deleted Target should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirX")));
            // Rename a file
            fileContextTestHelper.CreateFile(fcView, "/user/foo");
            fcView.Rename(new Path("/user/foo"), new Path("/user/fooBar"));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/foo")));
            NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(targetTestRoot
                                                                                           , "user/foo")));
            Assert.True(FileContextTestHelper.IsFile(fcView, fileContextTestHelper
                                                     .GetTestRootPath(fcView, "/user/fooBar")));
            Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot
                                                                        , "user/fooBar")));
            fcView.Mkdir(new Path("/user/dirFoo"), FileContext.DefaultPerm, false);
            fcView.Rename(new Path("/user/dirFoo"), new Path("/user/dirFooBar"));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirFoo")));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist in target", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirFoo")));
            Assert.True("Renamed dest should  exist as dir", FileContextTestHelper.IsDir
                            (fcView, fileContextTestHelper.GetTestRootPath(fcView, "/user/dirFooBar")));
            Assert.True("Renamed dest should  exist as dir in target", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirFooBar")));
            // Make a directory under a directory that's mounted from the root of another FS
            fcView.Mkdir(new Path("/targetRoot/dirFoo"), FileContext.DefaultPerm, false);
            Assert.True(FileContextTestHelper.Exists(fcView, new Path("/targetRoot/dirFoo"
                                                                      )));
            bool dirFooPresent = false;
            RemoteIterator <FileStatus> dirContents = fcView.ListStatus(new Path("/targetRoot/"
                                                                                 ));

            while (dirContents.HasNext())
            {
                FileStatus fileStatus = dirContents.Next();
                if (fileStatus.GetPath().GetName().Equals("dirFoo"))
                {
                    dirFooPresent = true;
                }
            }
            Assert.True(dirFooPresent);
        }