ngr1.setMemCapacityMB(2048);
ngr1.setStorage(sr1);
ngr1.setInstanceNum(2);
ngr1.setInstances(instances1);
ngr1.setRoles(roles1);
ClusterRead cr1 = new ClusterRead();
cr1.setName("cluster1");
cr1.setDistroVendor("BIGTOP");
cr1.setDistro("distro1");
cr1.setInstanceNum(10);
cr1.setVhmMinNum(-1);
cr1.setVhmMaxNum(-1);
cr1.setStatus(ClusterStatus.RUNNING);
List<NodeGroupRead> nodeGroupRead = new LinkedList<NodeGroupRead>();
nodeGroupRead.add(ngr1);
List<String> roles2 = new LinkedList<String>();
roles2.add(Constants.ROLE_HADOOP_CLIENT);
NodeGroupRead ngr2 = new NodeGroupRead();
ngr2.setName("NodeGroup2");
ngr2.setCpuNum(6);
ngr2.setMemCapacityMB(2048);
ngr2.setStorage(sr1);
ngr2.setInstanceNum(1);
ngr2.setInstances(instances1);
ngr2.setRoles(roles2);
nodeGroupRead.add(ngr2);
cr1.setNodeGroups(nodeGroupRead);
cr1.setAutomationEnable(false);
//setParam tests
//set elasticityMode to MANUAL
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", "MANUAL", null, null, null, "HIGH");
//set elasticityMode to AUTO with targetComputeNodeNum=2
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", "AUTO", null, null, 2, "HIGH");
//set elasticityMode to MANUAL with targetComputeNodeNum=2
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param_wait_for_result", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", "MANUAL", null, null, 2, "HIGH");
//set minComputeNodeNum=2 and targetComputeNodeNum=2
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param_wait_for_result", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", null, 2, null, 2, "HIGH");
//set elasticityMode to AUTO with minComputeNodeNum=maxComputeNodeNum=2
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", "AUTO", 2, 2, null, "HIGH");
//only set ioShares to HIGH
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.setParam("cluster1", null, null, null, null, "HIGH");
//reset Param tests
//reset all
setup();
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param_wait_for_result", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.resetParam("cluster1", true, false, false, false, false, false);
//set vhmTargetNum to -1
//then reset elasticityMode
setup();
cr1.setVhmTargetNum(-1);
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param_wait_for_result", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.resetParam("cluster1", false, true, false, false, false, false);
//set automationEnable to true
//then reset minComputeNodeNum, maxComputeNodeNum, targetComputeNodeNum and ioShares
setup();
cr1.setAutomationEnable(true);
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.resetParam("cluster1", false, false, true, true, true, true);
//set automationEnable to true
//then only reset ioShares
setup();
cr1.setAutomationEnable(true);
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1", HttpMethod.GET, HttpStatus.OK,
mapper.writeValueAsString(cr1));
buildReqRespWithoutReqBody("https://127.0.0.1:8443/serengeti/api/cluster/cluster1/param", HttpMethod.PUT,
HttpStatus.NO_CONTENT, "");
clusterCommands.resetParam("cluster1", false, false, false, false, false, true);