Search in sources :

Example 21 with DistroXAutoscaleClusterRequest

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);
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 22 with DistroXAutoscaleClusterRequest

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);
}
Also used : LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 23 with 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);
}
Also used : ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) AutoscaleRecommendationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.connector.responses.AutoscaleRecommendationV4Response) TimeAlertRequest(com.sequenceiq.periscope.api.model.TimeAlertRequest) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) Test(org.junit.Test)

Example 24 with DistroXAutoscaleClusterRequest

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);
}
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 25 with DistroXAutoscaleClusterRequest

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));
}
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)

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