|
@@ -1283,4 +1283,40 @@ public class TestFileTruncate {
|
|
cluster.waitActive();
|
|
cluster.waitActive();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * QuotaUsage in Truncate with Snapshot.
|
|
|
|
+ */
|
|
|
|
+ @Test
|
|
|
|
+ public void testQuotaOnTruncateWithSnapshot() throws Exception {
|
|
|
|
+ Path root = new Path("/");
|
|
|
|
+ Path dirPath = new Path(root, "dir");
|
|
|
|
+ assertTrue(fs.mkdirs(dirPath));
|
|
|
|
+ Path filePath = new Path(dirPath, "file");
|
|
|
|
+ DFSTestUtil.createFile(fs, filePath, 10, (short) 3, 0);
|
|
|
|
+
|
|
|
|
+ // verify quotausage and content summary after creating snapshot
|
|
|
|
+ fs.allowSnapshot(dirPath);
|
|
|
|
+ fs.createSnapshot(dirPath, "s1");
|
|
|
|
+ assertEquals(fs.getContentSummary(root).getSpaceConsumed(),
|
|
|
|
+ fs.getQuotaUsage(root).getSpaceConsumed());
|
|
|
|
+
|
|
|
|
+ // truncating the file size to 5bytes
|
|
|
|
+ boolean blockrecovery = fs.truncate(filePath, 5);
|
|
|
|
+ if (!blockrecovery) {
|
|
|
|
+ checkBlockRecovery(filePath, fs, 300, 100L);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // verify quotausage and content summary after truncating file which exists
|
|
|
|
+ // in snapshot
|
|
|
|
+ assertEquals(fs.getContentSummary(root).getSpaceConsumed(),
|
|
|
|
+ fs.getQuotaUsage(root).getSpaceConsumed());
|
|
|
|
+
|
|
|
|
+ // verify quotausage and content summary after deleting snapshot
|
|
|
|
+ // now the quota of the file shouldn't present in quotausage and content
|
|
|
|
+ // summary
|
|
|
|
+ fs.deleteSnapshot(dirPath, "s1");
|
|
|
|
+ assertEquals(fs.getContentSummary(root).getSpaceConsumed(),
|
|
|
|
+ fs.getQuotaUsage(root).getSpaceConsumed());
|
|
|
|
+ }
|
|
}
|
|
}
|