use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AzureMetadataCollectorTest method testCollectSinglePublicLoadBalancer.
@Test
public void testCollectSinglePublicLoadBalancer() {
List<CloudResource> resources = new ArrayList<>();
CloudResource cloudResource = createCloudResource();
when(authenticatedContext.getCloudContext()).thenReturn(mockCloudContext);
when(mockCloudContext.getName()).thenReturn(RESOURCE_GROUP_NAME);
when(azureUtils.getTemplateResource(resources)).thenReturn(cloudResource);
when(azureUtils.getStackName(any())).thenReturn(STACK_NAME);
final String loadBalancerName = AzureLoadBalancer.getLoadBalancerName(LoadBalancerType.PUBLIC, STACK_NAME);
when(azureClient.getLoadBalancerIps(RESOURCE_GROUP_NAME, loadBalancerName, LoadBalancerType.PUBLIC)).thenReturn(List.of(PUBLIC_IP));
when(authenticatedContext.getParameter(AzureClient.class)).thenReturn(azureClient);
when(azureLbMetadataCollector.getParameters(any(), anyString(), anyString())).thenReturn(Map.of());
List<CloudLoadBalancerMetadata> result = underTest.collectLoadBalancer(authenticatedContext, List.of(LoadBalancerType.PUBLIC), resources);
assertEquals(1, result.size());
assertEquals(PUBLIC_IP, result.get(0).getIp());
assertEquals(LoadBalancerType.PUBLIC, result.get(0).getType());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class LoadBalancerMetadataService method collectMetadata.
public List<CloudLoadBalancerMetadata> collectMetadata(CloudContext cloudContext, CloudCredential cloudCredential, List<LoadBalancerType> types, List<CloudResource> cloudResources) {
LOGGER.debug("Initiating load balancer metadata collection");
CloudConnector<Object> connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, cloudCredential);
List<CloudLoadBalancerMetadata> loadBalancerStatuses = connector.metadata().collectLoadBalancer(ac, types, cloudResources);
LOGGER.debug("Load balancer metadata collection successfully finished. Collected metadata: {}", loadBalancerStatuses);
return loadBalancerStatuses;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AwsMetaDataCollectorTest method testCollectLoadBalancers.
@Test
public void testCollectLoadBalancers() {
setupMethodsForLoadBalancer(true);
AuthenticatedContext ac = authenticatedContext();
List<CloudLoadBalancerMetadata> metadata = awsMetadataCollector.collectLoadBalancer(ac, List.of(LoadBalancerType.PRIVATE, LoadBalancerType.PUBLIC), null);
assertEquals(2, metadata.size());
Optional<CloudLoadBalancerMetadata> internalMetadata = metadata.stream().filter(m -> m.getType() == LoadBalancerType.PRIVATE).findFirst();
assertTrue(internalMetadata.isPresent());
assertEquals(INTERNAL_LB_DNS, internalMetadata.get().getCloudDns());
assertEquals(ZONE_1, internalMetadata.get().getHostedZoneId());
Optional<CloudLoadBalancerMetadata> externalMetadata = metadata.stream().filter(m -> m.getType() == LoadBalancerType.PUBLIC).findFirst();
assertTrue(externalMetadata.isPresent());
assertEquals(EXTERNAL_LB_DNS, externalMetadata.get().getCloudDns());
assertEquals(ZONE_2, externalMetadata.get().getHostedZoneId());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AwsMetaDataCollectorTest method testCollectLoadBalancerMissingMetadata.
@Test
public void testCollectLoadBalancerMissingMetadata() {
setupMethodsForLoadBalancer(false);
when(awsLoadBalancerMetadataCollector.getParameters(any(), any(), any())).thenReturn(Map.of());
AuthenticatedContext ac = authenticatedContext();
List<CloudLoadBalancerMetadata> metadata = awsMetadataCollector.collectLoadBalancer(ac, List.of(LoadBalancerType.PRIVATE, LoadBalancerType.PUBLIC), null);
assertEquals(1, metadata.size());
Optional<CloudLoadBalancerMetadata> externalMetadata = metadata.stream().filter(m -> m.getType() == LoadBalancerType.PUBLIC).findFirst();
assertTrue(externalMetadata.isPresent());
assertEquals(LoadBalancerType.PUBLIC, metadata.iterator().next().getType());
assertEquals(EXTERNAL_LB_DNS, metadata.iterator().next().getCloudDns());
assertEquals(ZONE_2, metadata.iterator().next().getHostedZoneId());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AwsMetaDataCollectorTest method testCollectLoadBalancerOnlyEndpointAccessGateway.
@MockitoSettings(strictness = Strictness.LENIENT)
@Test
public void testCollectLoadBalancerOnlyEndpointAccessGateway() {
setupMethodsForLoadBalancer(true);
when(awsLoadBalancerMetadataCollector.getParameters(any(), any(), any())).thenReturn(Map.of());
AuthenticatedContext ac = authenticatedContext();
List<CloudLoadBalancerMetadata> metadata = awsMetadataCollector.collectLoadBalancer(ac, List.of(LoadBalancerType.PUBLIC), null);
assertEquals(1, metadata.size());
Optional<CloudLoadBalancerMetadata> externalMetadata = metadata.stream().filter(m -> m.getType() == LoadBalancerType.PUBLIC).findFirst();
assertTrue(externalMetadata.isPresent());
assertEquals(EXTERNAL_LB_DNS, externalMetadata.get().getCloudDns());
assertEquals(ZONE_2, externalMetadata.get().getHostedZoneId());
}
Aggregations