use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class EnvironmentValidatorTest method createEnvironment.
private DetailedEnvironmentResponse createEnvironment(String cloudplatform, Map<String, CloudSubnet> subnetMetas) {
DetailedEnvironmentResponse env = new DetailedEnvironmentResponse();
env.setCloudPlatform(cloudplatform);
EnvironmentNetworkResponse network = createNetwork(subnetMetas);
env.setNetwork(network);
return env;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method setupForEndpointGateway.
private StackV4Request setupForEndpointGateway(boolean enabled) {
initMocks();
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
EnvironmentNetworkResponse networkResponse = new EnvironmentNetworkResponse();
networkResponse.setPublicEndpointAccessGateway(enabled ? PublicEndpointAccessGateway.ENABLED : PublicEndpointAccessGateway.DISABLED);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setTunnel(Tunnel.DIRECT);
environmentResponse.setTags(new TagResponse());
environmentResponse.setNetwork(networkResponse);
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
given(credentialClientService.getByCrn(anyString())).willReturn(credential);
given(credentialClientService.getByName(anyString())).willReturn(credential);
given(providerParameterCalculator.get(request)).willReturn(getMappable());
given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
given(loadBalancerConfigService.getKnoxGatewayGroups(any(Stack.class))).willReturn(Set.of("master"));
return request;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertToLegacyNetworkWithPublicEndpointAccessGatewayEnabled.
@Test
void testConvertToLegacyNetworkWithPublicEndpointAccessGatewayEnabled() {
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkAzureParams azure = mock(EnvironmentNetworkAzureParams.class);
CloudSubnet cloudSubnet = mock(CloudSubnet.class);
when(environmentNetworkResponse.getPublicEndpointAccessGateway()).thenReturn(PublicEndpointAccessGateway.ENABLED);
when(subnetSelector.chooseSubnet(any(), any(), any(), any())).thenReturn(Optional.of(cloudSubnet));
when(cloudSubnet.getId()).thenReturn("my_cloud_subnet");
when(environmentNetworkResponse.getAzure()).thenReturn(azure);
when(azure.getNetworkId()).thenReturn("my_network_id");
when(azure.getResourceGroupName()).thenReturn("my_resource_group");
when(azure.getNoPublicIp()).thenReturn(true);
Network result = converter.convertToLegacyNetwork(environmentNetworkResponse, "my-az");
assertEquals(CloudPlatform.AZURE.toString(), result.getAttributes().getMap().get(CLOUD_PLATFORM).toString());
assertFalse(result.getAttributes().getMap().containsKey(ENDPOINT_GATEWAY_SUBNET_ID));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class EnvironmentBaseNetworkConverterTest method testConvertToLegacyNetworkWhenSubnetFound.
@Test
public void testConvertToLegacyNetworkWhenSubnetFound() {
CloudSubnet subnet = getCloudSubnet(EU_AZ);
Map<String, CloudSubnet> metas = Map.of("key", subnet);
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(metas);
when(subnetSelector.chooseSubnet(any(), eq(metas), eq(EU_AZ), eq(SelectionFallbackStrategy.ALLOW_FALLBACK))).thenReturn(Optional.of(subnet));
Network[] network = new Network[1];
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
network[0] = underTest.convertToLegacyNetwork(source, EU_AZ);
});
assertEquals(network[0].getAttributes().getValue("subnetId"), "eu-west-1");
assertTrue(network[0].getNetworkCidrs().containsAll(NETWORK_CIDRS));
assertEquals(source.getOutboundInternetTraffic(), network[0].getOutboundInternetTraffic());
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class EnvironmentBaseNetworkConverterTest method testConvertToLegacyNetworkWithEndpointAccessGateway.
@Test
public void testConvertToLegacyNetworkWithEndpointAccessGateway() {
CloudSubnet privateSubnet = getCloudSubnet(AZ_1);
CloudSubnet publicSubnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", privateSubnet));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
source.setGatewayEndpointSubnetMetas(Map.of("public-key", publicSubnet));
when(subnetSelector.chooseSubnet(any(), eq(source.getSubnetMetas()), eq(AZ_1), eq(SelectionFallbackStrategy.ALLOW_FALLBACK))).thenReturn(Optional.of(privateSubnet));
when(subnetSelector.chooseSubnetForEndpointGateway(eq(source), eq(privateSubnet.getId()))).thenReturn(Optional.of(publicSubnet));
Network[] network = new Network[1];
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
network[0] = underTest.convertToLegacyNetwork(source, AZ_1);
});
assertEquals(PUBLIC_ID_1, network[0].getAttributes().getValue(ENDPOINT_GATEWAY_SUBNET_ID));
}
Aggregations