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


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestSCMSafeModeManager.java:
##########
@@ -168,6 +169,67 @@ private void testSafeMode(int numContainers) throws 
Exception {
 
   }
 
+  @Test
+  public void testSafeModeExitWithPeriodicContainerRuleRefresh() throws 
Exception {
+    config.set(HddsConfigKeys.HDDS_SCM_SAFEMODE_RULE_REFRESH_INTERVAL, 
"100ms");
+
+    List<ContainerInfo> ratisContainers = new ArrayList<>();
+    ratisContainers.addAll(HddsTestUtils.getContainerInfo(5));
+    for (ContainerInfo container : ratisContainers) {
+      container.setState(HddsProtos.LifeCycleState.CLOSED);
+      container.setNumberOfKeys(10);
+    }
+
+    ContainerManager containerManager = mock(ContainerManager.class);
+    when(containerManager.getContainers(ReplicationType.RATIS))
+        .thenAnswer(invocation -> new ArrayList<>(ratisContainers));
+    when(containerManager.getContainers(ReplicationType.EC))
+        .thenReturn(Collections.emptyList());
+
+    scmSafeModeManager = new SCMSafeModeManager(config, null, null, 
containerManager,
+        serviceManager, queue, scmContext);
+    scmSafeModeManager.start();
+
+    assertTrue(scmSafeModeManager.getInSafeMode());
+
+    RatisContainerSafeModeRule ratisRule = SafeModeRuleFactory.getInstance()
+        .getSafeModeRule(RatisContainerSafeModeRule.class);
+    assertEquals(5, ratisRule.getTotalNumberOfContainers(),
+        "initial Ratis container count from ContainerManager");
+
+    ratisContainers.addAll(HddsTestUtils.getContainerInfo(5));
+    for (int i = 5; i < ratisContainers.size(); i++) {
+      ratisContainers.get(i).setState(HddsProtos.LifeCycleState.CLOSED);
+      ratisContainers.get(i).setNumberOfKeys(10);
+    }
+
+    GenericTestUtils.waitFor(
+        () -> ratisRule.getTotalNumberOfContainers() == 10,
+        100,
+        15000);

Review Comment:
   @sadanand48 @sumitagrawl This times out now that HDDS-15238 is implemented.  
`AbstractContainerSafeModeRule` only considers the containers it knows about at 
the start, adding more items to `ratisContainers` in the test does not increase 
`getTotalNumberOfContainers` to 10.
   
   
https://github.com/apache/ozone/blob/95b086316311a3adf6bd8b386edb20115cb977f0/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/AbstractContainerSafeModeRule.java#L88-L97



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