ayushtkn commented on code in PR #5656:
URL: https://github.com/apache/hadoop/pull/5656#discussion_r1193365802
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java:
##########
@@ -1603,4 +1609,51 @@ public void testSnapshotDiffReportRemoteIterator2()
throws Exception {
+ "supported for snapshotDiffReport between two snapshots"));
}
}
+
+ @Test
+ public void testSubtrees() throws Exception {
+ final Path root = new Path("/");
+ final Path foo = new Path(root, "foo");
+ final Path bar = new Path(foo, "bar");
+ hdfs.mkdirs(bar);
+ modifyAndCreateSnapshot(bar, new Path[]{root});
+
+ final SnapshottableDirectoryStatus[] snapshottables
+ = hdfs.getSnapshottableDirListing();
+ Assert.assertEquals(1, snapshottables.length);
+ Assert.assertEquals(3, snapshottables[0].getSnapshotNumber());
+
+ final SnapshotStatus[] statuses = hdfs.getSnapshotListing(root);
+ Assert.assertEquals(3, statuses.length);
+ for (int i = 0; i < statuses.length; i++) {
+ final SnapshotStatus s = statuses[i];
+ LOG.info("Snapshot #{}: {}", s.getSnapshotID(), s.getFullPath());
+ Assert.assertEquals(i, s.getSnapshotID());
+ }
+
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertDiff(root, foo, bar, "s" + i, "s" + j);
+ }
+ }
+ }
+
+ private void assertDiff(Path root, Path foo, Path bar,
+ String from, String to) throws Exception {
+ final String barDiff = diff(bar, from, to);
+ final String fooDiff = diff(foo, from, to);
+ Assert.assertEquals(barDiff, fooDiff.replace("/bar", ""));
+
+ final String rootDiff = diff(root, from, to);
+ Assert.assertEquals(fooDiff, rootDiff.replace("/foo", ""));
+ Assert.assertEquals(barDiff, rootDiff.replace("/foo/bar", ""));
+ }
+
+ private String diff(Path path, String from, String to) throws Exception {
+ final SnapshotDiffReport diff = hdfs.getSnapshotDiffReport(path, from, to);
+ LOG.info("DIFF {} from {} to {}", path, from, to);
+ LOG.info("{}", diff);
Review Comment:
could have put in single line, in case some parallel test logging in same
place, it would have been easy to relate.
```
LOG.info("DIFF {} from {} to {} is {}", path, from, to, diff);
```
juzz my thoughts, your call
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]