// ok - as expected public virtual void CheckInvalidBlock(ExtendedBlock b) { SimulatedFSDataset fsdataset = GetSimulatedFSDataset(); NUnit.Framework.Assert.IsFalse(fsdataset.IsValidBlock(b)); try { fsdataset.GetLength(b); NUnit.Framework.Assert.IsTrue("Expected an IO exception", false); } catch (IOException) { } // ok - as expected try { fsdataset.GetBlockInputStream(b); NUnit.Framework.Assert.IsTrue("Expected an IO exception", false); } catch (IOException) { } // ok - as expected try { fsdataset.FinalizeBlock(b); NUnit.Framework.Assert.IsTrue("Expected an IO exception", false); } catch (IOException) { } }
public virtual void TestWriteRead() { SimulatedFSDataset fsdataset = GetSimulatedFSDataset(); AddSomeBlocks(fsdataset); for (int i = 1; i <= Numblocks; ++i) { ExtendedBlock b = new ExtendedBlock(bpid, i, 0, 0); NUnit.Framework.Assert.IsTrue(fsdataset.IsValidBlock(b)); NUnit.Framework.Assert.AreEqual(BlockIdToLen(i), fsdataset.GetLength(b)); CheckBlockDataAndSize(fsdataset, b, BlockIdToLen(i)); } }
public virtual void TestInvalidate() { SimulatedFSDataset fsdataset = GetSimulatedFSDataset(); int bytesAdded = AddSomeBlocks(fsdataset); Block[] deleteBlocks = new Block[2]; deleteBlocks[0] = new Block(1, 0, 0); deleteBlocks[1] = new Block(2, 0, 0); fsdataset.Invalidate(bpid, deleteBlocks); CheckInvalidBlock(new ExtendedBlock(bpid, deleteBlocks[0])); CheckInvalidBlock(new ExtendedBlock(bpid, deleteBlocks[1])); long sizeDeleted = BlockIdToLen(1) + BlockIdToLen(2); NUnit.Framework.Assert.AreEqual(bytesAdded - sizeDeleted, fsdataset.GetDfsUsed()); NUnit.Framework.Assert.AreEqual(fsdataset.GetCapacity() - bytesAdded + sizeDeleted , fsdataset.GetRemaining()); // Now make sure the rest of the blocks are valid for (int i = 3; i <= Numblocks; ++i) { Block b = new Block(i, 0, 0); NUnit.Framework.Assert.IsTrue(fsdataset.IsValidBlock(new ExtendedBlock(bpid, b))); } }