public virtual void TestCreatedFileIsImmediatelyVisible() { Describe("verify that a newly created file exists as soon as open returns"); Path path = Path("testCreatedFileIsImmediatelyVisible"); FSDataOutputStream @out = null; try { @out = GetFileSystem().Create(path, false, 4096, (short)1, 1024); if (!GetFileSystem().Exists(path)) { if (IsSupported(IsBlobstore)) { // object store: downgrade to a skip so that the failure is visible // in test results ContractTestUtils.Skip("Filesystem is an object store and newly created files are not immediately visible" ); } AssertPathExists("expected path to be visible before anything written", path); } } finally { IOUtils.CloseStream(@out); } }
/// <summary>Skip a test if a feature is unsupported in this FS</summary> /// <param name="feature">feature to look for</param> /// <exception cref="System.IO.IOException">IO problem</exception> protected internal virtual void SkipIfUnsupported(string feature) { if (!IsSupported(feature)) { ContractTestUtils.Skip("Skipping as unsupported feature: " + feature); } }
public virtual void TestOverwriteNonEmptyDirectory() { Describe("verify trying to create a file over a non-empty dir fails"); Path path = Path("testOverwriteNonEmptyDirectory"); Mkdirs(path); try { AssertIsDirectory(path); } catch (Exception failure) { if (IsSupported(IsBlobstore)) { // file/directory hack surfaces here throw Extensions.InitCause(new AssumptionViolatedException(failure.ToString ()), failure); } // else: rethrow throw; } Path child = new Path(path, "child"); ContractTestUtils.WriteTextFile(GetFileSystem(), child, "child file", true); byte[] data = ContractTestUtils.Dataset(256, 'a', 'z'); try { ContractTestUtils.WriteDataset(GetFileSystem(), path, data, data.Length, 1024, true ); FileStatus status = GetFileSystem().GetFileStatus(path); bool isDir = status.IsDirectory(); if (!isDir && IsSupported(IsBlobstore)) { // object store: downgrade to a skip so that the failure is visible // in test results ContractTestUtils.Skip("Object store allows a file to overwrite a directory"); } NUnit.Framework.Assert.Fail("write of file over dir succeeded"); } catch (FileAlreadyExistsException expected) { //expected HandleExpectedException(expected); } catch (FileNotFoundException e) { HandleRelaxedException("overwriting a dir with a file ", "FileAlreadyExistsException" , e); } catch (IOException e) { HandleRelaxedException("overwriting a dir with a file ", "FileAlreadyExistsException" , e); } AssertIsDirectory(path); AssertIsFile(child); }