use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.
the class LoadAlertRequestConverterTest method testConvertLoadAlertRequestToLoadAlert.
@Test
public void testConvertLoadAlertRequestToLoadAlert() {
LoadAlertRequest req = new LoadAlertRequest();
req.setAlertName("loadalert");
req.setDescription("loadalertdesc");
ScalingPolicyRequest scalingPolicyRequest = getScalingPolicyRequest();
req.setScalingPolicy(scalingPolicyRequest);
when(scalingPolicyRequestConverter.convert(any(ScalingPolicyRequest.class))).thenCallRealMethod();
LoadAlert loadAlert = underTest.convert(req);
assertEquals("LoadAlert Name should match", loadAlert.getName(), "loadalert");
assertEquals("LoadAlert Desc should match", loadAlert.getDescription(), "loadalertdesc");
assertEquals("LoadAlert Hostgroup should match", loadAlert.getScalingPolicy().getHostGroup(), "compute");
assertEquals("LoadAlert Adjustment Type should match", loadAlert.getScalingPolicy().getAdjustmentType(), LOAD_BASED);
assertEquals("LoadAlert Adjustment should match", loadAlert.getScalingPolicy().getScalingAdjustment(), 10);
}
use of com.sequenceiq.periscope.api.model.LoadAlertRequest 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);
}
use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterCrnForMultipleLoadAlertsAndHostGroups.
@Test(expected = BadRequestException.class)
public void testUpdateAutoscaleConfigByClusterCrnForMultipleLoadAlertsAndHostGroups() {
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(2, List.of("group1", "group2"));
DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterCrn(TEST_CLUSTER_CRN, distroXAutoscaleClusterRequest);
}
use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.
the class DistroXAutoScaleClusterV1EndpointTest method testCreateTimeAlertWithPreExistingStopStartLoadAlert.
@Test(expected = BadRequestException.class)
public void testCreateTimeAlertWithPreExistingStopStartLoadAlert() {
DistroXAutoscaleClusterRequest autoscaleRequest = new DistroXAutoscaleClusterRequest();
List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(1, List.of("compute"));
autoscaleRequest.setLoadAlertRequests(loadAlertRequests);
autoscaleRequest.setUseStopStartMechanism(true);
autoscaleRequest.setEnableAutoscaling(true);
distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, autoscaleRequest);
List<TimeAlertRequest> timeAlertRequests = getTimeAlertRequests(2, List.of("compute", "compute"));
autoscaleRequest.setTimeAlertRequests(timeAlertRequests);
autoscaleRequest.setLoadAlertRequests(null);
autoscaleRequest.setUseStopStartMechanism(null);
distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, autoscaleRequest);
}
use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.
the class DistroXAutoscaleRequestValidatorTest method getTestRequest.
private DistroXAutoscaleClusterRequest getTestRequest(List<String> timeHostGroups, List<String> loadHostGroups, Optional<AdjustmentType> testAdjustmentType) {
DistroXAutoscaleClusterRequest testRequest = new DistroXAutoscaleClusterRequest();
List<TimeAlertRequest> timeAlertRequests = new ArrayList<>();
List<LoadAlertRequest> loadAlertRequests = new ArrayList<>();
if (timeHostGroups != null) {
for (String hostGroup : timeHostGroups) {
TimeAlertRequest request = new TimeAlertRequest();
ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
scalingPolicyRequest.setHostGroup(hostGroup);
scalingPolicyRequest.setAdjustmentType(testAdjustmentType.orElse(AdjustmentType.EXACT));
scalingPolicyRequest.setScalingAdjustment(10);
request.setScalingPolicy(scalingPolicyRequest);
timeAlertRequests.add(request);
}
testRequest.setTimeAlertRequests(timeAlertRequests);
}
if (loadHostGroups != null) {
for (String hostGroup : loadHostGroups) {
LoadAlertRequest request = new LoadAlertRequest();
ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
scalingPolicyRequest.setHostGroup(hostGroup);
scalingPolicyRequest.setAdjustmentType(testAdjustmentType.orElse(AdjustmentType.LOAD_BASED));
request.setScalingPolicy(scalingPolicyRequest);
loadAlertRequests.add(request);
}
testRequest.setLoadAlertRequests(loadAlertRequests);
}
return testRequest;
}
Aggregations