Search in sources :

Example 6 with AutoscaleRecommendation

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

the class CmTemplateProcessorTest method recommendAutoscale.

@Test
public void recommendAutoscale() {
    Versioned blueprintVersion = () -> "7.2.11";
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-multi-gateway.bp"));
    assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), underTest.recommendAutoscale(blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/namenode-ha.bp"));
    assertEquals(new AutoscaleRecommendation(Set.of("gateway"), Set.of("gateway")), underTest.recommendAutoscale(blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/kafka.bp"));
    assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), underTest.recommendAutoscale(blueprintVersion));
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    assertEquals(new AutoscaleRecommendation(Set.of("compute"), Set.of("compute")), underTest.recommendAutoscale(blueprintVersion));
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Test(org.junit.jupiter.api.Test)

Example 7 with AutoscaleRecommendation

use of com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation 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 8 with AutoscaleRecommendation

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

the class CloudResourceAdvisorTest method testRecommendAutoscaleWhenCloudManagerVersionLessThanEqualTo720.

@Test
public void testRecommendAutoscaleWhenCloudManagerVersionLessThanEqualTo720() {
    when(blueprintTextProcessor.getVersion()).thenReturn(java.util.Optional.of(VERSION_7_2_0));
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{\"Blueprints\":{123:2}}");
    when(blueprintTextProcessorFactory.createBlueprintTextProcessor("{\"Blueprints\":{123:2}}")).thenReturn(blueprintTextProcessor);
    when(blueprintService.getByNameForWorkspaceId(any(), anyLong())).thenReturn(blueprint);
    assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), underTest.getAutoscaleRecommendation(workspace.getId(), TEST_BLUEPRINT_NAME));
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Test(org.junit.Test)

Example 9 with AutoscaleRecommendation

use of com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation 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)9 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 Test (org.junit.Test)4 ScaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.ScaleRecommendation)3 Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)2 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)2 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)1 GatewayRecommendation (com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation)1 InstanceCount (com.sequenceiq.cloudbreak.cloud.model.InstanceCount)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 VmRecommendations (com.sequenceiq.cloudbreak.cloud.model.VmRecommendations)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1