use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest 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.DistroXAutoscaleClusterRequest 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.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testCreateTimeAlertSuccessWithStopStartDisabled.
@Test
public void testCreateTimeAlertSuccessWithStopStartDisabled() {
DistroXAutoscaleClusterRequest autoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
List<TimeAlertRequest> timeAlerts = new ArrayList<>();
List.of("compute", "compute", "compute1").forEach(hostGroup -> {
ScalingPolicyRequest sp1 = new ScalingPolicyRequest();
sp1.setHostGroup("compute");
TimeAlertRequest timeAlertRequest1 = new TimeAlertRequest();
timeAlertRequest1.setScalingPolicy(sp1);
timeAlertRequest1.setCron("1 0 1 1 1 1");
timeAlertRequest1.setTimeZone("GMT");
timeAlerts.add(timeAlertRequest1);
});
autoscaleClusterRequest.setUseStopStartMechanism(Boolean.FALSE);
autoscaleClusterRequest.setTimeAlertRequests(timeAlerts);
assertDoesNotThrow(() -> underTest.validateScheduleWithStopStart(aCluster, autoscaleClusterRequest));
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest 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