use of com.sequenceiq.sdx.api.model.SdxRecommendationResponse in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method testGetRecommendation.
@Test
public void testGetRecommendation() {
when(cdpConfigService.getConfigForKey(any())).thenReturn(createStackRequest());
when(environmentClientService.getVmTypesByCredential(anyString(), anyString(), anyString(), eq(CdpResourceType.DATALAKE), any())).thenReturn(createPlatformVmtypesResponse());
SdxRecommendationResponse recommendation = underTest.getRecommendation("cred", LIGHT_DUTY, "7.2.14", "AWS", "ec-central-1", null);
StackV4Request defaultTemplate = recommendation.getTemplate();
assertNotNull(defaultTemplate);
assertThat(defaultTemplate.getInstanceGroups()).hasSize(2).extracting(ig -> ig.getName(), ig -> ig.getTemplate().getInstanceType()).containsExactlyInAnyOrder(tuple("master", "large"), tuple("idbroker", "medium"));
Map<String, List<com.sequenceiq.sdx.api.model.VmTypeResponse>> availableVmTypesByInstanceGroup = recommendation.getAvailableVmTypesByInstanceGroup();
assertThat(availableVmTypesByInstanceGroup).containsOnlyKeys("master", "idbroker");
assertThat(availableVmTypesByInstanceGroup.get("master")).extracting(vmType -> vmType.getValue()).containsExactlyInAnyOrder("large");
assertThat(availableVmTypesByInstanceGroup.get("idbroker")).extracting(vmType -> vmType.getValue()).containsExactlyInAnyOrder("large", "medium", "mediumv2");
}
use of com.sequenceiq.sdx.api.model.SdxRecommendationResponse in project cloudbreak by hortonworks.
the class SdxRecommendationService method getRecommendation.
public SdxRecommendationResponse getRecommendation(String credentialCrn, SdxClusterShape clusterShape, String runtimeVersion, String cloudPlatform, String region, String availabilityZone) {
try {
StackV4Request defaultTemplate = getDefaultTemplate(clusterShape, runtimeVersion, cloudPlatform);
List<VmTypeResponse> availableVmTypes = getAvailableVmTypes(credentialCrn, cloudPlatform, region, availabilityZone);
Map<String, VmTypeResponse> defaultVmTypesByInstanceGroup = getDefaultVmTypesByInstanceGroup(availableVmTypes, defaultTemplate);
Map<String, List<VmTypeResponse>> availableVmTypesByInstanceGroup = filterAvailableVmTypesBasedOnDefault(availableVmTypes, defaultVmTypesByInstanceGroup);
LOGGER.debug("Return default template and available vm types for clusterShape: {}, " + "runtimeVersion: {}, cloudPlatform: {}, region: {}, availabilityZone: {}", clusterShape, runtimeVersion, cloudPlatform, region, availabilityZone);
return new SdxRecommendationResponse(defaultTemplate, availableVmTypesByInstanceGroup);
} catch (NotFoundException | BadRequestException e) {
throw e;
} catch (Exception e) {
LOGGER.warn("Getting recommendation failed!", e);
throw new RuntimeException("Getting recommendation failed: " + e.getMessage());
}
}
Aggregations