adoroszlai commented on code in PR #9464:
URL: https://github.com/apache/ozone/pull/9464#discussion_r2827979442


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestOneReplicaPipelineSafeModeRule.java:
##########
@@ -191,6 +195,46 @@ public void testOneReplicaPipelineRuleMixedPipelines() 
throws Exception {
     GenericTestUtils.waitFor(() -> rule.validate(), 1000, 5000);
   }
 
+  @Test
+  public void testOneReplicaPipelineRuleWithReportProcessingFalse() {
+    EventQueue localEventQueue = new EventQueue();
+    PipelineManager mockedPipelineManager = mock(PipelineManager.class);
+    SCMSafeModeManager mockedSafeModeManager = mock(SCMSafeModeManager.class);
+    SafeModeMetrics mockedMetrics = mock(SafeModeMetrics.class);
+    when(mockedSafeModeManager.getSafeModeMetrics()).thenReturn(mockedMetrics);
+
+    OzoneConfiguration conf = new OzoneConfiguration();
+
+    PipelineID pipelineID = PipelineID.randomId();
+    Pipeline mockedPipeline = mock(Pipeline.class);
+    when(mockedPipeline.getId()).thenReturn(pipelineID);
+
+    // First validate(): pipeline has no nodes -> not counted as reported.
+    // Second validate(): pipeline has at least one node -> counted as 
reported.
+    when(mockedPipeline.getNodeSet())
+        .thenReturn(java.util.Collections.emptySet(),
+            new java.util.HashSet<>(
+                
java.util.Collections.singletonList(mock(DatanodeDetails.class))));
+
+    when(mockedPipelineManager.getPipelines(
+        Mockito.any(ReplicationConfig.class),
+        Mockito.eq(Pipeline.PipelineState.OPEN)))
+        .thenReturn(java.util.Collections.singletonList(mockedPipeline));
+
+    OneReplicaPipelineSafeModeRule localRule =
+        new OneReplicaPipelineSafeModeRule(localEventQueue, 
mockedPipelineManager,
+            mockedSafeModeManager, conf);
+
+    localRule.setValidateBasedOnReportProcessing(false);
+
+    // With no nodes in the pipeline, the rule should not be satisfied.
+    assertFalse(localRule.validate());
+
+    // After at least one node is present in the pipeline, the rule should 
pass.
+    assertTrue(localRule.validate());
+    assertTrue(localRule.getReportedPipelineIDSet().contains(pipelineID));

Review Comment:
   nit (for the future): Please use `assertThat()` instead of `assertTrue()` 
for better failure message.
   
   https://issues.apache.org/jira/browse/HDDS-9951



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestOneReplicaPipelineSafeModeRule.java:
##########
@@ -59,6 +62,7 @@
 import org.apache.ozone.test.TestClock;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
+import org.mockito.Mockito;

Review Comment:
   nit (for the future): Please use static imports for `Mockito`, similar to 
assertions.  This makes code more readable and reduces change if libraries 
reorganize their code.
   
   https://issues.apache.org/jira/browse/HDDS-9961



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