mirror of https://github.com/apache/jclouds.git
Fixes in live tests
This commit is contained in:
parent
06b99c1cdc
commit
d8a721c175
|
@ -18,43 +18,22 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova;
|
package org.jclouds.openstack.nova;
|
||||||
|
|
||||||
import java.util.Set;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||||
|
import org.jclouds.openstack.filters.AuthenticateRequest;
|
||||||
import javax.ws.rs.Consumes;
|
import org.jclouds.openstack.nova.domain.*;
|
||||||
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 org.jclouds.openstack.nova.options.CreateServerOptions;
|
import org.jclouds.openstack.nova.options.CreateServerOptions;
|
||||||
import org.jclouds.openstack.nova.options.ListOptions;
|
import org.jclouds.openstack.nova.options.ListOptions;
|
||||||
import org.jclouds.openstack.nova.options.RebuildServerOptions;
|
import org.jclouds.openstack.nova.options.RebuildServerOptions;
|
||||||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
import org.jclouds.rest.annotations.*;
|
||||||
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.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
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.
|
* Provides asynchronous access to OpenStack Nova via their REST API.
|
||||||
|
@ -62,13 +41,13 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* All commands return a ListenableFuture of the result from OpenStack Nova. Any exceptions incurred
|
* All commands return a ListenableFuture of the result from OpenStack Nova. Any exceptions incurred
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
||||||
* {@link ListenableFuture#get()}.
|
* {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
* @see NovaClient
|
* @see NovaClient
|
||||||
* @see <a href="http://wiki.openstack.org/OpenStackAPI_1-1" />
|
* @see <a href="http://wiki.openstack.org/OpenStackAPI_1-1" />
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
*/
|
||||||
@SkipEncoding({ '/', '=' })
|
@SkipEncoding({'/', '='})
|
||||||
@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class })
|
@RequestFilters({AuthenticateRequest.class, AddTimestampQuery.class})
|
||||||
@Endpoint(ServerManagement.class)
|
@Endpoint(ServerManagement.class)
|
||||||
public interface NovaAsyncClient {
|
public interface NovaAsyncClient {
|
||||||
|
|
||||||
|
@ -152,7 +131,7 @@ public interface NovaAsyncClient {
|
||||||
@Path("/servers")
|
@Path("/servers")
|
||||||
@MapBinder(CreateServerOptions.class)
|
@MapBinder(CreateServerOptions.class)
|
||||||
ListenableFuture<Server> createServer(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
|
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
|
* @see NovaClient#rebuildServer
|
||||||
|
@ -167,10 +146,10 @@ public interface NovaAsyncClient {
|
||||||
/**
|
/**
|
||||||
* @see NovaClient#changeAdminPass
|
* @see NovaClient#changeAdminPass
|
||||||
*/
|
*/
|
||||||
@PUT
|
@POST
|
||||||
@Path("/servers/{id}")
|
@Path("/servers/{id}/action")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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);
|
ListenableFuture<Void> changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,7 +224,7 @@ public interface NovaAsyncClient {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D")
|
@Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D")
|
||||||
ListenableFuture<Image> createImageFromServer(@PayloadParam("name") String imageName,
|
ListenableFuture<Image> createImageFromServer(@PayloadParam("name") String imageName,
|
||||||
@PayloadParam("serverId") int serverId);
|
@PayloadParam("serverId") int serverId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NovaClient#listAddresses
|
* @see NovaClient#listAddresses
|
||||||
|
|
|
@ -316,7 +316,7 @@ public class NovaClientLiveTest {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
Server server = client.getServer(serverId);
|
Server server = client.getServer(serverId);
|
||||||
|
|
||||||
assertNotNull(server.getHostId());
|
assertNotNull(server.getHostId(), "Host id: ");
|
||||||
assertEquals(server.getStatus(), ServerStatus.ACTIVE);
|
assertEquals(server.getStatus(), ServerStatus.ACTIVE);
|
||||||
|
|
||||||
assertNotNull(server.getAddresses());
|
assertNotNull(server.getAddresses());
|
||||||
|
@ -366,13 +366,13 @@ public class NovaClientLiveTest {
|
||||||
@Test(enabled = true, timeOut = 5 * 60 * 1000)
|
@Test(enabled = true, timeOut = 5 * 60 * 1000)
|
||||||
public void testChangePassword() throws Exception {
|
public void testChangePassword() throws Exception {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
client.changeAdminPass(serverId, "elmo");
|
|
||||||
blockUntilServerActive(serverId);
|
blockUntilServerActive(serverId);
|
||||||
|
client.changeAdminPass(serverId, "elmo");
|
||||||
assertPassword(client.getServer(serverId), "elmo");
|
assertPassword(client.getServer(serverId), "elmo");
|
||||||
this.adminPass = "elmo";
|
this.adminPass = "elmo";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, timeOut = 10 * 60 * 1000)
|
@Test(enabled = true, timeOut = 10 * 600 * 1000)
|
||||||
public void testCreateImage() throws Exception {
|
public void testCreateImage() throws Exception {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
Image image = client.createImageFromServer("hoofie", serverId);
|
Image image = client.createImageFromServer("hoofie", serverId);
|
||||||
|
@ -405,7 +405,7 @@ public class NovaClientLiveTest {
|
||||||
blockUntilServerActive(serverId);
|
blockUntilServerActive(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
|
@Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft")
|
||||||
public void testRevertResize() throws Exception {
|
public void testRevertResize() throws Exception {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
client.resizeServer(serverId, 2);
|
client.resizeServer(serverId, 2);
|
||||||
|
@ -425,17 +425,16 @@ public class NovaClientLiveTest {
|
||||||
assertEquals(2, client.getServer(serverId).getFlavorRef());
|
assertEquals(2, client.getServer(serverId).getFlavorRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, timeOut = 10 * 60 * 1000)
|
@Test(enabled = true, timeOut = 60000)
|
||||||
void deleteServer2() throws Exception {
|
void deleteServer2() throws Exception {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
if (serverId > 0) {
|
if (serverId > 0) {
|
||||||
client.deleteServer(serverId);
|
client.deleteServer(serverId);
|
||||||
Thread.sleep(1000);
|
waitServerDeleted(serverId);
|
||||||
assert client.getServer(serverId) == null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, timeOut = 10 * 60 * 1000)
|
@Test(enabled = true, timeOut = 60000)
|
||||||
void testDeleteImage() throws Exception {
|
void testDeleteImage() throws Exception {
|
||||||
if (createdImageId <= 0) {
|
if (createdImageId <= 0) {
|
||||||
testCreateImage();
|
testCreateImage();
|
||||||
|
@ -446,15 +445,19 @@ public class NovaClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, timeOut = 10 * 60 * 1000)
|
@Test(enabled = true, timeOut = 60000)
|
||||||
void deleteServer1() throws Exception {
|
void deleteServer1() throws Exception {
|
||||||
if (serverId <= 0) testCreateServer();
|
if (serverId <= 0) testCreateServer();
|
||||||
if (serverId > 0) {
|
if (serverId > 0) {
|
||||||
client.deleteServer(serverId);
|
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
|
@AfterTest
|
||||||
void deleteServersOnEnd() {
|
void deleteServersOnEnd() {
|
||||||
if (serverId > 0) {
|
if (serverId > 0) {
|
||||||
|
|
Loading…
Reference in New Issue