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


##########
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:
   The test claims reachable child directories from parent 1 are {2, 3}, but 
the assertions only check size and de-duplication. This could still pass if the 
traversal accidentally includes the root (1) or misses an expected child. 
Assert the exact expected subpaths (in any order) to make the cycle-guard 
behavior regression-proof.



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