/// <exception cref="System.Exception"/> private void TestTruncate(long newLength, long expectedDiff, long expectedUsage) { // before doing the real truncation, make sure the computation is correct INodesInPath iip = fsdir.GetINodesInPath4Write(file.ToString()); INodeFile fileNode = iip.GetLastINode().AsFile(); fileNode.RecordModification(iip.GetLatestSnapshotId(), true); long diff = fileNode.ComputeQuotaDeltaForTruncate(newLength); NUnit.Framework.Assert.AreEqual(expectedDiff, diff); // do the real truncation dfs.Truncate(file, newLength); // wait for truncate to finish TestFileTruncate.CheckBlockRecovery(file, dfs); INodeDirectory dirNode = fsdir.GetINode4Write(dir.ToString()).AsDirectory(); long spaceUsed = dirNode.GetDirectoryWithQuotaFeature().GetSpaceConsumed().GetStorageSpace (); long diskUsed = dirNode.GetDirectoryWithQuotaFeature().GetSpaceConsumed().GetTypeSpaces ().Get(StorageType.Disk); NUnit.Framework.Assert.AreEqual(expectedUsage, spaceUsed); NUnit.Framework.Assert.AreEqual(expectedUsage, diskUsed); }