HDFS-13659. Add more test coverage for contentSummary for snapshottable path. Contributed by Wei-Chiu Chuang.
(cherry picked from commit e39b113db0f2e4bcf93f873801be770e472601da) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b2e919dc Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b2e919dc Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b2e919dc Branch: refs/remotes/origin/branch-3.1 Commit: b2e919dc1a8688bb6499f7334ad67c49dcc1bc93 Parents: a95f216 Author: Wei-Chiu Chuang <[email protected]> Authored: Thu Jun 7 08:30:06 2018 -0700 Committer: Wei-Chiu Chuang <[email protected]> Committed: Thu Jun 7 08:31:30 2018 -0700 ---------------------------------------------------------------------- .../TestGetContentSummaryWithSnapshot.java | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2e919dc/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java index dc6f584..1c16818 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java @@ -81,6 +81,9 @@ public class TestGetContentSummaryWithSnapshot { * 3. create a 10 byte file /foo/bar/baz * Make sure for "/foo/bar" and "/foo/.snapshot/s1/bar" have correct results: * the 1 byte file is not included in snapshot s1. + * 4. create another snapshot, append to the file /foo/bar/baz, + * and make sure file count, directory count and file length is good. + * 5. delete the file, ensure contentSummary output too. */ @Test public void testGetContentSummary() throws IOException { @@ -118,6 +121,29 @@ public class TestGetContentSummaryWithSnapshot { Assert.assertEquals(0, summary.getFileCount()); Assert.assertEquals(0, summary.getLength()); + // create a new snapshot s2 and update the file + dfs.createSnapshot(foo, "s2"); + DFSTestUtil.appendFile(dfs, baz, 10); + summary = cluster.getNameNodeRpc().getContentSummary( + bar.toString()); + Assert.assertEquals(1, summary.getDirectoryCount()); + Assert.assertEquals(1, summary.getFileCount()); + Assert.assertEquals(20, summary.getLength()); + + final Path fooS2 = SnapshotTestHelper.getSnapshotRoot(foo, "s2"); + summary = cluster.getNameNodeRpc().getContentSummary(fooS2.toString()); + Assert.assertEquals(2, summary.getDirectoryCount()); + Assert.assertEquals(1, summary.getFileCount()); + Assert.assertEquals(10, summary.getLength()); + + cluster.getNameNodeRpc().delete(baz.toString(), false); + + summary = cluster.getNameNodeRpc().getContentSummary( + foo.toString()); + Assert.assertEquals(0, summary.getSnapshotDirectoryCount()); + Assert.assertEquals(1, summary.getSnapshotFileCount()); + Assert.assertEquals(20, summary.getSnapshotLength()); + final Path bazS1 = SnapshotTestHelper.getSnapshotPath(foo, "s1", "bar/baz"); try { cluster.getNameNodeRpc().getContentSummary(bazS1.toString()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
