Search in sources :

Example 6 with SubnetRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.

the class AwsNetworkCfTemplateProviderTest method testProvideWhenPrivateSubnetsAreDisabledAndInterfaceServicesWithDifferentAzs.

@Test
public void testProvideWhenPrivateSubnetsAreDisabledAndInterfaceServicesWithDifferentAzs() throws IOException, TemplateException {
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-vpcendpoints-differentazs.json"));
    when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
    AmazonEc2Client ec2Client = mock(AmazonEc2Client.class);
    when(awsClient.createEc2Client(any(), anyString())).thenReturn(ec2Client);
    when(ec2Client.describeVpcEndpointServices()).thenReturn(createDescribeVpcEndpointServicesResultWithDifferentAzs());
    NetworkCreationRequest networkCreationRequest = createNetworkRequest(false, PrivateEndpointType.USE_VPC_ENDPOINT);
    List<SubnetRequest> subnetRequestList = createPublicSubnetRequestList();
    String actual = underTest.provide(networkCreationRequest, subnetRequestList);
    JsonNode json = objectMapper.readTree(actual);
    assertEquals(expectedJson, json);
    verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
Also used : SubnetRequest(com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest) NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with SubnetRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.

the class AwsNetworkCfTemplateProviderTest method createPublicSubnetRequestList.

private static List<SubnetRequest> createPublicSubnetRequestList() {
    SubnetRequest subnetRequest1 = new SubnetRequest();
    subnetRequest1.setPublicSubnetCidr("2.2.2.2/24");
    subnetRequest1.setIndex(0);
    subnetRequest1.setSubnetGroup(0);
    subnetRequest1.setAvailabilityZone("az1");
    SubnetRequest subnetRequest2 = new SubnetRequest();
    subnetRequest2.setPublicSubnetCidr("2.2.2.2/24");
    subnetRequest2.setIndex(1);
    subnetRequest2.setSubnetGroup(1);
    subnetRequest2.setAvailabilityZone("az2");
    SubnetRequest subnetRequest3 = new SubnetRequest();
    subnetRequest3.setPublicSubnetCidr("2.2.2.2/24");
    subnetRequest3.setIndex(2);
    subnetRequest3.setSubnetGroup(2);
    subnetRequest3.setAvailabilityZone("az3");
    SubnetRequest subnetRequest4 = new SubnetRequest();
    subnetRequest4.setPublicSubnetCidr("2.2.2.2/24");
    subnetRequest4.setIndex(3);
    subnetRequest4.setSubnetGroup(3);
    subnetRequest4.setAvailabilityZone("az4");
    return List.of(subnetRequest1, subnetRequest2, subnetRequest3, subnetRequest4);
}
Also used : SubnetRequest(com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest)

Example 8 with SubnetRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.

the class AwsNetworkCfTemplateProviderTest method testProvideWhenPrivateSubnetsAndInterfaceServicesAreDisabled.

@Test
public void testProvideWhenPrivateSubnetsAndInterfaceServicesAreDisabled() throws IOException, TemplateException {
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-privatesubnet-onlygatewayvpcendpoints.json"));
    when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
    NetworkCreationRequest networkCreationRequest = createNetworkRequest(true, PrivateEndpointType.NONE);
    List<SubnetRequest> subnetRequestList = createPrivateAndPublicSubnetRequestList();
    String actual = underTest.provide(networkCreationRequest, subnetRequestList);
    JsonNode json = objectMapper.readTree(actual);
    assertEquals(expectedJson, json);
    verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
Also used : SubnetRequest(com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest) NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with SubnetRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.

the class AwsNetworkCfTemplateProviderTest method testProvideWhenPublicSubnetsAndInterfaceServicesAreDisabled.

@Test
public void testProvideWhenPublicSubnetsAndInterfaceServicesAreDisabled() throws IOException, TemplateException {
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-onlygatewayvpcendpoints.json"));
    when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
    NetworkCreationRequest networkCreationRequest = createNetworkRequest(false, PrivateEndpointType.NONE);
    List<SubnetRequest> subnetRequestList = createPrivateAndPublicSubnetRequestList();
    String actual = underTest.provide(networkCreationRequest, subnetRequestList);
    JsonNode json = objectMapper.readTree(actual);
    assertEquals(expectedJson, json);
    verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
Also used : SubnetRequest(com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest) NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with SubnetRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.

the class AwsNetworkCfTemplateProviderTest method testProvideWhenOnlyPublicSubnetsAndInterfaceServicesWithDifferentAzs.

@Test
public void testProvideWhenOnlyPublicSubnetsAndInterfaceServicesWithDifferentAzs() throws IOException, TemplateException {
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-vpcendpoints-differentazs.json"));
    when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
    AmazonEc2Client ec2Client = mock(AmazonEc2Client.class);
    when(awsClient.createEc2Client(any(), anyString())).thenReturn(ec2Client);
    when(ec2Client.describeVpcEndpointServices()).thenReturn(createDescribeVpcEndpointServicesResultWithDifferentAzs());
    NetworkCreationRequest networkCreationRequest = createNetworkRequest(true, PrivateEndpointType.USE_VPC_ENDPOINT);
    List<SubnetRequest> subnetRequestList = createPublicSubnetRequestList();
    String actual = underTest.provide(networkCreationRequest, subnetRequestList);
    JsonNode json = objectMapper.readTree(actual);
    assertEquals(expectedJson, json);
    verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
Also used : SubnetRequest(com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest) NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Template(freemarker.template.Template) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SubnetRequest (com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest)27 NetworkSubnetRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkSubnetRequest)12 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)11 AmazonEc2Client (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client)9 Template (freemarker.template.Template)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)5 CreatedSubnet (com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet)5 File (java.io.File)5 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)4 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)4 ArrayList (java.util.ArrayList)4 AmazonCloudFormationClient (com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient)3 HashSet (java.util.HashSet)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2