Search in sources :

Example 11 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest 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 12 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest 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 13 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest 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

LoadAlertRequest (com.sequenceiq.periscope.api.model.LoadAlertRequest)13 DistroXAutoscaleClusterRequest (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest)11 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ScalingPolicyRequest (com.sequenceiq.periscope.api.model.ScalingPolicyRequest)6 LoadAlertConfigurationRequest (com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest)4 DistroXAutoscaleClusterResponse (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse)3 TimeAlertRequest (com.sequenceiq.periscope.api.model.TimeAlertRequest)3 AutoscaleRecommendationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.connector.responses.AutoscaleRecommendationV4Response)2 ArrayList (java.util.ArrayList)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 LoadAlert (com.sequenceiq.periscope.domain.LoadAlert)1