use of com.sequenceiq.cloudbreak.cloud.azure.loadbalancer.AzureLoadBalancer in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method testGetModel.
@Test
void testGetModel() {
CloudStack mockCloudStack = mock(CloudStack.class);
Group targetGroup = new Group(INSTANCE_GROUP_NAME, InstanceGroupType.GATEWAY, List.of(new CloudInstance(INSTANCE_NAME, null, null, "subnet-1", "az1")), null, null, null, null, null, 64, null, createGroupNetwork(), emptyMap());
CloudLoadBalancer cloudLoadBalancer = new CloudLoadBalancer(LoadBalancerType.PRIVATE);
cloudLoadBalancer.addPortToTargetGroupMapping(new TargetGroupPortPair(443, 443), Set.of(targetGroup));
when(mockCloudStack.getLoadBalancers()).thenReturn(List.of(cloudLoadBalancer));
underTest = new AzureLoadBalancerModelBuilder(mockCloudStack, STACK_NAME);
Map<String, Object> result = underTest.buildModel();
assertTrue(result.containsKey(LOAD_BALANCERS_KEY));
assertTrue(result.get(LOAD_BALANCERS_KEY) instanceof List);
List<AzureLoadBalancer> loadBalancers = (List<AzureLoadBalancer>) result.get(LOAD_BALANCERS_KEY);
assertEquals(1, loadBalancers.size());
AzureLoadBalancer lb = loadBalancers.get(0);
assertEquals(LOAD_BALANCER_STACK_NAME, lb.getName());
assertEquals(LoadBalancerType.PRIVATE, lb.getType());
assertTrue(result.containsKey(LOAD_BALANCER_MAPPING_KEY));
assertTrue(result.get(LOAD_BALANCER_MAPPING_KEY) instanceof Map);
Map<String, List<AzureLoadBalancer>> mapping = (Map<String, List<AzureLoadBalancer>>) result.get(LOAD_BALANCER_MAPPING_KEY);
List<AzureLoadBalancer> mappingList = mapping.get(INSTANCE_GROUP_NAME);
assertEquals(1, mappingList.size());
assertEquals(LOAD_BALANCER_STACK_NAME, mappingList.get(0).getName());
}
use of com.sequenceiq.cloudbreak.cloud.azure.loadbalancer.AzureLoadBalancer in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method testGetModelWithOutboundLoadBalancer.
@Test
void testGetModelWithOutboundLoadBalancer() {
CloudStack mockCloudStack = mock(CloudStack.class);
CloudLoadBalancer privateLoadBalancer = createCloudLoadBalancer(LoadBalancerSku.STANDARD);
CloudLoadBalancer outboundLoadBalancer = createOutboundCloudLoadBalancer();
when(mockCloudStack.getLoadBalancers()).thenReturn(List.of(privateLoadBalancer, outboundLoadBalancer));
underTest = new AzureLoadBalancerModelBuilder(mockCloudStack, STACK_NAME);
Map<String, Object> result = underTest.buildModel();
assertTrue(result.containsKey(LOAD_BALANCERS_KEY));
assertTrue(result.get(LOAD_BALANCERS_KEY) instanceof List);
List<AzureLoadBalancer> loadBalancers = (List<AzureLoadBalancer>) result.get(LOAD_BALANCERS_KEY);
assertEquals(2, loadBalancers.size());
assertTrue(loadBalancers.stream().allMatch(lb -> LoadBalancerSku.STANDARD.equals(lb.getSku())));
assertTrue(loadBalancers.stream().anyMatch(lb -> LoadBalancerType.PRIVATE.equals(lb.getType())));
assertTrue(loadBalancers.stream().anyMatch(lb -> LoadBalancerType.OUTBOUND.equals(lb.getType())));
}
use of com.sequenceiq.cloudbreak.cloud.azure.loadbalancer.AzureLoadBalancer in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method testGetModelWithBasicSku.
@Test
void testGetModelWithBasicSku() {
CloudStack mockCloudStack = mock(CloudStack.class);
CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer(LoadBalancerSku.BASIC);
when(mockCloudStack.getLoadBalancers()).thenReturn(List.of(cloudLoadBalancer));
underTest = new AzureLoadBalancerModelBuilder(mockCloudStack, STACK_NAME);
Map<String, Object> result = underTest.buildModel();
assertTrue(result.containsKey(LOAD_BALANCERS_KEY));
assertTrue(result.get(LOAD_BALANCERS_KEY) instanceof List);
List<AzureLoadBalancer> loadBalancers = (List<AzureLoadBalancer>) result.get(LOAD_BALANCERS_KEY);
assertEquals(1, loadBalancers.size());
AzureLoadBalancer lb = loadBalancers.get(0);
assertEquals(LoadBalancerSku.BASIC, lb.getSku());
}
use of com.sequenceiq.cloudbreak.cloud.azure.loadbalancer.AzureLoadBalancer in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method testGetModelWithStandardSku.
@Test
void testGetModelWithStandardSku() {
CloudStack mockCloudStack = mock(CloudStack.class);
CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer(LoadBalancerSku.STANDARD);
when(mockCloudStack.getLoadBalancers()).thenReturn(List.of(cloudLoadBalancer));
underTest = new AzureLoadBalancerModelBuilder(mockCloudStack, STACK_NAME);
Map<String, Object> result = underTest.buildModel();
assertTrue(result.containsKey(LOAD_BALANCERS_KEY));
assertTrue(result.get(LOAD_BALANCERS_KEY) instanceof List);
List<AzureLoadBalancer> loadBalancers = (List<AzureLoadBalancer>) result.get(LOAD_BALANCERS_KEY);
assertEquals(1, loadBalancers.size());
AzureLoadBalancer lb = loadBalancers.get(0);
assertEquals(LoadBalancerSku.STANDARD, lb.getSku());
}
use of com.sequenceiq.cloudbreak.cloud.azure.loadbalancer.AzureLoadBalancer in project cloudbreak by hortonworks.
the class AzureLoadBalancerModelBuilderTest method testGetModelWithDefaultSku.
@Test
void testGetModelWithDefaultSku() {
CloudStack mockCloudStack = mock(CloudStack.class);
CloudLoadBalancer cloudLoadBalancer = createCloudLoadBalancer();
when(mockCloudStack.getLoadBalancers()).thenReturn(List.of(cloudLoadBalancer));
underTest = new AzureLoadBalancerModelBuilder(mockCloudStack, STACK_NAME);
Map<String, Object> result = underTest.buildModel();
assertTrue(result.containsKey(LOAD_BALANCERS_KEY));
assertTrue(result.get(LOAD_BALANCERS_KEY) instanceof List);
List<AzureLoadBalancer> loadBalancers = (List<AzureLoadBalancer>) result.get(LOAD_BALANCERS_KEY);
assertEquals(1, loadBalancers.size());
AzureLoadBalancer lb = loadBalancers.get(0);
assertEquals(LoadBalancerSku.getDefault(), lb.getSku());
}
Aggregations