Merge pull request #797 from grkvlt/openstack-test-descriptions

OpenStack test descriptions
This commit is contained in:
Adrian Cole 2012-08-25 14:06:54 -07:00
commit d29774330b
5 changed files with 202 additions and 95 deletions

View File

@ -19,7 +19,8 @@
package org.jclouds.openstack.nova.v2_0.features; package org.jclouds.openstack.nova.v2_0.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import java.util.Set; import java.util.Set;
@ -29,35 +30,57 @@ import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code ExtensionApi} * Tests behavior of {@link ExtensionApi}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "ExtensionApiLiveTest") @Test(groups = "live", testName = "ExtensionApiLiveTest")
public class ExtensionApiLiveTest extends BaseNovaApiLiveTest { public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
/** /**
* Tests the listing of Extensions (getExtension() is tested too!) * Tests the listing of Extensions.
* *
* @throws Exception * @throws Exception
*/ */
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/extensions")
public void testListExtensions() throws Exception { public void testListExtensions() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : zones) {
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId); ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
Set<? extends Extension> response = api.listExtensions(); Set<? extends Extension> response = api.listExtensions();
assert null != response; assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Extension extension : response) { for (Extension extension : response) {
Extension newDetails = api.getExtensionByAlias(extension.getId()); assertNotNull(extension.getId());
assertEquals(newDetails.getId(), extension.getId()); assertNotNull(extension.getName());
assertEquals(newDetails.getName(), extension.getName()); assertNotNull(extension.getDescription());
assertEquals(newDetails.getDescription(), extension.getDescription()); assertNotNull(extension.getNamespace());
assertEquals(newDetails.getNamespace(), extension.getNamespace()); assertNotNull(extension.getUpdated());
assertEquals(newDetails.getUpdated(), extension.getUpdated()); assertNotNull(extension.getLinks());
assertEquals(newDetails.getLinks(), extension.getLinks()); }
} }
} }
}
/**
* Tests retrieval of Extensions using their alias.
*
* @throws Exception
*/
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" })
public void testGetExtensionByAlias() throws Exception {
for (String zoneId : zones) {
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
Set<? extends Extension> response = api.listExtensions();
for (Extension extension : response) {
Extension details = api.getExtensionByAlias(extension.getId());
assertNotNull(details);
assertEquals(details.getId(), extension.getId());
assertEquals(details.getName(), extension.getName());
assertEquals(details.getDescription(), extension.getDescription());
assertEquals(details.getNamespace(), extension.getNamespace());
assertEquals(details.getUpdated(), extension.getUpdated());
assertEquals(details.getLinks(), extension.getLinks());
}
}
}
} }

View File

@ -19,6 +19,8 @@
package org.jclouds.openstack.nova.v2_0.features; package org.jclouds.openstack.nova.v2_0.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.Set; import java.util.Set;
@ -29,7 +31,7 @@ import org.jclouds.openstack.v2_0.domain.Resource;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code FlavorApi} * Tests behavior of {@link FlavorApi}
* *
* @author Jeremy Daggett * @author Jeremy Daggett
*/ */
@ -37,49 +39,69 @@ import org.testng.annotations.Test;
public class FlavorApiLiveTest extends BaseNovaApiLiveTest { public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
/** /**
* Tests the listing of Flavors (getFlavor() is tested too!) * Tests the listing of Flavors.
* *
* @throws Exception * @throws Exception
*/ */
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/flavors")
public void testListFlavors() throws Exception { public void testListFlavors() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId); FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
Set<? extends Resource> response = api.listFlavors(); Set<? extends Resource> response = api.listFlavors();
assert null != response; assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Resource flavor : response) { for (Resource flavor : response) {
Flavor newDetails = api.getFlavor(flavor.getId()); assertNotNull(flavor.getId());
assertEquals(newDetails.getId(), flavor.getId()); assertNotNull(flavor.getName());
assertEquals(newDetails.getName(), flavor.getName()); assertNotNull(flavor.getLinks());
assertEquals(newDetails.getLinks(), flavor.getLinks());
} }
} }
} }
/** /**
* Tests the listing of Flavors in detail (getFlavor() is tested too!) * Tests the listing of Flavors in detail.
* *
* @throws Exception * @throws Exception
*/ */
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/flavors/detail")
public void testListFlavorsInDetail() throws Exception { public void testListFlavorsInDetail() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId); FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = api.listFlavorsInDetail(); Set<? extends Flavor> response = api.listFlavorsInDetail();
assert null != response; assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Flavor flavor : response) { for (Flavor flavor : response) {
Flavor newDetails = api.getFlavor(flavor.getId()); assertNotNull(flavor.getId());
assertEquals(newDetails.getId(), flavor.getId()); assertNotNull(flavor.getName());
assertEquals(newDetails.getName(), flavor.getName()); assertNotNull(flavor.getLinks());
assertEquals(newDetails.getLinks(), flavor.getLinks()); assertTrue(flavor.getRam() > 0);
assertEquals(newDetails.getRam(), flavor.getRam()); assertTrue(flavor.getDisk() > 0);
assertEquals(newDetails.getDisk(), flavor.getDisk()); assertTrue(flavor.getVcpus() > 0);
assertEquals(newDetails.getVcpus(), flavor.getVcpus());
} }
} }
}
/**
* Tests getting Flavors by id.
*
* @throws Exception
*/
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/{id}", dependsOnMethods = { "testListFlavorsInDetail" })
public void testGetFlavorById() throws Exception {
for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = api.listFlavorsInDetail();
for (Flavor flavor : response) {
Flavor details = api.getFlavor(flavor.getId());
assertNotNull(details);
assertEquals(details.getId(), flavor.getId());
assertEquals(details.getName(), flavor.getName());
assertEquals(details.getLinks(), flavor.getLinks());
assertEquals(details.getRam(), flavor.getRam());
assertEquals(details.getDisk(), flavor.getDisk());
assertEquals(details.getVcpus(), flavor.getVcpus());
}
}
} }
} }

