Search in sources :

Example 6 with TargetGroupConfigDbWrapper

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroupMissingAvailabilitySetInMetadata.

@Test
public void testConvertAzureTargetGroupMissingAvailabilitySetInMetadata() {
    Map<String, Object> azureParams = createAzureParams(1);
    azureParams.put(AzureLoadBalancerMetadataView.getAvailabilitySetParam(PORT2), null);
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(azureParams).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair1 = new TargetGroupPortPair(PORT1, PORT2);
    TargetGroupPortPair portPair2 = new TargetGroupPortPair(PORT2, PORT2);
    TargetGroupPortPair portPair3 = new TargetGroupPortPair(PORT3, PORT3);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair1, portPair2, portPair3));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
    assertEquals(Set.of(PORT1, PORT2, PORT3), azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet());
    List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
    assertEquals(List.of(AVAILABILITY_SET_NAME), availabilitySets);
    availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT2);
    assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
    availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT3);
    assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 7 with TargetGroupConfigDbWrapper

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAwsTargetGroup.

@Test
public void testConvertAwsTargetGroup() {
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAwsParams(1)).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AWS, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAwsConfig());
    AwsTargetGroupConfigDb awsTargetGroupConfigDb = targetGroupConfigDbWrapper.getAwsConfig();
    assertEquals(1, awsTargetGroupConfigDb.getPortArnMapping().size());
    assertEquals(PORT1, awsTargetGroupConfigDb.getPortArnMapping().keySet().iterator().next());
    AwsTargetGroupArnsDb targetGroupArns = awsTargetGroupConfigDb.getPortArnMapping().get(PORT1);
    assertEquals(LISTENER_ARN, targetGroupArns.getListenerArn());
    assertEquals(TARGET_ARN, targetGroupArns.getTargetGroupArn());
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AwsTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupConfigDb) AwsTargetGroupArnsDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupArnsDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 8 with TargetGroupConfigDbWrapper

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroup.

@Test
public void testConvertAzureTargetGroup() {
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAzureParams(1)).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
    assertEquals(1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().size());
    assertEquals(PORT1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet().iterator().next());
    List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
    assertEquals(1, availabilitySets.size());
    assertEquals(AVAILABILITY_SET_NAME, availabilitySets.get(0));
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 9 with TargetGroupConfigDbWrapper

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAwsTargetGroupMissingPortInMetadata.

@Test
public void testConvertAwsTargetGroupMissingPortInMetadata() {
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAwsParams(1)).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair1 = new TargetGroupPortPair(PORT1, PORT1);
    TargetGroupPortPair portPair2 = new TargetGroupPortPair(PORT2, PORT2);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair1, portPair2));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AWS, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAwsConfig());
    AwsTargetGroupConfigDb awsTargetGroupConfigDb = targetGroupConfigDbWrapper.getAwsConfig();
    assertEquals(2, awsTargetGroupConfigDb.getPortArnMapping().size());
    assertEquals(Set.of(PORT1, PORT2), awsTargetGroupConfigDb.getPortArnMapping().keySet());
    AwsTargetGroupArnsDb targetGroupArns = awsTargetGroupConfigDb.getPortArnMapping().get(PORT1);
    assertEquals(LISTENER_ARN, targetGroupArns.getListenerArn());
    assertEquals(TARGET_ARN, targetGroupArns.getTargetGroupArn());
    targetGroupArns = awsTargetGroupConfigDb.getPortArnMapping().get(PORT2);
    assertEquals(MISSING_CLOUD_RESOURCE, targetGroupArns.getListenerArn());
    assertEquals(MISSING_CLOUD_RESOURCE, targetGroupArns.getTargetGroupArn());
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AwsTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupConfigDb) AwsTargetGroupArnsDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupArnsDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 10 with TargetGroupConfigDbWrapper

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertGcpTargetGroup.

@Test
public void testConvertGcpTargetGroup() {
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(creatGcpParams(1)).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(GCP, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getGcpConfig());
    GcpTargetGroupConfigDb gcpTargetGroupConfigDb = targetGroupConfigDbWrapper.getGcpConfig();
    assertEquals(1, gcpTargetGroupConfigDb.getPortMapping().size());
    assertEquals(PORT1, gcpTargetGroupConfigDb.getPortMapping().keySet().iterator().next());
    GcpLoadBalancerNamesDb gcpLoadBalancerNamesDb = gcpTargetGroupConfigDb.getPortMapping().get(PORT1);
    assertEquals(BACKEND_SERVICE_NAME, gcpLoadBalancerNamesDb.getBackendServiceName());
    assertEquals(INSTANCE_GROUP_NAME, gcpLoadBalancerNamesDb.getInstanceGroupName());
}
Also used : GcpLoadBalancerNamesDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb) TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) GcpTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpTargetGroupConfigDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Aggregations

TargetGroupConfigDbWrapper (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper)13 TargetGroup (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup)10 TargetGroupPortPair (com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair)7 CloudLoadBalancerMetadata (com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata)6 AwsTargetGroupConfigDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupConfigDb)6 Test (org.junit.Test)6 AwsTargetGroupArnsDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupArnsDb)5 AzureTargetGroupConfigDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb)5 GcpLoadBalancerNamesDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb)4 GcpTargetGroupConfigDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpTargetGroupConfigDb)4 AwsLoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsLoadBalancerResponse)1 AwsTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse)1 AzureLoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureLoadBalancerResponse)1 AzureTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse)1 GcpLoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpLoadBalancerResponse)1 GcpTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse)1 LoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse)1 TargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.TargetGroupResponse)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1