Search in sources :

Example 6 with LoadBalancerState

use of com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState in project photon-model by vmware.

the class AzureLoadBalancerServiceTest method testCreateLoadBalancerWithInvalidNICTarget.

@Test
public void testCreateLoadBalancerWithInvalidNICTarget() throws Throwable {
    if (!this.isMock) {
        LoadBalancerState loadBalancerState = createLoadBalancerState(this.loadBalancerName, LoadBalancerTargetType.INVALID);
        ProvisionLoadBalancerTaskState provisionLoadBalancerTaskState = startLoadBalancerProvisioning(LoadBalancerInstanceRequest.InstanceRequestType.CREATE, loadBalancerState, TaskStage.FAILED);
        assertTrue(provisionLoadBalancerTaskState.taskInfo.stage == TaskStage.FAILED);
        assertEquals("java.lang.IllegalArgumentException: Invalid target type specified", provisionLoadBalancerTaskState.taskInfo.failure.message);
    }
}
Also used : LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState) ProvisionLoadBalancerTaskState(com.vmware.photon.controller.model.tasks.ProvisionLoadBalancerTaskService.ProvisionLoadBalancerTaskState) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) Test(org.junit.Test)

Example 7 with LoadBalancerState

use of com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState in project photon-model by vmware.

the class AzureLoadBalancerServiceTest method provisionLoadBalancer.

private LoadBalancerState provisionLoadBalancer(TaskStage stage, LoadBalancerTargetType loadBalancerTargetType) throws Throwable {
    LoadBalancerState loadBalancerState = createLoadBalancerState(this.loadBalancerName, loadBalancerTargetType);
    startLoadBalancerProvisioning(LoadBalancerInstanceRequest.InstanceRequestType.CREATE, loadBalancerState, stage);
    return getHost().getServiceState(null, LoadBalancerState.class, UriUtils.buildUri(getHost(), loadBalancerState.documentSelfLink));
}
Also used : LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)

Example 8 with LoadBalancerState

use of com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState in project photon-model by vmware.

the class TestAWSEnumerationTask method validateLoadBalancerState.

private void validateLoadBalancerState(String lbName, String computeLink) throws Throwable {
    LoadBalancerState loadBalancerState = getLoadBalancerByAWSId(this.host, lbName);
    assertEquals(count1, loadBalancerState.computeLinks.size());
    assertEquals(count1, loadBalancerState.securityGroupLinks.size());
    assertEquals(count1, loadBalancerState.subnetLinks.size());
    assertEquals(computeLink, loadBalancerState.computeLinks.iterator().next());
    assertNotNull(loadBalancerState.routes);
    assertEquals(count1, loadBalancerState.routes.size());
    RouteConfiguration route = loadBalancerState.routes.iterator().next();
    assertNotNull(route.healthCheckConfiguration);
    assertEquals("80", route.port);
    assertEquals("80", route.instancePort);
    assertEquals("HTTP", route.instanceProtocol);
    assertEquals("HTTP", route.protocol);
}
Also used : RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)

Example 9 with LoadBalancerState

use of com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState in project photon-model by vmware.

the class AWSLoadBalancerServiceTest method createLoadBalancerState.

