jerqi commented on code in PR #166:
URL: https://github.com/apache/incubator-uniffle/pull/166#discussion_r978221475
##########
coordinator/src/test/java/org/apache/uniffle/coordinator/PartitionBalanceAssignmentStrategyTest.java:
##########
@@ -282,4 +285,70 @@ public void testAssignmentShuffleNodesNum() {
.size()
);
}
+
+
+ @Test
+ public void testAssignmentWithSameIP() throws Exception {
+ CoordinatorConf ssc = new CoordinatorConf();
+ ssc.setInteger(CoordinatorConf.COORDINATOR_SHUFFLE_NODES_MAX,
shuffleNodesMax);
+ ssc.set(CoordinatorConf.COORDINATOR_ASSGINMENT_HOST_STRATEGY,
+ AbstractAssignmentStrategy.HostAssignmentStrategy.MUST_DIFF);
+ clusterManager = new SimpleClusterManager(ssc, new Configuration());
+ strategy = new PartitionBalanceAssignmentStrategy(clusterManager, ssc);
+
+ Set<String> serverTags = Sets.newHashSet("tag-1");
+
+ for (int i = 0; i < 5; ++i) {
+ clusterManager.add(new ServerNode("t1-" + i, "127.0.0." + i, 0, 0, 0,
+ 20 - i, 0, serverTags, true));
+ }
+ for (int i = 0; i < 5; ++i) {
+ clusterManager.add(new ServerNode("t2-" + i, "127.0.0." + i, 1, 0, 0,
+ 20 - i, 0, serverTags, true));
+ }
+ PartitionRangeAssignment pra = strategy.assign(100, 1, 5, serverTags, -1);
+ pra.getAssignments().values().forEach((nodeList) -> {
+ Map<String, ServerNode> nodeMap = new HashMap<>();
+ nodeList.forEach((node) -> {
+ ServerNode serverNode = nodeMap.get(node.getIp());
+ assertNull(serverNode);
+ nodeMap.put(node.getIp(), node);
+ });
+ });
+
+ pra = strategy.assign(100, 1, 6, serverTags, -1);
+ pra.getAssignments().values().forEach((nodeList) -> {
+ Map<String, ServerNode> nodeMap = new HashMap<>();
+ boolean hasSameHost = false;
+ for (ServerNode node : nodeList) {
+ ServerNode serverNode = nodeMap.get(node.getIp());
+ if (serverNode != null) {
+ hasSameHost = true;
+ break;
+ }
+ assertNull(serverNode);
+ nodeMap.put(node.getIp(), node);
+ }
+ assertTrue(hasSameHost);
+ });
+ }
+
Review Comment:
We would better test the Strategy `PREFER_DIFF` and `NONE`.
--
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]