use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse 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.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method getEnvironmentResponse.
private DetailedEnvironmentResponse getEnvironmentResponse() {
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setName("env");
detailedEnvironmentResponse.setEnvironmentStatus(EnvironmentStatus.AVAILABLE);
CompactRegionResponse compactRegionResponse = new CompactRegionResponse();
compactRegionResponse.setNames(Lists.newArrayList("eu-west-1"));
compactRegionResponse.setDisplayNames(Map.of("eu-west-1", "ireland"));
detailedEnvironmentResponse.setRegions(compactRegionResponse);
detailedEnvironmentResponse.setCrn(CrnTestUtil.getEnvironmentCrnBuilder().setResource(UUID.randomUUID().toString()).setAccountId(UUID.randomUUID().toString()).build().toString());
EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
network.setCrn(CrnTestUtil.getNetworkCrnBuilder().setResource(UUID.randomUUID().toString()).setAccountId(UUID.randomUUID().toString()).build().toString());
EnvironmentNetworkAwsParams environmentNetworkAwsParams = new EnvironmentNetworkAwsParams();
environmentNetworkAwsParams.setVpcId("vpc");
network.setAws(environmentNetworkAwsParams);
network.setSubnetIds(Sets.newHashSet("subnet"));
CloudSubnet cloudSubnet = new CloudSubnet();
cloudSubnet.setId("subnet");
cloudSubnet.setName("subnet");
cloudSubnet.setAvailabilityZone("eu-west-1a");
Map<String, CloudSubnet> cloudSubnetMap = Map.of("subnet", cloudSubnet);
network.setSubnetMetas(cloudSubnetMap);
detailedEnvironmentResponse.setNetwork(network);
EnvironmentAuthenticationResponse authentication = new EnvironmentAuthenticationResponse();
authentication.setPublicKey("ssh-public-key");
detailedEnvironmentResponse.setAuthentication(authentication);
return detailedEnvironmentResponse;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class MultiAzDecoratorTest method decorateStackRequestWithMultiAzShouldPickMultipleSubnetsButOneSubnetPerAzForGatewayGroupWhenClusterShapeIsHA.
@Test
void decorateStackRequestWithMultiAzShouldPickMultipleSubnetsButOneSubnetPerAzForGatewayGroupWhenClusterShapeIsHA() {
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-1a", "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 -> InstanceGroupType.GATEWAY.equals(ig.getType()) ? ig.getNetwork().getAws().getSubnetIds().size() == 1 : ig.getNetwork().getAws().getSubnetIds().containsAll(subnetIds)));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class NetworkDtoToResponseConverterTest method testConvertWithMockParams.
@Test
void testConvertWithMockParams() {
NetworkDto network = createNetworkDto().withMock(createMockParams()).build();
ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
assertCommonFields(network, actual);
assertEquals(network.getMock().getVpcId(), actual.getMock().getVpcId());
assertEquals(network.getMock().getInternetGatewayId(), actual.getMock().getInternetGatewayId());
assertNull(actual.getAws());
assertNull(actual.getYarn());
assertNull(actual.getAzure());
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class NetworkDtoToResponseConverterTest method testConvertWithAzureParams.
@Test
void testConvertWithAzureParams() {
NetworkDto network = createNetworkDto().withAzure(createAzureParams()).build();
ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
assertCommonFields(network, actual);
assertEquals(network.getAzure().isNoPublicIp(), actual.getAzure().getNoPublicIp());
assertEquals(network.getAzure().getNetworkId(), actual.getAzure().getNetworkId());
assertEquals(network.getAzure().getResourceGroupName(), actual.getAzure().getResourceGroupName());
assertNull(actual.getAws());
assertNull(actual.getYarn());
assertNull(actual.getMock());
}
Aggregations