Esempio n. 1
0
        /// <param name="fsTarget">- the target fs of the view fs.</param>
        /// <returns>return the ViewFS File context to be used for tests</returns>
        /// <exception cref="System.Exception"/>
        public static FileSystem SetupForViewFileSystem(Configuration conf, FileSystemTestHelper
                                                        fileSystemTestHelper, FileSystem fsTarget)
        {
            Path targetOfTests = fileSystemTestHelper.GetTestRootPath(fsTarget);

            // In case previous test was killed before cleanup
            fsTarget.Delete(targetOfTests, true);
            fsTarget.Mkdirs(targetOfTests);
            // Set up viewfs link for test dir as described above
            string testDir = fileSystemTestHelper.GetTestRootPath(fsTarget).ToUri().GetPath();

            LinkUpFirstComponents(conf, testDir, fsTarget, "test dir");
            // Set up viewfs link for home dir as described above
            SetUpHomeDir(conf, fsTarget);
            // the test path may be relative to working dir - we need to make that work:
            // Set up viewfs link for wd as described above
            string wdDir = fsTarget.GetWorkingDirectory().ToUri().GetPath();

            LinkUpFirstComponents(conf, wdDir, fsTarget, "working dir");
            FileSystem fsView = FileSystem.Get(FsConstants.ViewfsUri, conf);

            fsView.SetWorkingDirectory(new Path(wdDir));
            // in case testdir relative to wd.
            Org.Mortbay.Log.Log.Info("Working dir is: " + fsView.GetWorkingDirectory());
            return(fsView);
        }
Esempio n. 2
0
 public virtual void SetUp()
 {
     fsTarget = FileSystem.GetLocal(new Configuration());
     fsTarget.Mkdirs(new Path(fileSystemTestHelper.GetTestRootPath(fsTarget), "dir1"));
     conf   = ViewFileSystemTestSetup.CreateConfig();
     fsView = ViewFileSystemTestSetup.SetupForViewFileSystem(conf, fileSystemTestHelper
                                                             , fsTarget);
     conf.Set("fs.defaultFS", FsConstants.ViewfsUri.ToString());
 }
Esempio n. 3
0
        /// <summary>delete the test directory in the target  fs</summary>
        /// <exception cref="System.Exception"/>
        public static void TearDown(FileSystemTestHelper fileSystemTestHelper, FileSystem
                                    fsTarget)
        {
            Path targetOfTests = fileSystemTestHelper.GetTestRootPath(fsTarget);

            fsTarget.Delete(targetOfTests, true);
        }
Esempio n. 4
0
        public virtual void TestGetFileChecksum()
        {
            // Create two different files in HDFS
            fileSystemTestHelper.CreateFile(fHdfs, someFile);
            FileSystemTestHelper.CreateFile(fHdfs, fileSystemTestHelper.GetTestRootPath(fHdfs
                                                                                        , someFile + "other"), 1, 512);
            // Get checksum through ViewFS
            FileChecksum viewFSCheckSum = vfs.GetFileChecksum(new Path("/vfstmp/someFileForTestGetFileChecksum"
                                                                       ));
            // Get checksum through HDFS.
            FileChecksum hdfsCheckSum = fHdfs.GetFileChecksum(new Path(someFile));
            // Get checksum of different file in HDFS
            FileChecksum otherHdfsFileCheckSum = fHdfs.GetFileChecksum(new Path(someFile + "other"
                                                                                ));

            // Checksums of the same file (got through HDFS and ViewFS should be same)
            NUnit.Framework.Assert.AreEqual("HDFS and ViewFS checksums were not the same", viewFSCheckSum
                                            , hdfsCheckSum);
            // Checksum of different files should be different.
            NUnit.Framework.Assert.IsFalse("Some other HDFS file which should not have had the same "
                                           + "checksum as viewFS did!", viewFSCheckSum.Equals(otherHdfsFileCheckSum));
        }
 public virtual void TearDown()
 {
     fsTarget.Delete(fileSystemTestHelper.GetTestRootPath(fsTarget), true);
 }