sodonnel commented on a change in pull request #2591:
URL: https://github.com/apache/ozone/pull/2591#discussion_r697889335



##########
File path: 
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/TestSCMContainerPlacementRackAware.java
##########
@@ -524,4 +527,28 @@ public void 
testvalidateContainerPlacementSingleRackCluster() {
     assertTrue(stat.isPolicySatisfied());
     assertEquals(0, stat.misReplicationCount());
   }
+
+  @Test
+  public void testOutOfServiceNodesNotSelected() {
+    // Set all the nodes to out of service
+    for (DatanodeInfo dn : dnInfos) {
+      dn.setNodeStatus(new NodeStatus(DECOMMISSIONED, HEALTHY));
+    }
+
+    for (int i=0; i<10; i++) {
+      // Set a random DN to in_service and ensure it is always picked
+      int index = new Random().nextInt(dnInfos.size());
+      dnInfos.get(index).setNodeStatus(NodeStatus.inServiceHealthy());
+      try {
+        List<DatanodeDetails> datanodeDetails =
+            policy.chooseDatanodes(null, null, 1, 0, 0);
+        Assert.assertEquals(dnInfos.get(index), datanodeDetails.get(0));
+      } catch (SCMException e) {
+        // If we get SCMException: No satisfied datanode to meet the ... this 
is

Review comment:
       I think that would risk making the test flaky. When there are a large 
number of datanodes (say 15) and we put all out of service but 1, there is a 
reasonably high chance it will never find a node to use in 10 tries. I think it 
only retries 3 times inside the policy so it has a 1 in 15 chance on the first 
try, and 1 in 14 on the second try and 1 in 13 on the 3rd. Its actually more 
likely to fail than find a node.
   
   I could argue that is a problem with the provider, but that logic was put in 
to avoid infinite loops, and we are not trying to fix the provider here. 
Probably the provider should keep trying until all nodes have been tried, but 
that would be a topic for another Jira I think.




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