use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testValidateDistroXAutoscaleClusterRequestWhenInvalidHostGroup.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenInvalidHostGroup() {
DistroXAutoscaleClusterRequest request = new DistroXAutoscaleClusterRequest();
List<TimeAlertRequest> timeAlertRequests = 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");
timeAlertRequests.add(timeAlertRequest1);
});
ScalingPolicyRequest sp2 = new ScalingPolicyRequest();
sp2.setHostGroup("computeNotSupported");
TimeAlertRequest timeAlertRequest2 = new TimeAlertRequest();
timeAlertRequest2.setScalingPolicy(sp2);
timeAlertRequest2.setCron("1 0 1 1 1 1");
timeAlertRequest2.setTimeZone("GMT");
timeAlertRequests.add(timeAlertRequest2);
request.setTimeAlertRequests(timeAlertRequests);
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("compute", "computeNotSupported"), AlertType.TIME, 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 testValidateDistroXAutoscaleClusterRequestWhenInvalidTimeZone.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenInvalidTimeZone() {
DistroXAutoscaleClusterRequest request = new DistroXAutoscaleClusterRequest();
List<TimeAlertRequest> timeAlertRequests = 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");
timeAlertRequests.add(timeAlertRequest1);
});
ScalingPolicyRequest sp2 = new ScalingPolicyRequest();
sp2.setHostGroup("compute3");
TimeAlertRequest timeAlertRequest2 = new TimeAlertRequest();
timeAlertRequest2.setScalingPolicy(sp2);
timeAlertRequest2.setCron("1 0 1 1 1 1");
timeAlertRequest2.setTimeZone("GMT-434343");
timeAlertRequests.add(timeAlertRequest2);
request.setTimeAlertRequests(timeAlertRequests);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Invalid ID for offset-based ZoneId: GMT-4343");
underTest.validateDistroXAutoscaleClusterRequest(aCluster, request);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testEnableStopStartInRequestWithTimeAlertPreCreated.
@Test
public void testEnableStopStartInRequestWithTimeAlertPreCreated() {
DistroXAutoscaleClusterRequest autoscaleRequest = new DistroXAutoscaleClusterRequest();
autoscaleRequest.setEnableAutoscaling(Boolean.TRUE);
autoscaleRequest.setUseStopStartMechanism(Boolean.TRUE);
TimeAlert timeAlert = new TimeAlert();
timeAlert.setTimeZone("Asia/Calcutta");
timeAlert.setCluster(aCluster);
timeAlert.setCron("1 0 1 1 1 1");
aCluster.setTimeAlerts(Set.of(timeAlert));
when(messagesService.getMessage(VALIDATION_TIME_STOP_START_UNSUPPORTED)).thenReturn("Schedule-Based Autoscaling does not support the stop / start scaling mechanism.");
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Schedule-Based Autoscaling does not support the stop / start scaling mechanism.");
underTest.validateScheduleWithStopStart(aCluster, autoscaleRequest);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testTimeAlertCreateWhenStopStartEnabledInRequest.
@Test
public void testTimeAlertCreateWhenStopStartEnabledInRequest() {
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.TRUE);
autoscaleClusterRequest.setTimeAlertRequests(timeAlerts);
when(messagesService.getMessage(VALIDATION_TIME_STOP_START_UNSUPPORTED)).thenReturn("Schedule-Based Autoscaling does not support the stop / start scaling mechanism.");
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Schedule-Based Autoscaling does not support the stop / start scaling mechanism.");
underTest.validateScheduleWithStopStart(aCluster, autoscaleClusterRequest);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigWhenMultipleAlertTypes.
@Test(expected = BadRequestException.class)
public void testUpdateAutoscaleConfigWhenMultipleAlertTypes() {
List<TimeAlertRequest> timeAlertRequests = getTimeAlertRequests(2, List.of("compute", "compute"));
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(2, List.of("group1", "group2"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setTimeAlertRequests(timeAlertRequests);
distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, distroXAutoscaleClusterRequest);
}
Aggregations