use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterCrnForLoadAlerts.
@Test
public void testUpdateAutoscaleConfigByClusterCrnForLoadAlerts() {
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(1, List.of("compute"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
DistroXAutoscaleClusterResponse xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, 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 testUpdateAutoscaleConfigByClusterCrnForMultipleLoadAlerts.
@Test(expected = BadRequestException.class)
public void testUpdateAutoscaleConfigByClusterCrnForMultipleLoadAlerts() {
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(2, List.of("compute", "compute"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, distroXAutoscaleClusterRequest);
}
use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest in project cloudbreak by hortonworks.
the class AlertValidatorTest method testValidateDistroXAutoscaleClusterRequestWhenValidTimeAlertRequest.
@Test
public void testValidateDistroXAutoscaleClusterRequestWhenValidTimeAlertRequest() {
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);
});
request.setTimeAlertRequests(timeAlertRequests);
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 testTimeAlertCreateWhenStopStartEnabledInClusterEntity.
@Test
public void testTimeAlertCreateWhenStopStartEnabledInClusterEntity() {
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);
});
aCluster.setStopStartScalingEnabled(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 AlertValidatorTest method testCreateTimeAlertSuccessIfStopStartDisabledInRequestButEnabledInClusterEntity.
@Test
public void testCreateTimeAlertSuccessIfStopStartDisabledInRequestButEnabledInClusterEntity() {
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);
aCluster.setStopStartScalingEnabled(Boolean.TRUE);
assertDoesNotThrow(() -> underTest.validateScheduleWithStopStart(aCluster, autoscaleClusterRequest));
}
Aggregations