Search in sources :

Example 6 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterNameForLoadAlerts.

@Test
public void testUpdateAutoscaleConfigByClusterNameForLoadAlerts() {
    List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(1, List.of("compute"));
    DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
    distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
    distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
    DistroXAutoscaleClusterResponse xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, 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 7 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method testDeleteAlertByClusterCrnForLoadAlerts.

@Test
public void testDeleteAlertByClusterCrnForLoadAlerts() {
    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());
    distroXAutoScaleClusterV1Endpoint.deleteAlertsForClusterCrn(TEST_CLUSTER_CRN);
    xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.getClusterByCrn(TEST_CLUSTER_CRN);
    assertEquals("Retrieved Alerts Size Should Match", 0, xAutoscaleClusterResponse.getLoadAlerts().size());
}
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 8 with LoadAlertRequest

use of com.sequenceiq.periscope.api.model.LoadAlertRequest in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method getLoadAlertRequests.

private List<LoadAlertRequest> getLoadAlertRequests(Integer loadAlertRequestCount, List<String> computeGroups) {
    List<LoadAlertRequest> loadRequests = new ArrayList();
    IntStream.range(0, loadAlertRequestCount).forEach(loop -> {
        LoadAlertRequest loadAlertRequest = new LoadAlertRequest();
        loadAlertRequest.setAlertName("testalert");
        LoadAlertConfigurationRequest loadAlertConfiguration = new LoadAlertConfigurationRequest();
        loadAlertConfiguration.setMinResourceValue(MIN_RESOURCE_COUNT);
        loadAlertConfiguration.setMaxResourceValue(MAX_RESOURCE_COUNT);
        loadAlertConfiguration.setCoolDownMinutes(COOL_DOWN_MINUTES);
        ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
        scalingPolicyRequest.setAdjustmentType(LOAD_BASED);
        scalingPolicyRequest.setHostGroup(computeGroups.get(loop));
        loadAlertRequest.setScalingPolicy(scalingPolicyRequest);
        loadAlertRequest.setLoadAlertConfiguration(loadAlertConfiguration);
        loadRequests.add(loadAlertRequest);
    });
    return loadRequests;
}
Also used : LoadAlertConfigurationRequest(com.sequenceiq.periscope.api.model.LoadAlertConfigurationRequest) ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) ArrayList(java.util.ArrayList) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest)

Example 9 with LoadAlertRequest

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

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

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