use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoscaleRequestValidatorTest method testIsValidWhenNegativeTargeTimeAlertsThenFalse.
@Test
public void testIsValidWhenNegativeTargeTimeAlertsThenFalse() {
List<String> timeHostGroups = Arrays.asList("compute2", "hdfs1", "hdfs3");
DistroXAutoscaleClusterRequest request = getTestRequest(timeHostGroups, List.of(), Optional.empty());
request.getTimeAlertRequests().stream().forEach(timeAlertRequest -> timeAlertRequest.getScalingPolicy().setScalingAdjustment(-10));
boolean underTestValid = underTest.isValid(request, validatorContext);
assertFalse("Target for Time Alert with Exact Adjustment cannot be negative.", underTestValid);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoscaleRequestValidatorTest method getTestRequest.
private DistroXAutoscaleClusterRequest getTestRequest(List<String> timeHostGroups, List<String> loadHostGroups, Optional<AdjustmentType> testAdjustmentType) {
DistroXAutoscaleClusterRequest testRequest = new DistroXAutoscaleClusterRequest();
List<TimeAlertRequest> timeAlertRequests = new ArrayList<>();
List<LoadAlertRequest> loadAlertRequests = new ArrayList<>();
if (timeHostGroups != null) {
for (String hostGroup : timeHostGroups) {
TimeAlertRequest request = new TimeAlertRequest();
ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
scalingPolicyRequest.setHostGroup(hostGroup);
scalingPolicyRequest.setAdjustmentType(testAdjustmentType.orElse(AdjustmentType.EXACT));
scalingPolicyRequest.setScalingAdjustment(10);
request.setScalingPolicy(scalingPolicyRequest);
timeAlertRequests.add(request);
}
testRequest.setTimeAlertRequests(timeAlertRequests);
}
if (loadHostGroups != null) {
for (String hostGroup : loadHostGroups) {
LoadAlertRequest request = new LoadAlertRequest();
ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
scalingPolicyRequest.setHostGroup(hostGroup);
scalingPolicyRequest.setAdjustmentType(testAdjustmentType.orElse(AdjustmentType.LOAD_BASED));
request.setScalingPolicy(scalingPolicyRequest);
loadAlertRequests.add(request);
}
testRequest.setLoadAlertRequests(loadAlertRequests);
}
return testRequest;
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterNameForLoadAlerts.
@Test
public void testUpdateAutoscaleConfigByClusterNameForLoadAlerts() {
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(1, List.of("compute"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
DistroXAutoscaleClusterResponse xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, distroXAutoscaleClusterRequest);
assertEquals("Retrieved Alerts Size Should Match", 1, xAutoscaleClusterResponse.getLoadAlerts().size());
assertTrue("Autoscaling should be enabled", xAutoscaleClusterResponse.isAutoscalingEnabled());
xAutoscaleClusterResponse.getLoadAlerts().stream().forEach(this::validateLoadAlertResponse);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testDeleteAlertByClusterNameForTimeAlerts.
@Test
public void testDeleteAlertByClusterNameForTimeAlerts() {
List<TimeAlertRequest> timeAlertRequests = getTimeAlertRequests(2, List.of("compute", "compute"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setTimeAlertRequests(timeAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
DistroXAutoscaleClusterResponse xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, distroXAutoscaleClusterRequest);
assertEquals("Retrieved Alerts Size Should Match", 2, xAutoscaleClusterResponse.getTimeAlerts().size());
distroXAutoScaleClusterV1Endpoint.deleteAlertsForClusterName(TEST_CLUSTER_NAME);
xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.getClusterByName(TEST_CLUSTER_NAME);
assertEquals("Retrieved Alerts Size Should Match", 0, xAutoscaleClusterResponse.getTimeAlerts().size());
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterCrnForEnableDisableStopStartScaling.
@Test
public void testUpdateAutoscaleConfigByClusterCrnForEnableDisableStopStartScaling() {
DistroXAutoscaleClusterRequest clusterRequest = new DistroXAutoscaleClusterRequest();
clusterRequest.setEnableAutoscaling(true);
clusterRequest.setUseStopStartMechanism(null);
DistroXAutoscaleClusterResponse clusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, clusterRequest);
assertFalse("StopStart scaling should be disabled if not specified in reuqest", clusterResponse.isStopStartScalingEnabled());
clusterRequest.setUseStopStartMechanism(true);
clusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, clusterRequest);
assertTrue("StopStart scaling should be enabled", clusterResponse.isStopStartScalingEnabled());
clusterRequest.setUseStopStartMechanism(false);
clusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, clusterRequest);
assertFalse("StopStart scaling should be disabled", clusterResponse.isStopStartScalingEnabled());
}
Aggregations