Search in sources :

Example 26 with DistroXAutoscaleClusterRequest

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);
}
Also used : LoadAlertConfigurationRequest(com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest) ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) AutoscaleRecommendationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.connector.responses.AutoscaleRecommendationV4Response) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) Test(org.junit.Test)

Example 27 with DistroXAutoscaleClusterRequest

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);
}
Also used : LoadAlertConfigurationRequest(com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest) ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) AutoscaleRecommendationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.connector.responses.AutoscaleRecommendationV4Response) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) Test(org.junit.Test)

Example 28 with DistroXAutoscaleClusterRequest

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));
}
Also used : ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) TimeAlertRequest(com.sequenceiq.periscope.api.model.TimeAlertRequest) ArrayList(java.util.ArrayList) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) Test(org.junit.Test)

Example 29 with DistroXAutoscaleClusterRequest

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);
}
Also used : LoadAlertConfigurationRequest(com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest) ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) Test(org.junit.Test)

Aggregations

DistroXAutoscaleClusterRequest (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest)29 Test (org.junit.Test)28 TimeAlertRequest (com.sequenceiq.periscope.api.model.TimeAlertRequest)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 LoadAlertRequest (com.sequenceiq.periscope.api.model.LoadAlertRequest)11 ScalingPolicyRequest (com.sequenceiq.periscope.api.model.ScalingPolicyRequest)11 DistroXAutoscaleClusterResponse (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse)8 ArrayList (java.util.ArrayList)8 AutoscaleRecommendationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.connector.responses.AutoscaleRecommendationV4Response)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 LoadAlertConfigurationRequest (com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest)3 TimeAlert (com.sequenceiq.periscope.domain.TimeAlert)1