mirror of https://github.com/apache/jclouds.git
reverted an accidental commit of several files; added editing to load balancer
This commit is contained in:
parent
86471b0a5a
commit
d8d88c3321
|
@ -58,17 +58,6 @@ public interface GridLoadBalancerAsyncClient {
|
||||||
@Path("/grid/loadbalancer/list")
|
@Path("/grid/loadbalancer/list")
|
||||||
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
|
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
|
||||||
|
|
||||||
/**
|
|
||||||
* @see GridLoadBalancerClient#addLoadBalancer
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
|
||||||
@Path("/grid/loadbalancer/add")
|
|
||||||
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam("name") String name,
|
|
||||||
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
|
|
||||||
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
|
|
||||||
AddLoadBalancerOptions... options);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridLoadBalancerClient#getLoadBalancersByName
|
* @see GridLoadBalancerClient#getLoadBalancersByName
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +74,26 @@ public interface GridLoadBalancerAsyncClient {
|
||||||
@Path("/grid/loadbalancer/get")
|
@Path("/grid/loadbalancer/get")
|
||||||
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
|
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see GridLoadBalancerClient#addLoadBalancer
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
||||||
|
@Path("/grid/loadbalancer/add")
|
||||||
|
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam("name") String name,
|
||||||
|
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
|
||||||
|
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
|
||||||
|
AddLoadBalancerOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see GridLoadBalancerClient#editLoadBalancer
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
||||||
|
@Path("/grid/loadbalancer/edit")
|
||||||
|
ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam("loadbalancer") String idOrName,
|
||||||
|
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridLoadBalancerClient#
|
* @see GridLoadBalancerClient#
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,6 +39,26 @@ public interface GridLoadBalancerClient {
|
||||||
*/
|
*/
|
||||||
Set<LoadBalancer> getLoadBalancerList();
|
Set<LoadBalancer> getLoadBalancerList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the load balancer(s) by unique name(s).
|
||||||
|
*
|
||||||
|
* Given a name or a set of names, finds one or
|
||||||
|
* multiple load balancers.
|
||||||
|
* @param names to get the load balancers
|
||||||
|
* @return load balancer(s) matching the name(s)
|
||||||
|
*/
|
||||||
|
Set<LoadBalancer> getLoadBalancersByName(String... names);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the load balancer(s) by unique id(s).
|
||||||
|
*
|
||||||
|
* Given an id or a set of ids, finds one or
|
||||||
|
* multiple load balancers.
|
||||||
|
* @param ids to get the load balancers
|
||||||
|
* @return load balancer(s) matching the ids
|
||||||
|
*/
|
||||||
|
Set<LoadBalancer> getLoadBalancersById(Long... ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a load balancer with given properties.
|
* Creates a load balancer with given properties.
|
||||||
*
|
*
|
||||||
|
@ -60,24 +80,18 @@ public interface GridLoadBalancerClient {
|
||||||
AddLoadBalancerOptions... options);
|
AddLoadBalancerOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the load balancer(s) by unique name(s).
|
* Edits the existing load balancer to change the real
|
||||||
|
* IP mapping.
|
||||||
*
|
*
|
||||||
* Given a name or a set of names, finds one or
|
* @param idOrName id or name of the existing load balancer
|
||||||
* multiple load balancers.
|
* @param realIps real IPs to bind the virtual IP to, with
|
||||||
* @param names to get the load balancers
|
* IP address set in
|
||||||
* @return load balancer(s) matching the name(s)
|
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||||
|
* port set in {@link IpPortPair#port}
|
||||||
|
* @return edited object
|
||||||
*/
|
*/
|
||||||
Set<LoadBalancer> getLoadBalancersByName(String... names);
|
LoadBalancer editLoadBalancer(String idOrName,
|
||||||
|
List<IpPortPair> realIps);
|
||||||
/**
|
|
||||||
* Returns the load balancer(s) by unique id(s).
|
|
||||||
*
|
|
||||||
* Given an id or a set of ids, finds one or
|
|
||||||
* multiple load balancers.
|
|
||||||
* @param ids to get the load balancers
|
|
||||||
* @return load balancer(s) matching the ids
|
|
||||||
*/
|
|
||||||
Set<LoadBalancer> getLoadBalancersById(Long... ids);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the load balancer by Id
|
* Deletes the load balancer by Id
|
||||||
|
|
|
@ -186,11 +186,12 @@ public class GoGridLiveTest {
|
||||||
GetIpListOptions ipOptions = new GetIpListOptions.Builder().unassignedPublicIps();
|
GetIpListOptions ipOptions = new GetIpListOptions.Builder().unassignedPublicIps();
|
||||||
Set<Ip> availableIps = client.getIpServices().getIpList(ipOptions);
|
Set<Ip> availableIps = client.getIpServices().getIpList(ipOptions);
|
||||||
|
|
||||||
if(availableIps.size() < 3) throw new SkipException("Not enough available IPs (3 needed) to run the test");
|
if(availableIps.size() < 4) throw new SkipException("Not enough available IPs (4 needed) to run the test");
|
||||||
Iterator<Ip> ipIterator = availableIps.iterator();
|
Iterator<Ip> ipIterator = availableIps.iterator();
|
||||||
Ip vip = ipIterator.next();
|
Ip vip = ipIterator.next();
|
||||||
Ip realIp1 = ipIterator.next();
|
Ip realIp1 = ipIterator.next();
|
||||||
Ip realIp2 = ipIterator.next();
|
Ip realIp2 = ipIterator.next();
|
||||||
|
Ip realIp3 = ipIterator.next();
|
||||||
|
|
||||||
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().
|
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().
|
||||||
create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
||||||
|
@ -206,10 +207,17 @@ public class GoGridLiveTest {
|
||||||
assert (response.size() == 1);
|
assert (response.size() == 1);
|
||||||
createdLoadBalancer = Iterables.getOnlyElement(response);
|
createdLoadBalancer = Iterables.getOnlyElement(response);
|
||||||
assertNotNull(createdLoadBalancer.getRealIpList());
|
assertNotNull(createdLoadBalancer.getRealIpList());
|
||||||
assert createdLoadBalancer.getRealIpList().size() == 2;
|
assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
|
||||||
assertNotNull(createdLoadBalancer.getVirtualIp());
|
assertNotNull(createdLoadBalancer.getVirtualIp());
|
||||||
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
||||||
|
|
||||||
|
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().
|
||||||
|
editLoadBalancer(nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181)));
|
||||||
|
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
||||||
|
assertNotNull(editedLoadBalancer.getRealIpList());
|
||||||
|
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
||||||
|
assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(), realIp3.getIp());
|
||||||
|
|
||||||
int lbCountAfterAddingOneServer = client.getLoadBalancerServices().getLoadBalancerList().size();
|
int lbCountAfterAddingOneServer = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||||
assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 :
|
assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 :
|
||||||
"There should be +1 increase in the number of load balancers since the test started";
|
"There should be +1 increase in the number of load balancers since the test started";
|
||||||
|
|
|
@ -118,6 +118,38 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
||||||
assertPayloadEquals(httpRequest, null);
|
assertPayloadEquals(httpRequest, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
|
||||||
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer",
|
||||||
|
String.class, List.class);
|
||||||
|
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||||
|
"BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
||||||
|
new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||||
|
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||||
|
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpRequest, "");
|
||||||
|
assertPayloadEquals(httpRequest, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||||
|
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||||
|
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&" +
|
||||||
|
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||||
|
"HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpRequest, "");
|
||||||
|
assertPayloadEquals(httpRequest, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
|
public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class);
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class);
|
||||||
|
|
Loading…
Reference in New Issue