use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class MultiAzDecoratorTest method decorateStackRequestWithMultiAzShouldPickMultipleSubnetsWhenClusterShapeIsHA.
@Test
void decorateStackRequestWithMultiAzShouldPickMultipleSubnetsWhenClusterShapeIsHA() {
StackV4Request stackV4Request = new StackV4Request();
stackV4Request.setInstanceGroups(List.of(getInstanceGroupV4Request(InstanceGroupType.GATEWAY), getInstanceGroupV4Request(InstanceGroupType.CORE)));
Set<String> subnetIds = Set.of(PREFERRED_SUBNET_ID, PREFERRED_SUBNET_ID2);
EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
network.setPreferedSubnetId(PREFERRED_SUBNET_ID);
network.setPreferedSubnetIds(subnetIds);
network.setSubnetIds(subnetIds);
network.setSubnetMetas(Map.of(PREFERRED_SUBNET_ID, new CloudSubnet("id1", PREFERRED_SUBNET_ID, "eu-central-1a", "10.0.0.0/24", false, true, true, SubnetType.PUBLIC), PREFERRED_SUBNET_ID2, new CloudSubnet("id1", PREFERRED_SUBNET_ID2, "eu-central-1b", "10.0.1.0/24", false, true, true, SubnetType.PUBLIC)));
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setNetwork(network);
environment.setTunnel(Tunnel.DIRECT);
underTest.decorateStackRequestWithMultiAz(stackV4Request, environment, SdxClusterShape.MEDIUM_DUTY_HA);
Assertions.assertTrue(stackV4Request.getInstanceGroups().stream().allMatch(ig -> ig.getNetwork().getAws().getSubnetIds().containsAll(subnetIds)));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method validateVmTypeOverrideWhenDefaultVmTypeIsMissingFromAvailableVmTypes.
@Test
public void validateVmTypeOverrideWhenDefaultVmTypeIsMissingFromAvailableVmTypes() {
StackV4Request defaultTemplate = createStackRequest();
defaultTemplate.getInstanceGroups().get(0).getTemplate().setInstanceType("unknown");
when(cdpConfigService.getConfigForKey(any())).thenReturn(defaultTemplate);
when(environmentClientService.getVmTypesByCredential(anyString(), anyString(), anyString(), eq(CdpResourceType.DATALAKE), any())).thenReturn(createPlatformVmtypesResponse());
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.validateVmTypeOverride(createEnvironment("AWS"), createSdxCluster(createStackRequest(), LIGHT_DUTY)));
assertEquals("Missing vm type for default template instance group: master - unknown", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method createStackRequest.
private StackV4Request createStackRequest() {
StackV4Request defaultTemplate = new StackV4Request();
defaultTemplate.getInstanceGroups().add(createInstanceGroup("master", "large"));
defaultTemplate.getInstanceGroups().add(createInstanceGroup("idbroker", "medium"));
return defaultTemplate;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method testGetDefaultTemplate.
@Test
public void testGetDefaultTemplate() {
StackV4Request defaultTemplate = createStackRequest();
when(cdpConfigService.getConfigForKey(any())).thenReturn(defaultTemplate);
SdxDefaultTemplateResponse response = underTest.getDefaultTemplateResponse(LIGHT_DUTY, "7.2.14", "AWS");
assertEquals(defaultTemplate, response.getTemplate());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request 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");
}
Aggregations