Fixes in live tests

This commit is contained in:
vicglarson 2011-04-18 23:55:19 +04:00 committed by Dmitri Babaev
parent 06b99c1cdc
commit d8a721c175
2 changed files with 31 additions and 49 deletions

View File

@ -18,43 +18,22 @@
*/
package org.jclouds.openstack.nova;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jclouds.openstack.nova.domain.Addresses;
import org.jclouds.openstack.nova.domain.Flavor;
import org.jclouds.openstack.nova.domain.Image;
import org.jclouds.openstack.nova.domain.RebootType;
import org.jclouds.openstack.nova.domain.Server;
import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.nova.domain.*;
import org.jclouds.openstack.nova.options.CreateServerOptions;
import org.jclouds.openstack.nova.options.ListOptions;
import org.jclouds.openstack.nova.options.RebuildServerOptions;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.Payload;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.*;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.Set;
import java.util.concurrent.ExecutionException;
/**
* Provides asynchronous access to OpenStack Nova via their REST API.
@ -63,12 +42,12 @@ import com.google.common.util.concurrent.ListenableFuture;
* during processing will be wrapped in an {@link ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @author Adrian Cole
* @see NovaClient
* @see <a href="http://wiki.openstack.org/OpenStackAPI_1-1" />
* @author Adrian Cole
*/
@SkipEncoding({ '/', '=' })
@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class })
@SkipEncoding({'/', '='})
@RequestFilters({AuthenticateRequest.class, AddTimestampQuery.class})
@Endpoint(ServerManagement.class)
public interface NovaAsyncClient {
@ -152,7 +131,7 @@ public interface NovaAsyncClient {
@Path("/servers")
@MapBinder(CreateServerOptions.class)
ListenableFuture<Server> createServer(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
@PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
@PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
/**
* @see NovaClient#rebuildServer
@ -167,10 +146,10 @@ public interface NovaAsyncClient {
/**
* @see NovaClient#changeAdminPass
*/
@PUT
@Path("/servers/{id}")
@POST
@Path("/servers/{id}/action")
@Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"server\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
@Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
ListenableFuture<Void> changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass);
/**
@ -245,7 +224,7 @@ public interface NovaAsyncClient {
@Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D")
ListenableFuture<Image> createImageFromServer(@PayloadParam("name") String imageName,
@PayloadParam("serverId") int serverId);
@PayloadParam("serverId") int serverId);
/**
* @see NovaClient#listAddresses

View File

@ -316,7 +316,7 @@ public class NovaClientLiveTest {
if (serverId <= 0) testCreateServer();
Server server = client.getServer(serverId);
assertNotNull(server.getHostId());
assertNotNull(server.getHostId(), "Host id: ");
assertEquals(server.getStatus(), ServerStatus.ACTIVE);
assertNotNull(server.getAddresses());
@ -366,13 +366,13 @@ public class NovaClientLiveTest {
@Test(enabled = true, timeOut = 5 * 60 * 1000)
public void testChangePassword() throws Exception {
if (serverId <= 0) testCreateServer();
client.changeAdminPass(serverId, "elmo");
blockUntilServerActive(serverId);
client.changeAdminPass(serverId, "elmo");
assertPassword(client.getServer(serverId), "elmo");
this.adminPass = "elmo";
}
@Test(enabled = true, timeOut = 10 * 60 * 1000)
@Test(enabled = true, timeOut = 10 * 600 * 1000)
public void testCreateImage() throws Exception {
if (serverId <= 0) testCreateServer();
Image image = client.createImageFromServer("hoofie", serverId);
@ -405,7 +405,7 @@ public class NovaClientLiveTest {
blockUntilServerActive(serverId);
}
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
@Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft")
public void testRevertResize() throws Exception {
if (serverId <= 0) testCreateServer();
client.resizeServer(serverId, 2);
@ -425,17 +425,16 @@ public class NovaClientLiveTest {
assertEquals(2, client.getServer(serverId).getFlavorRef());
}
@Test(enabled = true, timeOut = 10 * 60 * 1000)
@Test(enabled = true, timeOut = 60000)
void deleteServer2() throws Exception {
if (serverId <= 0) testCreateServer();
if (serverId > 0) {
client.deleteServer(serverId);
Thread.sleep(1000);
assert client.getServer(serverId) == null;
waitServerDeleted(serverId);
}
}
@Test(enabled = true, timeOut = 10 * 60 * 1000)
@Test(enabled = true, timeOut = 60000)
void testDeleteImage() throws Exception {
if (createdImageId <= 0) {
testCreateImage();
@ -446,15 +445,19 @@ public class NovaClientLiveTest {
}
}
@Test(enabled = true, timeOut = 10 * 60 * 1000)
@Test(enabled = true, timeOut = 60000)
void deleteServer1() throws Exception {
if (serverId <= 0) testCreateServer();
if (serverId > 0) {
client.deleteServer(serverId);
assert client.getServer(serverId) == null;
waitServerDeleted(serverId);
}
}
private void waitServerDeleted(int serverId) throws InterruptedException {
while (null != client.getServer(serverId)) Thread.sleep(1000);
}
@AfterTest
void deleteServersOnEnd() {
if (serverId > 0) {