Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

[JCLOUDS-1374]This is the first commit of Softlayer LoadBalancer API #1176

Closed
wants to merge 1 commit into from

Conversation

swaqos
Copy link

@swaqos swaqos commented Jan 26, 2018

Jira link: https://issues.apache.org/jira/browse/JCLOUDS-1374
The update focuses on adding SoftLayer LoadBalancer API to the features list of SoftLayer provider.

Domain type files:

  • Added LoadBalancer.java
  • Added LoadBalancerHealthMonitor.java
  • Added LoadBalancerListener.java
  • Added LoadBalancerListenerDefaultPool.java
  • Added LoadBalancerMember.java
  • Added LoadBalancerMemberHealth.java
  • Added LoadBalancerMemberPoolHealth.java
  • Added LoadBalancerProtocolConfiguration.java
  • Added LoadBalancerServerInstanceInformation.java
  • Added LoadBalancerServicePrice.java
  • Added LoadBalancerStatistics.java
  • Added LoadBalancerSubnetId.java
  • Added Location.java

Features:

  • Added LoadBalancerApi.java
  • Added LoadBalancerApiLiveTest.java
  • Added LoadBalancerApiMockTest.java
  • Added resource files for LoadBalancerApiMockTest.java

Notes:

  • The users are expected to set variables subnetId, servicePrices, and testInstancePrivateIp for LoadBalancerApiLiveTest.
  • Since the LoadBalancerApiLiveTest test cases are dependent on other test cases (some tests should take precedence), I had to set the threadCount to be 1 to avoid parallel REST calls in the pom.xml. Added after line 117 for <maven-surefire-plugin>
            <configuration>
              <parallel>methods</parallel>
              <threadCount>1</threadCount>
            </configuration>
  • The following is the test results of the LoadBalancerApiLiveTest:
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Running org.jclouds.softlayer.features.LoadBalancerApiLiveTest
Configuring TestNG with: TestNG652Configurator
Starting test testCreateLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
LoadBalancer service is fully created and ready to be tested.
[TestNG] Test testCreateLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 315135ms
Test suite progress: tests succeeded: 1, failed: 0, skipped: 0.
Starting test testAddLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testAddLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 32067ms
Test suite progress: tests succeeded: 2, failed: 0, skipped: 0.
Starting test testGetDatacenter(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetDatacenter(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 525ms
Test suite progress: tests succeeded: 3, failed: 0, skipped: 0.
Starting test testGetHealthMonitors(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetHealthMonitors(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 523ms
Test suite progress: tests succeeded: 4, failed: 0, skipped: 0.
Starting test testGetLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 440ms
Test suite progress: tests succeeded: 5, failed: 0, skipped: 0.
Starting test testGetLoadBalancerListeners(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerListeners(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 509ms
Test suite progress: tests succeeded: 6, failed: 0, skipped: 0.
Starting test testGetLoadBalancerObject(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerObject(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 500ms
Test suite progress: tests succeeded: 7, failed: 0, skipped: 0.
Starting test testGetLoadBalancerStatistics(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerStatistics(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 1061ms
Test suite progress: tests succeeded: 8, failed: 0, skipped: 0.
Starting test testListLoadBalancers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testListLoadBalancers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 461ms
Test suite progress: tests succeeded: 9, failed: 0, skipped: 0.
Starting test testUpdateLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testUpdateLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 978ms
Test suite progress: tests succeeded: 10, failed: 0, skipped: 0.
Starting test testAddLoadBalancerProtocols(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testAddLoadBalancerProtocols(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 33132ms
Test suite progress: tests succeeded: 11, failed: 0, skipped: 0.
Starting test testGetLoadBalancerMember(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerMember(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 525ms
Test suite progress: tests succeeded: 12, failed: 0, skipped: 0.
Starting test testGetLoadBalancerMemberHealth(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerMemberHealth(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 1079ms
Test suite progress: tests succeeded: 13, failed: 0, skipped: 0.
Starting test testGetLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 489ms
Test suite progress: tests succeeded: 14, failed: 0, skipped: 0.
Starting test testUpdateHealthMonitor(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testUpdateHealthMonitor(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 32393ms
Test suite progress: tests succeeded: 15, failed: 0, skipped: 0.
Starting test testUpdateLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testUpdateLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 523ms
Test suite progress: tests succeeded: 16, failed: 0, skipped: 0.
Starting test testGetHealthMonitor(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetHealthMonitor(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 457ms
Test suite progress: tests succeeded: 17, failed: 0, skipped: 0.
Starting test testDeleteLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testDeleteLoadBalancerMembers(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 32520ms
Test suite progress: tests succeeded: 18, failed: 0, skipped: 0.
Starting test testUpdateLoadBalancerProtocols(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testUpdateLoadBalancerProtocols(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 32929ms
Test suite progress: tests succeeded: 19, failed: 0, skipped: 0.
Starting test testGetLoadBalancerListener(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testGetLoadBalancerListener(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 467ms
Test suite progress: tests succeeded: 20, failed: 0, skipped: 0.
Starting test testDeleteLoadBalancerListener(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testDeleteLoadBalancerListener(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 34895ms
Test suite progress: tests succeeded: 21, failed: 0, skipped: 0.
Starting test testDeleteLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest)
[TestNG] Test testDeleteLoadBalancer(org.jclouds.softlayer.features.LoadBalancerApiLiveTest) succeeded: 62475ms
Test suite progress: tests succeeded: 22, failed: 0, skipped: 0.
Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 586.37 sec - in org.jclouds.softlayer.features.LoadBalancerApiLiveTest

Results :

Tests run: 22, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19:38 min
[INFO] Finished at: 2018-01-26T16:07:41-06:00
[INFO] Final Memory: 44M/499M
[INFO] ------------------------------------------------------------------------

@andreaturli
Copy link
Contributor

thx @swaqos it looks like a great PR: jira issue, good tests (with live tests results) and use of jclouds best practices!
Thanks, Ill review it properly asap

public void testCreateLoadBalancer() throws Exception {
assertTrue(subnetId != -1, "Please set the subnetId");
assertTrue(!testInstancePrivateIp.equals(""), "Please set the testInstancePrivateIp for Member functions testing");
loadBalancer = LoadBalancer.create(0, 0, "", new Date(), "", 0, 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you creating this mock obj instead of using line 108

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is because of the wait state at line 113-125, the assignment of the loadBalancer object needs to be created (not null) for the apply function.

@QueryParams(keys = "objectMask", values = NAME_MASK)
@Produces(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
LoadBalancer addLoadBalancerMembers(@WrapWith("parameters") List<Object> LoadBalancerMembersToBeAdded);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any better type than Object?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a lot of the LBaaS APIs, they are expecting the payload to be in the format of the mixture of LB uuid and the definition. For example, for updateLoadBalancerMembers, the payload is something like {"parameters": ["<load_balancer_uuid>", [{"uuid": "<load_balancer_member_uuid>", "weight": <weight>}]]}.

@QueryParams(keys = "objectMask", values = NAME_MASK)
@Produces(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
LoadBalancer updateLoadBalancerMembers(@WrapWith("parameters") List<Object> LoadBalancerMembersToBeUpdated);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any better type than Object?

@QueryParams(keys = "objectMask", values = NAME_MASK)
@Produces(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
LoadBalancer deleteLoadBalancerMembers(@WrapWith("parameters") List<Object> LoadBalancerMembersToBeDeleted);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any better type than Object?

@nacx
Copy link
Member

nacx commented Jan 30, 2018

Thanks @swaqos!

The users are expected to set variables subnetId, servicePrices, and testInstancePrivateIp for LoadBalancerApiLiveTest.

What are those properties needed for?

@swaqos
Copy link
Author

swaqos commented Jan 30, 2018

  • subnetId: This is the subnet id of which the load balancer instance will connect to, and which the back-end compute servers can reach. Description from load balancer doc "This subnet must have network connectivity with backend servers hosting your application. This means that the backend servers can be either on the same subnet as the one you select for the load balancer here, and/or the backend servers are on subnet(s) that have Layer-3 connectivity with the selected subnet (you may have to enable “VLAN Spanning” in this case). Note that the corresponding public subnet is automatically selected by the implementation.The load balancer uses two IP addresses from the private subnet, and three IP addresses from the public subnet. If sufficient IP addresses are not available, then the order or subsequent provisioning will fail."

  • servicePrices: These are just the priced items that are required by spinning up a load balancer instance. Users can retrieve relevant information through the following APIs:

    • Determine required product items of product package with id=805:
      curl -k -H 'Content-Type: application/json' 'https://'$SL_USER':'$SL_API'@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/805/getConfiguration?objectMask=isRequired;itemCategory.name;itemCategory.id' | jq .

    • Determine price identifiers of product items:
      curl -k -H 'Content-Type: application/json' 'https://'$SL_USER':'$SL_API'@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/805/getItemPrices?objectMask=id;item.description;categories.id;locations' | jq .

    • Determine datacenters, in which Bluemix LBaaS is available:
      curl -k -H 'Content-Type: application/json' 'https://'$SL_USER':'$SL_API'@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/805/getItemPrices?objectMask=id;item.description;categories.id;locations' | jq .

  • testInstancePrivateIp: This is the privateIp of a test instance from user that's going to be sitting behind the load balancer. Since we are not testing the performance of the load balancer, I just need one instance for testing the SoftLayer_Network_LBaaS_Member related APIs.

@swaqos swaqos closed this Jan 30, 2018
@nacx
Copy link
Member

nacx commented Jan 30, 2018

Thanks for the explanation. Would it make sense to do like we do in the Azure ARM load balancer live test and use the ComputeService to create the instance? That way you could probably extract the subnet and private ip from the created instance and get rid of those properties. We should try to have live tests that work out of the box.

@swaqos swaqos reopened this Jan 31, 2018
@swaqos
Copy link
Author

swaqos commented Jan 31, 2018

I totally understand that out of the box live tests would be nice and I would hope that too, but that would require other information for the new subnet (networkIdentifier, cider) and new machine, not to mention the extra time needed for this (it's now taking approximately 20 mins). I wonder if there's a better way to work around this.

@nacx
Copy link
Member

nacx commented Jan 31, 2018

Time is not an issue. Live tests are assumed to take their time.
What about my comment on creating the machine using the compute service? Could it be then created using the compute service defaults, and extract the subnet and address from the created instance?

@swaqos
Copy link
Author

swaqos commented Jan 31, 2018

I think creating a new virtualGuest is not a problem, but the problem is more with the network/subnets. I believe with the new CDN accounts, virtualGuest creations require subnetId as well, while I believe subnets need to live on private networks, and there are limit number of private networks(5), at least . Depending on how the private networks are configured, the number of subnets are limited, too, so I don't know if it's safe to assume there is room for them. I will need to do some more investigations on that.

@andreaturli
Copy link
Contributor

hi @swaqos any update on that?

@gaul
Copy link
Member

gaul commented Jul 25, 2020

Please reopen against apache/jclouds if this is still relevant.

@gaul gaul closed this Jul 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants