public virtual void TestRmNonEmptyRootDirNonRecursive()
        {
            //extra sanity checks here to avoid support calls about complete loss of data
            SkipIfUnsupported(TestRootTestsEnabled);
            Path   root      = new Path("/");
            string touchfile = "/testRmNonEmptyRootDirNonRecursive";
            Path   file      = new Path(touchfile);

            ContractTestUtils.Touch(GetFileSystem(), file);
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            try
            {
                bool deleted = GetFileSystem().Delete(root, false);
                NUnit.Framework.Assert.Fail("non recursive delete should have raised an exception,"
                                            + " but completed with exit code " + deleted);
            }
            catch (IOException e)
            {
                //expected
                HandleExpectedException(e);
            }
            finally
            {
                GetFileSystem().Delete(file, false);
            }
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
        }
        public virtual void TestOpenReadZeroByteFile()
        {
            Describe("create & read a 0 byte file");
            Path path = Path("zero.txt");

            ContractTestUtils.Touch(GetFileSystem(), path);
            instream = GetFileSystem().Open(path);
            Assert.Equal(0, instream.GetPos());
            //expect initial read to fail
            int result = instream.Read();

            AssertMinusOne("initial byte read", result);
        }
 /// <exception cref="System.Exception"/>
 public override void Setup()
 {
     base.Setup();
     SkipIfUnsupported(SupportsConcat);
     //delete the test directory
     testPath     = Path("test");
     srcFile      = new Path(testPath, "small.txt");
     zeroByteFile = new Path(testPath, "zero.txt");
     target       = new Path(testPath, "target");
     byte[] block = ContractTestUtils.Dataset(TestFileLen, 0, 255);
     ContractTestUtils.CreateFile(GetFileSystem(), srcFile, false, block);
     ContractTestUtils.Touch(GetFileSystem(), zeroByteFile);
 }
 /// <exception cref="System.Exception"/>
 public override void Setup()
 {
     base.Setup();
     SkipIfUnsupported(SupportsSeek);
     //delete the test directory
     testPath      = GetContract().GetTestPath();
     smallSeekFile = Path("seekfile.txt");
     zeroByteFile  = Path("zero.txt");
     byte[] block = ContractTestUtils.Dataset(TestFileLen, 0, 255);
     //this file now has a simple rule: offset => value
     ContractTestUtils.CreateFile(GetFileSystem(), smallSeekFile, false, block);
     ContractTestUtils.Touch(GetFileSystem(), zeroByteFile);
 }
 public virtual void TestConcatEmptyFiles()
 {
     ContractTestUtils.Touch(GetFileSystem(), target);
     try
     {
         GetFileSystem().Concat(target, new Path[0]);
         NUnit.Framework.Assert.Fail("expected a failure");
     }
     catch (Exception e)
     {
         //expected
         HandleExpectedException(e);
     }
 }
예제 #6
0
        public virtual void TestAppendToEmptyFile()
        {
            ContractTestUtils.Touch(GetFileSystem(), target);
            byte[]             dataset      = ContractTestUtils.Dataset(256, 'a', 'z');
            FSDataOutputStream outputStream = GetFileSystem().Append(target);

            try
            {
                outputStream.Write(dataset);
            }
            finally
            {
                outputStream.Close();
            }
            byte[] bytes = ContractTestUtils.ReadDataset(GetFileSystem(), target, dataset.Length
                                                         );
            ContractTestUtils.CompareByteArrays(dataset, bytes, dataset.Length);
        }
예제 #7
0
        public virtual void TestRenameFileBeingAppended()
        {
            ContractTestUtils.Touch(GetFileSystem(), target);
            AssertPathExists("original file does not exist", target);
            byte[]             dataset      = ContractTestUtils.Dataset(256, 'a', 'z');
            FSDataOutputStream outputStream = GetFileSystem().Append(target);

            outputStream.Write(dataset);
            Path renamed = new Path(testPath, "renamed");

            outputStream.Close();
            string listing = Ls(testPath);

            //expected: the stream goes to the file that was being renamed, not
            //the original path
            AssertPathExists("renamed destination file does not exist", renamed);
            AssertPathDoesNotExist("Source file found after rename during append:\n" + listing
                                   , target);
            byte[] bytes = ContractTestUtils.ReadDataset(GetFileSystem(), renamed, dataset.Length
                                                         );
            ContractTestUtils.CompareByteArrays(dataset, bytes, dataset.Length);
        }
        public virtual void TestRmRootRecursive()
        {
            //extra sanity checks here to avoid support calls about complete loss of data
            SkipIfUnsupported(TestRootTestsEnabled);
            Path root = new Path("/");

            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            Path file = new Path("/testRmRootRecursive");

            ContractTestUtils.Touch(GetFileSystem(), file);
            bool deleted = GetFileSystem().Delete(root, true);

            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            Log.Info("rm -rf / result is {}", deleted);
            if (deleted)
            {
                AssertPathDoesNotExist("expected file to be deleted", file);
            }
            else
            {
                AssertPathExists("expected file to be preserved", file);
            }
        }