Search in sources :

Example 1 with ScaleRecommendation

use of com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation in project cloudbreak by hortonworks.

the class CloudResourceAdvisorTest method testReturnScaleRecommendationForBlueprintWhenCloudManagerVersionGreaterThanEqualTo721.

@Test
public void testReturnScaleRecommendationForBlueprintWhenCloudManagerVersionGreaterThanEqualTo721() {
    when(blueprintTextProcessor.getVersion()).thenReturn(java.util.Optional.of(VERSION_7_2_1));
    when(entitlementService.getEntitlements(anyString())).thenReturn(Collections.emptyList());
    Blueprint blueprint = createBlueprint();
    when(blueprintTextProcessorFactory.createBlueprintTextProcessor("{\"Blueprints\":{123:2}}")).thenReturn(blueprintTextProcessor);
    when(blueprintTextProcessor.recommendAutoscale(any())).thenReturn(new AutoscaleRecommendation(Set.of("compute"), Set.of("compute")));
    when(blueprintTextProcessor.recommendResize(anyList(), any())).thenReturn(new ResizeRecommendation(Set.of("compute"), Set.of("compute")));
    ScaleRecommendation scaleRecommendation = underTest.createForBlueprint(this.workspace.getId(), blueprint);
    assertEquals(new AutoscaleRecommendation(Set.of("compute"), Set.of("compute")), scaleRecommendation.getAutoscaleRecommendation());
    assertEquals(new ResizeRecommendation(Set.of("compute"), Set.of("compute")), scaleRecommendation.getResizeRecommendation());
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) ScaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Test(org.junit.Test)

Example 2 with ScaleRecommendation

use of com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation in project cloudbreak by hortonworks.

the class CloudResourceAdvisorTest method testReturnEmptyScaleRecommendationForBlueprintWhenCloudManagerVersionLessThanEqualTo720.

@Test
public void testReturnEmptyScaleRecommendationForBlueprintWhenCloudManagerVersionLessThanEqualTo720() {
    when(blueprintTextProcessor.getVersion()).thenReturn(java.util.Optional.of(VERSION_7_2_0));
    when(entitlementService.getEntitlements(anyString())).thenReturn(Collections.emptyList());
    Blueprint blueprint = createBlueprint();
    when(blueprintTextProcessorFactory.createBlueprintTextProcessor("{\"Blueprints\":{123:2}}")).thenReturn(blueprintTextProcessor);
    when(blueprintTextProcessor.recommendResize(anyList(), any())).thenReturn(new ResizeRecommendation(Set.of(), Set.of()));
    ScaleRecommendation scaleRecommendation = underTest.createForBlueprint(this.workspace.getId(), blueprint);
    assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), scaleRecommendation.getAutoscaleRecommendation());
    assertEquals(new ResizeRecommendation(Set.of(), Set.of()), scaleRecommendation.getResizeRecommendation());
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) ScaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Test(org.junit.Test)

Example 3 with ScaleRecommendation

use of com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation in project cloudbreak by hortonworks.

the class CloudResourceAdvisor method createForBlueprint.

public ScaleRecommendation createForBlueprint(Long workspaceId, Blueprint blueprint) {
    LOGGER.debug("Scale advice for blueprintName: {}.", blueprint.getName());
    BlueprintTextProcessor blueprintTextProcessor = getBlueprintTextProcessor(blueprint);
    AutoscaleRecommendation autoscale = recommendAutoscale(blueprintTextProcessor);
    List<String> entitlements = entitlementService.getEntitlements(blueprint.getWorkspace().getTenant().getName());
    ResizeRecommendation resize = recommendResize(blueprintTextProcessor, entitlements);
    return new ScaleRecommendation(autoscale, resize);
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) ScaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)

Aggregations

AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)3 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)3 ScaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Test (org.junit.Test)2 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)1