mirror of https://github.com/apache/jclouds.git
Issue 639:Memory scaling for GoGrid vm's
This commit is contained in:
parent
6ff1738e8a
commit
32fe309424
|
@ -92,6 +92,7 @@
|
|||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<threadCount>1</threadCount>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>test.gogrid.endpoint</name>
|
||||
|
|
|
@ -88,4 +88,9 @@ public class Option implements Comparable<Option> {
|
|||
public int compareTo(Option o) {
|
||||
return Longs.compare(id, o.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", name=" + name + ", description=" + description + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
|
||||
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
|
||||
import org.jclouds.gogrid.domain.Option;
|
||||
|
@ -70,7 +69,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
@RequestFilters(SharedKeyLiteAuthentication.class)
|
||||
@QueryParams(keys = VERSION, values = GoGridAsyncClient.VERSION)
|
||||
@QueryParams(keys = VERSION, values = "1.6")
|
||||
public interface GridServerAsyncClient {
|
||||
|
||||
/**
|
||||
|
@ -165,6 +164,15 @@ public interface GridServerAsyncClient {
|
|||
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
|
||||
ListenableFuture<Set<Option>> getRamSizes();
|
||||
|
||||
/**
|
||||
* @see GridServerClient#getTypes
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseOptionsFromJsonResponse.class)
|
||||
@Path("/common/lookup/list")
|
||||
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
|
||||
ListenableFuture<Set<Option>> getTypes();
|
||||
|
||||
/**
|
||||
* @see GridServerClient#getDatacenters
|
||||
*/
|
||||
|
@ -173,4 +181,32 @@ public interface GridServerAsyncClient {
|
|||
@Path("/common/lookup/list")
|
||||
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
|
||||
ListenableFuture<Set<Option>> getDatacenters();
|
||||
|
||||
|
||||
/**
|
||||
* @see GridServerClient#editServerDescription
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseServerFromJsonResponse.class)
|
||||
@Path("/grid/server/edit")
|
||||
ListenableFuture<Server> editServerDescription(@QueryParam("id") long id,
|
||||
@QueryParam("description") String newDescription);
|
||||
|
||||
/**
|
||||
* @see GridServerClient#editServerRam
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseServerFromJsonResponse.class)
|
||||
@Path("/grid/server/edit")
|
||||
ListenableFuture<Server> editServerRam(@QueryParam("id") long id,
|
||||
@QueryParam("server.ram") String ram);
|
||||
|
||||
/**
|
||||
* @see GridServerClient#editServerType
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseServerFromJsonResponse.class)
|
||||
@Path("/grid/server/edit")
|
||||
ListenableFuture<Server> editServerType(@QueryParam("id") long id,
|
||||
@QueryParam("server.type") String newType);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,39 @@ public interface GridServerClient {
|
|||
*/
|
||||
Server deleteByName(String name);
|
||||
|
||||
/**
|
||||
* Edits an existing server
|
||||
*
|
||||
* @param id
|
||||
* id of the existing server
|
||||
* @param newDescription
|
||||
* description to replace the current one
|
||||
* @return edited server
|
||||
*/
|
||||
Server editServerDescription(long id, String newDescription);
|
||||
|
||||
/**
|
||||
* Edits an existing server
|
||||
*
|
||||
* @param id
|
||||
* id of the existing server
|
||||
* @param idOrNameOfType
|
||||
* type to replace the current one
|
||||
* @return edited server
|
||||
*/
|
||||
Server editServerType(long id, String idOrNameOfType);
|
||||
|
||||
/**
|
||||
* Edits an existing server
|
||||
*
|
||||
* @param id
|
||||
* id of the existing server
|
||||
* @param idOrNameOfRam
|
||||
* ram to replace the current one
|
||||
* @return edited server
|
||||
*/
|
||||
Server editServerRam(long id, String idOrNameOfRam);
|
||||
|
||||
/**
|
||||
* Retrieves the list of supported RAM configurations. The objects will have
|
||||
* RAM ID, name and description. In most cases, id or name will be used for
|
||||
|
@ -153,6 +186,14 @@ public interface GridServerClient {
|
|||
*/
|
||||
Set<Option> getRamSizes();
|
||||
|
||||
/**
|
||||
* Retrieves the list of supported server types, for example Web/App Server and Database Server. In most cases, id
|
||||
* or name will be used for {@link #editServerType}.
|
||||
*
|
||||
* @return supported server types
|
||||
*/
|
||||
Set<Option> getTypes();
|
||||
|
||||
/**
|
||||
* Retrieves the list of supported Datacenters to launch servers into. The
|
||||
* objects will have datacenter ID, name and description. In most cases, id
|
||||
|
|
|
@ -18,18 +18,33 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.compute;
|
||||
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static org.jclouds.compute.predicates.NodePredicates.inGroup;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||
import org.jclouds.gogrid.GoGridClient;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "live", singleThreaded = true, testName = "GoGridComputeServiceLiveTest")
|
||||
public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
public GoGridComputeServiceLiveTest() {
|
||||
|
@ -42,7 +57,34 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
}
|
||||
|
||||
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
|
||||
// hostname is not completely predictable based on node metadata
|
||||
assert execResponse.getOutput().trim().startsWith(node1.getName()) : execResponse + ": " + node1;
|
||||
// hostname is not predictable based on node metadata
|
||||
}
|
||||
|
||||
public void testResizeRam() throws Exception {
|
||||
String group = this.group + "ram";
|
||||
RestContext<GoGridClient, GoGridAsyncClient> providerContext = client.getContext().getProviderSpecificContext();
|
||||
try {
|
||||
client.destroyNodesMatching(inGroup(group));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
RetryablePredicate<Server> serverLatestJobCompleted = new RetryablePredicate<Server>(
|
||||
new ServerLatestJobCompleted(providerContext.getApi().getJobServices()), 800, 20, TimeUnit.SECONDS);
|
||||
|
||||
String ram = Iterables.get(providerContext.getApi().getServerServices().getRamSizes(), 1).getName();
|
||||
try {
|
||||
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1));
|
||||
|
||||
Server updatedServer = providerContext.getApi().getServerServices().editServerRam(new Long(node.getId()), ram);
|
||||
assertNotNull(updatedServer);
|
||||
assert serverLatestJobCompleted.apply(updatedServer);
|
||||
|
||||
assertEquals(
|
||||
Iterables.getLast(providerContext.getApi().getServerServices().getServersById(new Long(node.getId())))
|
||||
.getRam().getName(), ram);
|
||||
|
||||
} finally {
|
||||
client.destroyNodesMatching(inGroup(group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
Method method = GridServerAsyncClient.class.getMethod("getServerList", GetServerListOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?v=1.5 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?v=1.6 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
|
||||
+ "v=1.5&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
+ "v=1.6&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
new GetServerListOptions.Builder().onlySandboxServers());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?v=1.5&isSandbox=true HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/server/list?v=1.6&isSandbox=true HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
|
||||
+ "v=1.5&isSandbox=true&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
+ "v=1.6&isSandbox=true&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
Method method = GridServerAsyncClient.class.getMethod("getServersByName", String[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "server1");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.5&name=server1 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.5&name=server1&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&name=server1&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -119,7 +119,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
Method method = GridServerAsyncClient.class.getMethod("getServersById", long[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 123L);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.5&id=123 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.5&id=123&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&id=123&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -143,7 +143,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
HttpRequest httpRequest = processor.createRequest(method, "serverName", "img55",
|
||||
"memory", "127.0.0.1");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?v=1.5&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?v=1.6&"
|
||||
+ "name=serverName&server.ram=memory&image=img55&ip=127.0.0.1 " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -156,7 +156,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?"
|
||||
+ "v=1.5&name=serverName&server.ram=memory&" + "image=img55&ip=127.0.0.1&"
|
||||
+ "v=1.6&name=serverName&server.ram=memory&" + "image=img55&ip=127.0.0.1&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -171,7 +171,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.5&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.6&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.5&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy&sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.6&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy&sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
HttpRequest httpRequest = processor.createRequest(method, "PowerServer",
|
||||
PowerCommand.RESTART);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.5&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
|
||||
+ "server=PowerServer&power=restart " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -207,7 +207,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.5&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
|
||||
+ "server=PowerServer&power=restart&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -218,7 +218,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
Method method = GridServerAsyncClient.class.getMethod("deleteByName", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "PowerServer");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.5&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
|
||||
+ "name=PowerServer " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -230,7 +230,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.5&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
|
||||
+ "name=PowerServer&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -241,7 +241,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
Method method = GridServerAsyncClient.class.getMethod("getRamSizes");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.5&lookup=server.ram "
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram "
|
||||
+ "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -253,7 +253,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.5&lookup=server.ram&"
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -265,7 +265,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
HttpRequest httpRequest = processor.createRequest(method, 1);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/support/grid/password/get?v=1.5&id=1 HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/support/grid/password/get?v=1.6&id=1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -274,6 +274,90 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
|
|||
assertExceptionParserClassEquals(method, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypes() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getTypes");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.type HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditServerDescription() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("editServerDescription", long.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 2, "newDesc");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&description=newDesc HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&description=newDesc&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditServerRam() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("editServerRam", long.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 2, "1GB");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&server.ram=1GB HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&server.ram=1GB&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditServerType() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("editServerType", long.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 2, "web");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&server.type=web HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
|
||||
+ "id=2&server.type=web&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>>() {
|
||||
|
|
Loading…
Reference in New Issue