Ejemplo n.º 1
0
        public virtual void TestStatistics()
        {
            URI fsUri = GetFsUri();

            FileSystem.Statistics stats = FileContext.GetStatistics(fsUri);
            Assert.Equal(0, stats.GetBytesRead());
            Path filePath = fileContextTestHelper.GetTestRootPath(fc, "file1");

            FileContextTestHelper.CreateFile(fc, filePath, numBlocks, blockSize);
            Assert.Equal(0, stats.GetBytesRead());
            VerifyWrittenBytes(stats);
            FSDataInputStream fstr = fc.Open(filePath);

            byte[] buf       = new byte[blockSize];
            int    bytesRead = fstr.Read(buf, 0, blockSize);

            fstr.Read(0, buf, 0, blockSize);
            Assert.Equal(blockSize, bytesRead);
            VerifyReadBytes(stats);
            VerifyWrittenBytes(stats);
            VerifyReadBytes(FileContext.GetStatistics(GetFsUri()));
            IDictionary <URI, FileSystem.Statistics> statsMap = FileContext.GetAllStatistics();
            URI exactUri = GetSchemeAuthorityUri();

            VerifyWrittenBytes(statsMap[exactUri]);
            fc.Delete(filePath, true);
        }
 public virtual void SetUp()
 {
     fileContextTestHelper = GetFileContextHelper();
     fc = GetFileContext();
     fc.Mkdir(fileContextTestHelper.GetTestRootPath(fc), FileContext.DefaultPerm, true
              );
 }
Ejemplo n.º 3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestSymlinkHdfsDisable()
        {
            Configuration conf = new HdfsConfiguration();

            // disable symlink resolution
            conf.SetBoolean(CommonConfigurationKeys.FsClientResolveRemoteSymlinksKey, false);
            // spin up minicluster, get dfs and filecontext
            MiniDFSCluster        cluster = new MiniDFSCluster.Builder(conf).Build();
            DistributedFileSystem dfs     = cluster.GetFileSystem();
            FileContext           fc      = FileContext.GetFileContext(cluster.GetURI(0), conf);
            // Create test files/links
            FileContextTestHelper helper = new FileContextTestHelper("/tmp/TestSymlinkHdfsDisable"
                                                                     );
            Path root   = helper.GetTestRootPath(fc);
            Path target = new Path(root, "target");
            Path link   = new Path(root, "link");

            DFSTestUtil.CreateFile(dfs, target, 4096, (short)1, unchecked ((int)(0xDEADDEAD)));
            fc.CreateSymlink(target, link, false);
            // Try to resolve links with FileSystem and FileContext
            try
            {
                fc.Open(link);
                NUnit.Framework.Assert.Fail("Expected error when attempting to resolve link");
            }
            catch (IOException e)
            {
                GenericTestUtils.AssertExceptionContains("resolution is disabled", e);
            }
            try
            {
                dfs.Open(link);
                NUnit.Framework.Assert.Fail("Expected error when attempting to resolve link");
            }
            catch (IOException e)
            {
                GenericTestUtils.AssertExceptionContains("resolution is disabled", e);
            }
        }
Ejemplo n.º 4
0
 public virtual void SetUp()
 {
     fc.SetUMask(WideOpenTestUmask);
     fc.Mkdir(fileContextTestHelper.GetTestRootPath(fc), FileContext.DefaultPerm, true
              );
 }
 public virtual void TearDown()
 {
     fc.Delete(fileContextTestHelper.GetTestRootPath(fc), true);
 }
Ejemplo n.º 6
0
 public virtual void TearDown()
 {
     fc.Delete(helper.GetTestRootPath(fc), true);
 }
Ejemplo n.º 7
0
 private Path GetTestRootPath(FileContext fc)
 {
     return(fileContextTestHelper.GetTestRootPath(fc));
 }