View File

@ -19,6 +19,7 @@
package org.jclouds.openstack.nova.v2_0.features; package org.jclouds.openstack.nova.v2_0.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@ -30,52 +31,72 @@ import org.jclouds.openstack.v2_0.domain.Resource;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code ImageApi} * Tests behavior of {@link ImageApi}
* *
* @author Michael Arnold * @author Michael Arnold
*/ */
@Test(groups = "live", testName = "ImageApiLiveTest") @Test(groups = "live", testName = "ImageApiLiveTest")
public class ImageApiLiveTest extends BaseNovaApiLiveTest { public class ImageApiLiveTest extends BaseNovaApiLiveTest {
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/images")
public void testListImages() throws Exception { public void testListImages() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : zones) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
Set<? extends Resource> response = api.listImages(); Set<? extends Resource> response = api.listImages();
assertNotNull(response); assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Resource image : response) { for (Resource image : response) {
Image newDetails = api.getImage(image.getId()); assertNotNull(image.getId());
assertNotNull(newDetails); assertNotNull(image.getName());
assertEquals(newDetails.getId(), image.getId()); assertNotNull(image.getLinks());
assertEquals(newDetails.getName(), image.getName());
assertEquals(newDetails.getLinks(), image.getLinks());
} }
} }
} }
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/images/detail")
public void testListImagesInDetail() throws Exception { public void testListImagesInDetail() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
Set<? extends Image> response = api.listImagesInDetail(); Set<? extends Image> response = api.listImagesInDetail();
assertNotNull(response); assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Image image : response) { for (Image image : response) {
Image newDetails = api.getImage(image.getId()); assertNotNull(image.getId());
assertNotNull(newDetails); assertNotNull(image.getName());
assertEquals(newDetails.getId(), image.getId()); assertNotNull(image.getLinks());
assertEquals(newDetails.getName(), image.getName()); assertNotNull(image.getCreated());
assertEquals(newDetails.getLinks(), image.getLinks()); assertTrue(image.getMinDisk() > 0);
assertEquals(newDetails.getCreated(), image.getCreated()); assertTrue(image.getMinRam() > 0);
assertEquals(newDetails.getMinDisk(), image.getMinDisk()); assertTrue(image.getProgress() >= 0 && image.getProgress() <= 100);
assertEquals(newDetails.getMinRam(), image.getMinRam()); assertNotNull(image.getStatus());
assertEquals(newDetails.getProgress(), image.getProgress()); assertNotNull(image.getServer());
assertEquals(newDetails.getStatus(), image.getStatus()); assertNotNull(image.getTenantId());
assertEquals(newDetails.getServer(), image.getServer()); assertNotNull(image.getUpdated());
assertEquals(newDetails.getTenantId(), image.getTenantId()); assertNotNull(image.getUserId());
assertEquals(newDetails.getUpdated(), image.getUpdated()); }
assertEquals(newDetails.getUserId(), image.getUserId()); }
}
@Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" })
public void testGetImageById() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
Set<? extends Image> response = api.listImagesInDetail();
for (Image image : response) {
Image details = api.getImage(image.getId());
assertNotNull(details);
assertEquals(details.getId(), image.getId());
assertEquals(details.getName(), image.getName());
assertEquals(details.getLinks(), image.getLinks());
assertEquals(details.getCreated(), image.getCreated());
assertEquals(details.getMinDisk(), image.getMinDisk());
assertEquals(details.getMinRam(), image.getMinRam());
assertEquals(details.getProgress(), image.getProgress());
assertEquals(details.getStatus(), image.getStatus());
assertEquals(details.getServer(), image.getServer());
assertEquals(details.getTenantId(), image.getTenantId());
assertEquals(details.getUpdated(), image.getUpdated());
assertEquals(details.getUserId(), image.getUserId());
} }
} }
} }

