Source:
<code>public void testListSnapshot() throws Exception { <START> cluster.getNamesystem().getSnapshotManager().setAllowNestedSnapshots(true); <END> SnapshotStatus[] snapshotStatuses = null; SnapshottableDirectoryStatus[] dirs = hdfs.getSnapshottableDirListing(); assertNull(dirs); try { hdfs.getSnapshotListing(dir1); } catch (Exception e) { assertTrue(e.getMessage().contains( "Directory is not a snapshottable directory")); } final Path root = new Path("/"); hdfs.allowSnapshot(root); dirs = hdfs.getSnapshottableDirListing(); assertEquals(1, dirs.length); assertEquals("", dirs[0].getDirStatus().getLocalName()); assertEquals(root, dirs[0].getFullPath()); snapshotStatuses = hdfs.getSnapshotListing(root); assertNull(snapshotStatuses); hdfs.disallowSnapshot(root); dirs = hdfs.getSnapshottableDirListing(); assertNull(dirs); snapshotStatuses = hdfs.getSnapshotListing(root); assertNull(snapshotStatuses); hdfs.allowSnapshot(dir1); hdfs.createSnapshot(dir1, "s0"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(1, snapshotStatuses.length); assertEquals("s0", snapshotStatuses[0].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s0"), snapshotStatuses[0].getFullPath()); assertEquals(0, snapshotStatuses[0].getSnapshotID()); hdfs.createSnapshot(dir1, "s1"); hdfs.createSnapshot(dir1, "s2"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(3, snapshotStatuses.length); assertEquals("s0", snapshotStatuses[0].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s0"), snapshotStatuses[0].getFullPath()); assertEquals("s1", snapshotStatuses[1].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s1"), snapshotStatuses[1].getFullPath()); assertEquals("s2", snapshotStatuses[2].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s2"), snapshotStatuses[2].getFullPath()); hdfs.deleteSnapshot(dir1, "s2"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(2, snapshotStatuses.length); }</code><technical_language>fsn is there, change to: fsn.getSnapshotManager().setAllowNestedSnapshots(true);</technical_language>

Target:
public void testListSnapshot() throws Exception { fsn.getSnapshotManager().setAllowNestedSnapshots(true); SnapshotStatus[] snapshotStatuses = null; SnapshottableDirectoryStatus[] dirs = hdfs.getSnapshottableDirListing(); assertNull(dirs); LambdaTestUtils.intercept(SnapshotException.class, "Directory is not a " + "snapshottable directory", () -> hdfs.getSnapshotListing(dir1)); final Path root = new Path("/"); hdfs.allowSnapshot(root); dirs = hdfs.getSnapshottableDirListing(); assertEquals(1, dirs.length); assertEquals("", dirs[0].getDirStatus().getLocalName()); assertEquals(root, dirs[0].getFullPath()); snapshotStatuses = hdfs.getSnapshotListing(root); assertTrue(snapshotStatuses.length == 0); hdfs.disallowSnapshot(root); dirs = hdfs.getSnapshottableDirListing(); assertNull(dirs); snapshotStatuses = hdfs.getSnapshotListing(root); assertTrue(snapshotStatuses.length == 0); hdfs.allowSnapshot(dir1); hdfs.createSnapshot(dir1, "s0"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(1, snapshotStatuses.length); assertEquals("s0", snapshotStatuses[0].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s0"), snapshotStatuses[0].getFullPath()); assertEquals(0, snapshotStatuses[0].getSnapshotID()); hdfs.createSnapshot(dir1, "s1"); hdfs.createSnapshot(dir1, "s2"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(3, snapshotStatuses.length); assertEquals("s0", snapshotStatuses[0].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s0"), snapshotStatuses[0].getFullPath()); assertEquals("s1", snapshotStatuses[1].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s1"), snapshotStatuses[1].getFullPath()); assertEquals("s2", snapshotStatuses[2].getDirStatus(). getLocalName()); assertEquals(SnapshotTestHelper.getSnapshotRoot(dir1, "s2"), snapshotStatuses[2].getFullPath()); hdfs.deleteSnapshot(dir1, "s2"); snapshotStatuses = hdfs.getSnapshotListing(dir1); assertEquals(2, snapshotStatuses.length); }