TestPlacementUtil.validate(cluster, existedNodes, false);
}
@Test
public void testResizeCluster() throws Exception {
ClusterCreate cluster =
TestPlacementUtil
.getSimpleClusterSpec(TestPlacementUtil.DC_SPLIT_CLUSTER_SPEC);
// increase data group's instance number by 1
cluster.getNodeGroup("data").setInstanceNum(
cluster.getNodeGroup("data").getInstanceNum() + 1);
AbstractDatacenter dc =
TestPlacementUtil
.getAbstractDatacenter(TestPlacementUtil.RESIZE_DATACENTER_SPEC);
Container container = new Container(dc);
container.SetTemplateNode(TestPlacementUtil.getTemplateNode());
List<BaseNode> existedNodes =
TestPlacementUtil
.getExistedNodes(TestPlacementUtil.RESIZE_NODE_SPEC);
PlacementService service = new PlacementService();
List<BaseNode> bads = service.getBadNodes(cluster, existedNodes);
Assert.assertEquals(bads.size(), 0);
List<BaseNode> nodes =
service.getPlacementPlan(container, cluster, existedNodes,
new HashMap<String, List<String>>());
Assert.assertEquals(nodes.size(), 1);
existedNodes.addAll(nodes);
TestPlacementUtil.validate(cluster, existedNodes, false);
// increase compute group's instance by 2
cluster.getNodeGroup("compute").setInstanceNum(
cluster.getNodeGroup("compute").getInstanceNum() + 2);
nodes = service.getPlacementPlan(container, cluster, existedNodes,
new HashMap<String, List<String>>());
Assert.assertEquals(nodes.size(), 2);