This is an automated email from the ASF dual-hosted git repository. szetszwo pushed a commit to branch SnapshotDiffSubtrees in repository https://gitbox.apache.org/repos/asf/hadoop.git
commit f7be6b6886c44cd724bd37ce4c728e78edd82d04 Author: Tsz-Wo Nicholas Sze <szets...@apache.org> AuthorDate: Mon May 15 11:13:39 2023 +0800 add testSubtrees. --- .../namenode/snapshot/TestSnapshotDiffReport.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java index 1d50e50d426..a8724559bcc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java @@ -50,6 +50,8 @@ import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffType; import org.apache.hadoop.hdfs.protocol.SnapshotDiffReportListing; import org.apache.hadoop.hdfs.protocol.SnapshotException; +import org.apache.hadoop.hdfs.protocol.SnapshotStatus; +import org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus; import org.apache.hadoop.hdfs.server.namenode.INodeDirectory; import org.apache.hadoop.hdfs.server.namenode.NameNode; import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter; @@ -70,6 +72,10 @@ import org.slf4j.LoggerFactory; public class TestSnapshotDiffReport { private static final Logger LOG = LoggerFactory.getLogger(TestSnapshotDiffReport.class); + + { + SnapshotTestHelper.disableLogs(); + } private static final long SEED = 0; private static final short REPLICATION = 3; private static final short REPLICATION_1 = 2; @@ -1603,4 +1609,31 @@ public class TestSnapshotDiffReport { + "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}); + + cluster.getNamesystem().getFSDirectory().getRoot().dumpTreeRecursively(System.out); + for (SnapshottableDirectoryStatus s : hdfs.getSnapshottableDirListing()) { + LOG.info("Snapshottable {}: #snapshots={}", s.getFullPath(), s.getSnapshotNumber()); + } + for (SnapshotStatus s : hdfs.getSnapshotListing(root)) { + LOG.info("Snapshot #{}: {}", s.getSnapshotID(), s.getFullPath()); + } + + diff(root, "s0", "s2"); + diff(foo, "s0", "s2"); + diff(bar, "s0", "s2"); + } + + void 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); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org