Search in sources :

Example 21 with LoadBalancer

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

the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNNoLBs.

@Test
public void testGetLoadBalancerUserFacingFQDNNoLBs() {
    Set<LoadBalancer> loadBalancers = Set.of();
    when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
    String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
    assertNull(fqdn);
}
Also used : LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 22 with LoadBalancer

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

the class LoadBalancerConfigServiceTest method testGetLoadBalancerUserFacingFQDNNoPublicPrivateMissingFQDN.

@Test
public void testGetLoadBalancerUserFacingFQDNNoPublicPrivateMissingFQDN() {
    Set<LoadBalancer> loadBalancers = createPrivateOnlyLoadBalancer();
    LoadBalancer privateLoadBalancer = loadBalancers.stream().filter(lb -> LoadBalancerType.PRIVATE.equals(lb.getType())).findFirst().get();
    privateLoadBalancer.setFqdn(null);
    privateLoadBalancer.setIp(null);
    when(loadBalancerPersistenceService.findByStackId(0L)).thenReturn(loadBalancers);
    String fqdn = underTest.getLoadBalancerUserFacingFQDN(0L);
    assertEquals(PRIVATE_DNS, fqdn);
}
Also used : LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 23 with LoadBalancer

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

the class LoadBalancerConfigServiceTest method testCreateLoadBalancersForDatahubWithPrivateSubnet.

@Test
public void testCreateLoadBalancersForDatahubWithPrivateSubnet() {
    Stack stack = createAwsStack(StackType.WORKLOAD, PRIVATE_ID_1);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(true);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
        assertEquals(1, loadBalancers.size());
        assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.equals(l.getType()));
    });
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 24 with LoadBalancer

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

the class LoadBalancerConfigServiceTest method testCreateLoadBalancerNoAttributes.

@Test
public void testCreateLoadBalancerNoAttributes() {
    Stack stack = createAwsStack(StackType.DATALAKE, null);
    stack.getNetwork().setAttributes(null);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
        assert loadBalancers.isEmpty();
    });
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 25 with LoadBalancer

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

the class LoadBalancerConfigServiceTest method testCreateLoadBalancerNoSubnetSpecified.

@Test
public void testCreateLoadBalancerNoSubnetSpecified() {
    Stack stack = createAwsStack(StackType.DATALAKE, null);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AWS");
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    when(entitlementService.datalakeLoadBalancerEnabled(anyString())).thenReturn(true);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
        assert loadBalancers.isEmpty();
    });
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Aggregations

LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)74 Test (org.junit.Test)48 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)46 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)39 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)37 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)32 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)26 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)16 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)12 Test (org.junit.jupiter.api.Test)12 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 LoadBalancerPersistenceService (com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService)9 HashSet (java.util.HashSet)9 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)8 TargetGroup (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup)8 LoadBalancerType (com.sequenceiq.common.api.type.LoadBalancerType)8 Map (java.util.Map)8 Optional (java.util.Optional)8 Json (com.sequenceiq.cloudbreak.common.json.Json)7