naming + correct parameter/return type for addNodes

This commit is contained in:
danikov 2011-11-16 15:12:04 +00:00
parent f851271ae3
commit d44bf5d23e
4 changed files with 20 additions and 18 deletions

View File

@ -62,15 +62,15 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface NodeAsyncClient { public interface NodeAsyncClient {
/** /**
* @see NodeClient#createNode * @see NodeClient#addNodes
*/ */
@POST @POST
@ResponseParser(UnwrapNode.class) @ResponseParser(UnwrapNodes.class)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Path("/loadbalancers/{lbid}/nodes") @Path("/loadbalancers/{lbid}/nodes")
ListenableFuture<Node> createNode(@PathParam("lbid") int lbid, ListenableFuture<Set<Node>> addNodes(@PathParam("lbid") int lbid,
@WrapWith("node") NodeRequest n); @WrapWith("nodes") Set<NodeRequest> nodes);
/** /**
* @see NodeClient#modifyNode * @see NodeClient#modifyNode

View File

@ -52,14 +52,14 @@ public interface NodeClient {
* @param lbid * @param lbid
* loadbalancer on which to create the node * loadbalancer on which to create the node
* @param n * @param n
* configuration to create * configurations to create
* @return * @return created nodes
* @throws HttpResponseException * @throws HttpResponseException
* If the corresponding request cannot be fulfilled due to insufficient or invalid * If the corresponding request cannot be fulfilled due to insufficient or invalid
* data * data
* *
*/ */
Node createNode(int lbid, NodeRequest n); Set<Node> addNodes(int lbid, Set<NodeRequest> nodes);
/** /**
* *

View File

@ -107,22 +107,24 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
} }
} }
public void testCreateNode() throws Exception { public void testAddNodes() throws Exception {
for (LoadBalancer lb : nodes.keySet()) { for (LoadBalancer lb : nodes.keySet()) {
String region = lb.getRegion(); String region = lb.getRegion();
Logger.getAnonymousLogger().info("starting node on loadbalancer "+lb.getId()+" in region "+region); Logger.getAnonymousLogger().info("starting node on loadbalancer "+lb.getId()+" in region "+region);
Node n = client.getNodeClient(region).createNode(lb.getId(), Set<Node> newNodes = client.getNodeClient(region).addNodes(lb.getId(), Collections.<NodeRequest>singleton(
NodeRequest.builder().address("192.168.1.1").port(8080).build()); NodeRequest.builder().address("192.168.1.2").port(8080).build()));
assertEquals(lb.getStatus(), Node.Status.ONLINE);
for (Node n : newNodes) {
assertEquals(n.getStatus(), Node.Status.ONLINE);
nodes.get(lb).add(n); nodes.get(lb).add(n);
assertEquals(client.getNodeClient(region).getNode(lb.getId(), n.getId()).getStatus(), Node.Status.ONLINE); assertEquals(client.getNodeClient(region).getNode(lb.getId(), n.getId()).getStatus(), Node.Status.ONLINE);
}
Node newNode = client.getNodeClient(region).getNode(lb.getId(), n.getId()); assert loadBalancerActive.apply(lb) : lb;
assertEquals(newNode.getStatus(), Node.Status.ONLINE);
} }
} }
@Test(dependsOnMethods = "testCreateNode") @Test(dependsOnMethods = "testAddNodes")
public void testModifyNode() throws Exception { public void testModifyNode() throws Exception {
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) { for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
for (Node n : entry.getValue()) { for (Node n : entry.getValue()) {