smengcl commented on code in PR #10723:
URL: https://github.com/apache/ozone/pull/10723#discussion_r3562310820


##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconUtils.java:
##########
@@ -175,6 +183,35 @@ public void testNextClosestPowerIndexOfTwo() {
     }
   }
 
+  @Test
+  @Timeout(30)
+  public void testGatherSubPathsToleratesCyclicTree() throws IOException {
+    // Corrupted NSSummary tree: 1 -> {2, 3}, 2 -> 1 (back edge), 3 -> 3 (self
+    // loop). gatherSubPaths must terminate instead of overflowing the stack,
+    // and must list each reachable child directory once.
+    ReconNamespaceSummaryManager nsSummaryManager =
+        mock(ReconNamespaceSummaryManager.class);
+    when(nsSummaryManager.getNSSummary(1L))
+        .thenReturn(nsSummaryWithChildren(2L, 3L));
+    when(nsSummaryManager.getNSSummary(2L))
+        .thenReturn(nsSummaryWithChildren(1L));
+    when(nsSummaryManager.getNSSummary(3L))
+        .thenReturn(nsSummaryWithChildren(3L));
+
+    List<String> subPaths = new ArrayList<>();
+    ReconUtils.gatherSubPaths(1L, subPaths, 100L, 200L, nsSummaryManager);
+
+    // Child directories reachable from parent 1 are {2, 3}, each emitted once.
+    assertEquals(2, subPaths.size());
+    assertThat(subPaths).doesNotHaveDuplicates();

Review Comment:
   done in 13feedbf841c8d3297775729d4bb3221f5827216



-- 
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]

Reply via email to