private LoadBalancerState createLoadBalancerState(String name) throws Throwable {
    LoadBalancerState state = new LoadBalancerState();
    state.name = name;
    state.endpointLink = this.endpointState.documentSelfLink;
    state.endpointLinks = new HashSet<String>();
    state.endpointLinks.add(this.endpointState.documentSelfLink);
    state.regionId = this.regionId;
    state.computeLinks = Collections.singleton(this.cs1.documentSelfLink);
    state.subnetLinks = new HashSet<>();
    state.subnetLinks.add(createSubnetState(this.subnetId, createNetworkState(this.vpcId).documentSelfLink).documentSelfLink);
    RouteConfiguration route1 = new RouteConfiguration();
    route1.protocol = Protocol.HTTP.name();
    route1.port = "80";
    route1.instanceProtocol = Protocol.HTTP.name();
    route1.instancePort = "80";
    route1.healthCheckConfiguration = new HealthCheckConfiguration();
    route1.healthCheckConfiguration.protocol = Protocol.HTTP.name();
    route1.healthCheckConfiguration.port = "80";
    route1.healthCheckConfiguration.urlPath = "/test.html";
    route1.healthCheckConfiguration.intervalSeconds = 60;
    route1.healthCheckConfiguration.healthyThreshold = 2;
    route1.healthCheckConfiguration.unhealthyThreshold = 5;
    route1.healthCheckConfiguration.timeoutSeconds = 5;
    RouteConfiguration route2 = new RouteConfiguration();
    route2.protocol = Protocol.HTTPS.name();
    route2.port = "443";
    route2.instanceProtocol = Protocol.HTTPS.name();
    route2.instancePort = "443";
    state.routes = Arrays.asList(route1, route2);
    state.internetFacing = Boolean.TRUE;
    state.instanceAdapterReference = UriUtils.buildUri(this.host, AWSLoadBalancerService.SELF_LINK);
    return postServiceSynchronously(LoadBalancerService.FACTORY_LINK, state, LoadBalancerState.class);
}
Also used : HealthCheckConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration) RouteConfiguration(com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)

Example 10 with LoadBalancerState

use of com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState in project photon-model by vmware.

the class AzureLoadBalancerServiceTest method testCreateLoadBalancerWithComputeTarget.

@Test
public void testCreateLoadBalancerWithComputeTarget() throws Throwable {
    securityGroupState = createSecurityGroupState(this.host, endpointState, this.securityGroupName, Lists.newArrayList(), Lists.newArrayList());
    kickOffSecurityGroupProvision(SecurityGroupInstanceRequest.InstanceRequestType.CREATE, TaskStage.FINISHED);
    LoadBalancerState loadBalancerState = provisionLoadBalancer(TaskStage.FINISHED, LoadBalancerTargetType.COMPUTE);
    assertNotNull(loadBalancerState.id);
    assertNotEquals(loadBalancerState.id, this.loadBalancerName);
    if (!this.isMock) {
        // Verify that the load balancer was created.
        LoadBalancerInner lbResponse = this.loadBalancerClient.getByResourceGroup(this.rgName, this.loadBalancerName);
        assertEquals(this.loadBalancerName, lbResponse.name());
        assertEquals(loadBalancerState.id, lbResponse.id());
        assertNotNull(loadBalancerState.address);
        // delete the load balancer
        startLoadBalancerProvisioning(LoadBalancerInstanceRequest.InstanceRequestType.DELETE, loadBalancerState, TaskStage.FINISHED);
    }
}
Also used : LoadBalancerInner(com.microsoft.azure.management.network.implementation.LoadBalancerInner) LoadBalancerState(com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) Test(org.junit.Test)

Aggregations

LoadBalancerState (com.vmware.photon.controller.model.resources.LoadBalancerService.LoadBalancerState)14 Test (org.junit.Test)6 AzureBaseTest (com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)5 LoadBalancerInner (com.microsoft.azure.management.network.implementation.LoadBalancerInner)4 RouteConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.RouteConfiguration)4 HealthCheckConfiguration (com.vmware.photon.controller.model.resources.LoadBalancerDescriptionService.LoadBalancerDescription.HealthCheckConfiguration)2 SecurityGroupState (com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState)2 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)1 ListenerDescription (com.amazonaws.services.elasticloadbalancing.model.ListenerDescription)1 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)1 BaseModelTest (com.vmware.photon.controller.model.helpers.BaseModelTest)1 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)1 ImageState (com.vmware.photon.controller.model.resources.ImageService.ImageState)1 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)1 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)1 ResourceGroupState (com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)1 RouterState (com.vmware.photon.controller.model.resources.RouterService.RouterState)1 StorageDescription (com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription)1