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