use of com.sequenceiq.periscope.api.model.LoadAlertRequest 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.LoadAlertRequest 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.LoadAlertRequest 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