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