use of com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method getLoadAlertRequests.
private List<LoadAlertRequest> getLoadAlertRequests(Integer loadAlertRequestCount, List<String> computeGroups) {
List<LoadAlertRequest> loadRequests = new ArrayList();
IntStream.range(0, loadAlertRequestCount).forEach(loop -> {
LoadAlertRequest loadAlertRequest = new LoadAlertRequest();
loadAlertRequest.setAlertName("testalert");
LoadAlertConfigurationRequest loadAlertConfiguration = new LoadAlertConfigurationRequest();
loadAlertConfiguration.setMinResourceValue(MIN_RESOURCE_COUNT);
loadAlertConfiguration.setMaxResourceValue(MAX_RESOURCE_COUNT);
loadAlertConfiguration.setCoolDownMinutes(COOL_DOWN_MINUTES);
ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
scalingPolicyRequest.setAdjustmentType(LOAD_BASED);
scalingPolicyRequest.setHostGroup(computeGroups.get(loop));
loadAlertRequest.setScalingPolicy(scalingPolicyRequest);
loadAlertRequest.setLoadAlertConfiguration(loadAlertConfiguration);
loadRequests.add(loadAlertRequest);
});
return loadRequests;
}
use of com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testValidateDistroXAutoscaleClusterRequestWhenValidLoadAlertRequest.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenValidLoadAlertRequest() {
DistroXAutoscaleClusterRequest request = new DistroXAutoscaleClusterRequest();
ScalingPolicyRequest sp1 = new ScalingPolicyRequest();
sp1.setHostGroup("compute");
LoadAlertConfigurationRequest loadAlertConfigurationRequest = new LoadAlertConfigurationRequest();
loadAlertConfigurationRequest.setMaxResourceValue(10);
LoadAlertRequest loadAlertRequest = new LoadAlertRequest();
loadAlertRequest.setScalingPolicy(sp1);
loadAlertRequest.setLoadAlertConfiguration(loadAlertConfigurationRequest);
request.setLoadAlertRequests(List.of(loadAlertRequest));
Set<String> supportedHostGroups = Set.of("compute", "compute1", "compute3");
when(recommendationService.getAutoscaleRecommendations(anyString())).thenReturn(new AutoscaleRecommendationV4Response(supportedHostGroups, supportedHostGroups));
underTest.validateDistroXAutoscaleClusterRequest(aCluster, request);
}
use of com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testValidateDistroXAutoscaleClusterRequestWhenHostGroupNotSupported.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenHostGroupNotSupported() {
DistroXAutoscaleClusterRequest request = new DistroXAutoscaleClusterRequest();
ScalingPolicyRequest sp1 = new ScalingPolicyRequest();
sp1.setHostGroup("notsupported");
LoadAlertConfigurationRequest loadAlertConfigurationRequest = new LoadAlertConfigurationRequest();
loadAlertConfigurationRequest.setMaxResourceValue(10);
LoadAlertRequest loadAlertRequest = new LoadAlertRequest();
loadAlertRequest.setScalingPolicy(sp1);
loadAlertRequest.setLoadAlertConfiguration(loadAlertConfigurationRequest);
request.setLoadAlertRequests(List.of(loadAlertRequest));
Set<String> supportedHostGroups = Set.of("compute", "compute1", "compute3");
when(recommendationService.getAutoscaleRecommendations(anyString())).thenReturn(new AutoscaleRecommendationV4Response(supportedHostGroups, supportedHostGroups));
when(messagesService.getMessage(UNSUPPORTED_AUTOSCALING_HOSTGROUP, List.of(Set.of("notsupported"), AlertType.LOAD, aCluster.getStackName(), supportedHostGroups))).thenReturn("unsupported.hostgroup");
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("unsupported.hostgroup");
underTest.validateDistroXAutoscaleClusterRequest(aCluster, request);
}
use of com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testValidateDistroXAutoscaleClusterRequestWhenClusterSizeExceeded.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenClusterSizeExceeded() {
DistroXAutoscaleClusterRequest request = new DistroXAutoscaleClusterRequest();
ScalingPolicyRequest sp1 = new ScalingPolicyRequest();
sp1.setAdjustmentType(AdjustmentType.LOAD_BASED);
sp1.setHostGroup("compute");
LoadAlertConfigurationRequest loadAlertConfigurationRequest = new LoadAlertConfigurationRequest();
loadAlertConfigurationRequest.setMaxResourceValue(500);
LoadAlertRequest loadAlertRequest = new LoadAlertRequest();
loadAlertRequest.setScalingPolicy(sp1);
loadAlertRequest.setLoadAlertConfiguration(loadAlertConfigurationRequest);
request.setLoadAlertRequests(List.of(loadAlertRequest));
when(limitsConfigurationService.getMaxNodeCountLimit()).thenReturn(400);
when(messagesService.getMessage(AUTOSCALING_CLUSTER_LIMIT_EXCEEDED, List.of(400))).thenReturn("cluster limit exceeded");
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("cluster limit exceeded");
underTest.validateDistroXAutoscaleClusterRequest(aCluster, request);
}
Aggregations