ashishkumar50 commented on code in PR #4614:
URL: https://github.com/apache/ozone/pull/4614#discussion_r1179480012
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/TestSCMContainerPlacementRackAware.java:
##########
@@ -588,4 +588,213 @@ public void testOutOfServiceNodesNotSelected(int
datanodeCount) {
dnInfos.get(index).setNodeStatus(new NodeStatus(DECOMMISSIONED,
HEALTHY));
}
}
+
+ @ParameterizedTest
+ @ValueSource(ints = {NODE_PER_RACK + 1, 2 * NODE_PER_RACK + 1})
+ public void chooseNodeWithUsedNodesMultipleRack(int datanodeCount)
+ throws SCMException {
+ assumeTrue(datanodeCount > NODE_PER_RACK);
+ setup(datanodeCount);
+ int nodeNum = 1;
+ List<DatanodeDetails> excludedNodes = new ArrayList<>();
+ List<DatanodeDetails> usedNodes = new ArrayList<>();
+
+ // 2 replicas, two existing datanodes on same rack
+ usedNodes.add(datanodes.get(0));
+ usedNodes.add(datanodes.get(1));
+
+ List<DatanodeDetails> datanodeDetails = policy.chooseDatanodes(usedNodes,
+ excludedNodes, null, nodeNum, 0, 5);
+ Assertions.assertEquals(nodeNum, datanodeDetails.size());
+
+ // New DN should be on different rack than DN0 & DN1
+ Assertions.assertTrue(!cluster.isSameParent(
+ datanodes.get(0), datanodeDetails.get(0)) &&
+ !cluster.isSameParent(datanodes.get(1), datanodeDetails.get(0)));
+
+ // 2 replicas, two existing datanodes on different rack
+ usedNodes.clear();
+ // 1st Replica on rack0
+ usedNodes.add(datanodes.get(0));
+ // 2nd Replica on rack1
+ usedNodes.add(datanodes.get(5));
+
+ datanodeDetails = policy.chooseDatanodes(usedNodes,
+ excludedNodes, null, nodeNum, 0, 5);
+ Assertions.assertEquals(nodeNum, datanodeDetails.size());
+
+ // New replica should be either on rack0 or rack1
+ Assertions.assertTrue(cluster.isSameParent(
+ datanodes.get(0), datanodeDetails.get(0)) ||
+ cluster.isSameParent(datanodes.get(1), datanodeDetails.get(0)));
Review Comment:
Thanks for pointing out, updated test.
--
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]