You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "erichung9060 (via GitHub)" <gi...@apache.org> on 2025/06/28 17:57:39 UTC

[PR] HDDS-12953. Directly create DataNodeSafeModeRule in TestDataNodeSafeModeRule [ozone]

erichung9060 opened a new pull request, #8716:
URL: https://github.com/apache/ozone/pull/8716

   ## What changes were proposed in this pull request?
   This pull request refactors TestDataNodeSafeModeRule to directly instantiate DataNodeSafeModeRule instead of using SCMSafeModeManager and SafeModeRuleFactory.
   
   - Remove dependency on SCMSafeModeManager and SafeModeRuleFactory in test
   - Create DataNodeSafeModeRule directly with mocked dependencies
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-12953
   
   ## How was this patch tested?
   
   By existing tests.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12953. Directly create DataNodeSafeModeRule in TestDataNodeSafeModeRule [ozone]

Posted by "peterxcli (via GitHub)" <gi...@apache.org>.
peterxcli commented on code in PR #8716:
URL: https://github.com/apache/ozone/pull/8716#discussion_r2173564041


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestDataNodeSafeModeRule.java:
##########
@@ -67,20 +60,15 @@ private void setup(int requiredDns) throws Exception {
     ozoneConfiguration.setInt(
         HddsConfigKeys.HDDS_SCM_SAFEMODE_MIN_DATANODE, requiredDns);
 
-    List<ContainerInfo> containers =
-        new ArrayList<>(HddsTestUtils.getContainerInfo(1));
     nodeManager = mock(NodeManager.class);
-    ContainerManager containerManager = mock(ContainerManager.class);
-    when(containerManager.getContainers()).thenReturn(containers);
     eventQueue = new EventQueue();
-    serviceManager = new SCMServiceManager();
-    scmContext = SCMContext.emptyContext();
 
-    SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(ozoneConfiguration,
-        nodeManager, null, containerManager, serviceManager, eventQueue, scmContext);
-    scmSafeModeManager.start();
+    // Mock SCMSafeModeManager for DataNodeSafeModeRule dependencies
+    SCMSafeModeManager mockSafeModeManager = mock(SCMSafeModeManager.class);
+    when(mockSafeModeManager.getInSafeMode()).thenReturn(true);

Review Comment:
   We don't need to assume safeModeManager is in safe mode.



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestDataNodeSafeModeRule.java:
##########
@@ -67,20 +60,15 @@ private void setup(int requiredDns) throws Exception {
     ozoneConfiguration.setInt(
         HddsConfigKeys.HDDS_SCM_SAFEMODE_MIN_DATANODE, requiredDns);
 
-    List<ContainerInfo> containers =
-        new ArrayList<>(HddsTestUtils.getContainerInfo(1));
     nodeManager = mock(NodeManager.class);
-    ContainerManager containerManager = mock(ContainerManager.class);
-    when(containerManager.getContainers()).thenReturn(containers);
     eventQueue = new EventQueue();
-    serviceManager = new SCMServiceManager();
-    scmContext = SCMContext.emptyContext();
 
-    SCMSafeModeManager scmSafeModeManager = new SCMSafeModeManager(ozoneConfiguration,
-        nodeManager, null, containerManager, serviceManager, eventQueue, scmContext);
-    scmSafeModeManager.start();
+    // Mock SCMSafeModeManager for DataNodeSafeModeRule dependencies
+    SCMSafeModeManager mockSafeModeManager = mock(SCMSafeModeManager.class);
+    when(mockSafeModeManager.getInSafeMode()).thenReturn(true);
 
-    rule = SafeModeRuleFactory.getInstance().getSafeModeRule(DataNodeSafeModeRule.class);
+    // Create DataNodeSafeModeRule directly without using SafeModeRuleFactory

Review Comment:
   this comment could be removed.
   ```suggestion
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12953. Directly create DataNodeSafeModeRule in TestDataNodeSafeModeRule [ozone]

Posted by "erichung9060 (via GitHub)" <gi...@apache.org>.
erichung9060 commented on PR #8716:
URL: https://github.com/apache/ozone/pull/8716#issuecomment-3016736825

   @peterxcli  ,Thanks a lot for reviewing and approving the PR!


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-12953. Directly create DataNodeSafeModeRule in TestDataNodeSafeModeRule [ozone]

Posted by "peterxcli (via GitHub)" <gi...@apache.org>.
peterxcli merged PR #8716:
URL: https://github.com/apache/ozone/pull/8716


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org