View File

@ -19,41 +19,79 @@
package org.jclouds.openstack.nova.v2_0.features; package org.jclouds.openstack.nova.v2_0.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.*;
import java.util.Set; import java.util.Set;
import org.jclouds.openstack.nova.v2_0.domain.Server; import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.v2_0.domain.Link.Relation;
import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.openstack.v2_0.domain.Resource;
import org.jclouds.openstack.v2_0.predicates.LinkPredicates;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@code ServerApi} * Tests behavior of {@link ServerApi}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "ServerApiLiveTest") @Test(groups = "live", testName = "ServerApiLiveTest")
public class ServerApiLiveTest extends BaseNovaApiLiveTest { public class ServerApiLiveTest extends BaseNovaApiLiveTest {
@Test @Test(description = "GET /v${apiVersion}/{tenantId}/servers")
public void testListServersInDetail() throws Exception { public void testListServers() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId); ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
Set<? extends Resource> response = api.listServers(); Set<? extends Resource> response = api.listServers();
assert null != response; assertNotNull(response);
assertTrue(response.size() >= 0); assertFalse(response.isEmpty());
for (Resource server : response) { assert null != response;
Server newDetails = api.getServer(server.getId()); assertTrue(response.size() >= 0);
assertEquals(newDetails.getId(), server.getId()); for (Resource server : response) {
assertEquals(newDetails.getName(), server.getName()); checkResource(server);
assertEquals(newDetails.getLinks(), server.getLinks()); }
checkServer(newDetails); }
} }
}
}
private void checkServer(Server server) { @Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
assert server.getAddresses().size() > 0 : server; public void testListServersInDetail() throws Exception {
} for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
Set<? extends Server> response = api.listServersInDetail();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Server server : response) {
checkServer(server);
}
}
}
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
public void testGetServerById() throws Exception {
for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
Set<? extends Resource> response = api.listServers();
for (Resource server : response) {
Server details = api.getServer(server.getId());
assertEquals(details.getId(), server.getId());
assertEquals(details.getName(), server.getName());
assertEquals(details.getLinks(), server.getLinks());
checkServer(details);
}
}
}
private void checkResource(Resource resource) {
assertNotNull(resource.getId());
assertNotNull(resource.getName());
assertNotNull(resource.getLinks());
assertTrue(Iterables.any(resource.getLinks(), LinkPredicates.relationEquals(Relation.SELF)));
}
private void checkServer(Server server) {
checkResource(server);
assertFalse(server.getAddresses().isEmpty());
}
} }

View File

@ -19,11 +19,12 @@
package org.jclouds.openstack.nova.v2_0.internal; package org.jclouds.openstack.nova.v2_0.internal;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.config.NovaProperties; import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
import org.jclouds.openstack.nova.v2_0.domain.Flavor; import org.jclouds.openstack.nova.v2_0.domain.Flavor;
import org.jclouds.openstack.nova.v2_0.domain.Server; import org.jclouds.openstack.nova.v2_0.domain.Server;
@ -54,13 +55,15 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
provider = "openstack-nova"; provider = "openstack-nova";
} }
protected Set<String> zones;
protected RestContext<NovaApi, NovaAsyncApi> novaContext; protected RestContext<NovaApi, NovaAsyncApi> novaContext;
@BeforeGroups(groups = { "integration", "live" }) @BeforeGroups(groups = { "integration", "live" }, alwaysRun = true)
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
novaContext = view.unwrap(); novaContext = view.unwrap();
zones = novaContext.getApi().getConfiguredZones();
} }
@Override @Override