mirror of https://github.com/apache/jclouds.git
made ec2 tests a bit more portable
This commit is contained in:
parent
f1ab4e466f
commit
3ab960ce39
|
@ -1,38 +1,57 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ec2.services;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||
import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.RunNodesException;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.domain.TemplateBuilderSpec;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.compute.predicates.ImagePredicates;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.Image;
|
||||
import org.jclouds.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.domain.Snapshot;
|
||||
import org.jclouds.ec2.services.AMIClient;
|
||||
import org.jclouds.ec2.predicates.InstanceStateRunning;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AMIClient}
|
||||
|
@ -50,28 +69,37 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
@Override
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = super.setupProperties();
|
||||
String ebsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template");
|
||||
if (ebsSpec != null)
|
||||
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
|
||||
String ebsSpec = checkNotNull(setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template"), provider
|
||||
+ ".ebs-template");
|
||||
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
protected EC2Client ec2Client;
|
||||
protected AMIClient client;
|
||||
|
||||
protected Set<String> imagesToDeregister = Sets.newHashSet();
|
||||
protected Set<String> snapshotsToDelete = Sets.newHashSet();
|
||||
protected RetryablePredicate<RunningInstance> runningTester;
|
||||
|
||||
protected Set<String> imagesToDeregister = newHashSet();
|
||||
protected Set<String> snapshotsToDelete = newHashSet();
|
||||
protected String regionId;
|
||||
protected String ebsBackedImageId;
|
||||
protected String ebsBackedImageName = "jcloudstest1";
|
||||
protected String imageId;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
runningTester = new RetryablePredicate<RunningInstance>(new InstanceStateRunning(ec2Client), 600, 5,
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
client = ec2Client.getAMIServices();
|
||||
if (ebsTemplate != null) {
|
||||
Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
|
||||
regionId = template.getLocation().getId();
|
||||
imageId = template.getImage().getProviderId();
|
||||
for (Image image : client.describeImagesInRegion(regionId)) {
|
||||
if (ebsBackedImageName.equals(image.getName()))
|
||||
client.deregisterImageInRegion(regionId, image.getId());
|
||||
|
@ -89,8 +117,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
}
|
||||
|
||||
public void testDescribeImages() {
|
||||
for (String region : view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices()
|
||||
.describeRegions().keySet()) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
Set<? extends Image> allResults = client.describeImagesInRegion(region);
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
|
@ -108,18 +135,16 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
|
||||
@Test
|
||||
public void testCreateAndListEBSBackedImage() throws Exception {
|
||||
ComputeService computeService = view.getComputeService();
|
||||
Snapshot snapshot = createSnapshot(computeService);
|
||||
Snapshot snapshot = createSnapshot();
|
||||
|
||||
// List of images before...
|
||||
int sizeBefore = computeService.listImages().size();
|
||||
int sizeBefore = client.describeImagesInRegion(regionId).size();
|
||||
|
||||
// Register a new image...
|
||||
ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(),
|
||||
addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
|
||||
imagesToDeregister.add(ebsBackedImageId);
|
||||
final Image ebsBackedImage = Iterables.getOnlyElement(client.describeImagesInRegion(regionId,
|
||||
imageIds(ebsBackedImageId)));
|
||||
final Image ebsBackedImage = getOnlyElement(client.describeImagesInRegion(regionId, imageIds(ebsBackedImageId)));
|
||||
assertEquals(ebsBackedImage.getName(), ebsBackedImageName);
|
||||
assertEquals(ebsBackedImage.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(ebsBackedImage.getRootDeviceType(), RootDeviceType.EBS);
|
||||
|
@ -130,46 +155,40 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true),
|
||||
"/dev/sda2", new Image.EbsBlockDevice(null, 1, false)).entrySet());
|
||||
|
||||
// This is the suggested method to ensure the new image ID is inserted
|
||||
// into the cache
|
||||
// (suggested by adriancole_ on #jclouds)
|
||||
computeService.templateBuilder().imageId(ebsBackedImage.getRegion() + "/" + ebsBackedImageId).build();
|
||||
|
||||
// List of images after - should be one larger than before
|
||||
Set<? extends org.jclouds.compute.domain.Image> after = computeService.listImages();
|
||||
assertEquals(after.size(), sizeBefore + 1);
|
||||
|
||||
// Detailed check: filter for the AMI ID
|
||||
Iterable<? extends org.jclouds.compute.domain.Image> filtered = Iterables.filter(after,
|
||||
ImagePredicates.idEquals(ebsBackedImage.getRegion() + "/" + ebsBackedImageId));
|
||||
assertEquals(Iterables.size(filtered), 1);
|
||||
int after = client.describeImagesInRegion(regionId).size();
|
||||
assertEquals(after, sizeBefore + 1);
|
||||
}
|
||||
|
||||
// Fires up an instance, finds its root volume ID, takes a snapshot, then
|
||||
// terminates the instance.
|
||||
private Snapshot createSnapshot(ComputeService computeService) throws RunNodesException {
|
||||
Template template = computeService.templateBuilder().from(ebsTemplate).build();
|
||||
regionId = template.getLocation().getId();
|
||||
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup("jcloudstest", 1, template);
|
||||
private Snapshot createSnapshot() throws RunNodesException {
|
||||
|
||||
String instanceId = null;
|
||||
try {
|
||||
String instanceId = Iterables.getOnlyElement(nodes).getProviderId();
|
||||
Reservation<? extends RunningInstance> reservation = Iterables.getOnlyElement(view
|
||||
.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices()
|
||||
.describeInstancesInRegion(regionId, instanceId));
|
||||
RunningInstance instance = Iterables.getOnlyElement(reservation);
|
||||
RunningInstance instance = getOnlyElement(concat(ec2Client.getInstanceServices().runInstancesInRegion(
|
||||
regionId, null, imageId, 1, 1)));
|
||||
instanceId = instance.getId();
|
||||
|
||||
assertTrue(runningTester.apply(instance), instanceId + "didn't achieve the state running!");
|
||||
|
||||
instance = getOnlyElement(concat(ec2Client.getInstanceServices().describeInstancesInRegion(regionId,
|
||||
instanceId)));
|
||||
BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
|
||||
Snapshot snapshot = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
|
||||
.createSnapshotInRegion(regionId, device.getVolumeId());
|
||||
assertNotNull(device, "device: /dev/sda1 not present on: " + instance);
|
||||
Snapshot snapshot = ec2Client.getElasticBlockStoreServices().createSnapshotInRegion(regionId,
|
||||
device.getVolumeId());
|
||||
snapshotsToDelete.add(snapshot.getId());
|
||||
return snapshot;
|
||||
} finally {
|
||||
computeService.destroyNodesMatching(Predicates.in(nodes));
|
||||
if (instanceId != null)
|
||||
ec2Client.getInstanceServices().terminateInstancesInRegion(regionId, instanceId);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateAndListEBSBackedImage")
|
||||
public void testGetLaunchPermissionForImage() {
|
||||
System.out.println(client.getLaunchPermissionForImageInRegion(regionId, ebsBackedImageId));
|
||||
client.getLaunchPermissionForImageInRegion(regionId, ebsBackedImageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,8 +197,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
for (String imageId : imagesToDeregister)
|
||||
client.deregisterImageInRegion(regionId, imageId);
|
||||
for (String snapshotId : snapshotsToDelete)
|
||||
view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
|
||||
.deleteSnapshotInRegion(regionId, snapshotId);
|
||||
ec2Client.getElasticBlockStoreServices().deleteSnapshotInRegion(regionId, snapshotId);
|
||||
super.tearDownContext();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,17 @@ import static org.testng.Assert.assertNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
|
@ -50,31 +49,30 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceC
|
|||
provider = "ec2";
|
||||
}
|
||||
|
||||
private EC2Client ec2Client;
|
||||
private AvailabilityZoneAndRegionClient client;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getAvailabilityZoneAndRegionServices();
|
||||
}
|
||||
|
||||
public void testDescribeAvailabilityZones() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
Set<AvailabilityZoneInfo> allResults = client.describeAvailabilityZonesInRegion(region);
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
assert allResults.size() >= 1 : allResults.size();
|
||||
Iterator<AvailabilityZoneInfo> iterator = allResults.iterator();
|
||||
String id1 = iterator.next().getZone();
|
||||
String id2 = iterator.next().getZone();
|
||||
Set<AvailabilityZoneInfo> twoResults = client.describeAvailabilityZonesInRegion(region,
|
||||
availabilityZones(id1, id2));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 2);
|
||||
Set<AvailabilityZoneInfo> oneResult = client.describeAvailabilityZonesInRegion(region,
|
||||
availabilityZones(id1));
|
||||
assertNotNull(oneResult);
|
||||
assertEquals(oneResult.size(), 1);
|
||||
iterator = allResults.iterator();
|
||||
assertEquals(iterator.next().getZone(), id1);
|
||||
assertEquals(iterator.next().getZone(), id2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,17 +80,15 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceC
|
|||
SortedMap<String, URI> allResults = Maps.newTreeMap();
|
||||
allResults.putAll(client.describeRegions());
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
assert allResults.size() >= 1 : allResults.size();
|
||||
Iterator<Entry<String, URI>> iterator = allResults.entrySet().iterator();
|
||||
String r1 = iterator.next().getKey();
|
||||
String r2 = iterator.next().getKey();
|
||||
SortedMap<String, URI> twoResults = Maps.newTreeMap();
|
||||
twoResults.putAll(client.describeRegions(regions(r1, r2)));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 2);
|
||||
iterator = twoResults.entrySet().iterator();
|
||||
SortedMap<String, URI> oneResult = Maps.newTreeMap();
|
||||
oneResult.putAll(client.describeRegions(regions(r1)));
|
||||
assertNotNull(oneResult);
|
||||
assertEquals(oneResult.size(), 1);
|
||||
iterator = oneResult.entrySet().iterator();
|
||||
assertEquals(iterator.next().getKey(), r1);
|
||||
assertEquals(iterator.next().getKey(), r2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.ec2.services;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
@ -26,9 +27,10 @@ import java.util.Set;
|
|||
import java.util.SortedSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.jclouds.ec2.domain.Snapshot;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
||||
|
@ -38,8 +40,8 @@ import org.testng.annotations.BeforeClass;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
|
@ -52,8 +54,13 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
public ElasticBlockStoreClientLiveTest() {
|
||||
provider = "ec2";
|
||||
}
|
||||
|
||||
|
||||
private EC2Client ec2Client;
|
||||
private ElasticBlockStoreClient client;
|
||||
|
||||
private String defaultRegion;
|
||||
private String defaultZone;
|
||||
|
||||
private String volumeId;
|
||||
private Snapshot snapshot;
|
||||
|
||||
|
@ -61,12 +68,17 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getElasticBlockStoreServices();
|
||||
AvailabilityZoneInfo info = Iterables.get(ec2Client.getAvailabilityZoneAndRegionServices()
|
||||
.describeAvailabilityZonesInRegion(defaultRegion), 0);
|
||||
defaultRegion = checkNotNull(Strings.emptyToNull(info.getRegion()), "region of " + info);
|
||||
defaultZone = checkNotNull(Strings.emptyToNull(info.getZone()), "zone of " + info);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeVolumes() {
|
||||
for (String region : view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
|
@ -81,14 +93,13 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
|
||||
@Test
|
||||
void testCreateVolumeInAvailabilityZone() {
|
||||
Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1);
|
||||
Volume expected = client.createVolumeInAvailabilityZone(defaultZone, 1);
|
||||
assertNotNull(expected);
|
||||
System.out.println(expected);
|
||||
assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
assertEquals(expected.getAvailabilityZone(), defaultZone);
|
||||
|
||||
this.volumeId = expected.getId();
|
||||
|
||||
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(null, expected.getId()));
|
||||
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId()));
|
||||
assertNotNull(result);
|
||||
assertEquals(result.size(), 1);
|
||||
Volume volume = result.iterator().next();
|
||||
|
@ -97,7 +108,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
|
||||
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
|
||||
void testCreateSnapshotInRegion() {
|
||||
Snapshot snapshot = client.createSnapshotInRegion(null, volumeId);
|
||||
Snapshot snapshot = client.createSnapshotInRegion(defaultRegion, volumeId);
|
||||
Predicate<Snapshot> snapshotted = new RetryablePredicate<Snapshot>(new SnapshotCompleted(client), 600, 10,
|
||||
TimeUnit.SECONDS);
|
||||
assert snapshotted.apply(snapshot);
|
||||
|
@ -109,13 +120,9 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
this.snapshot = result;
|
||||
}
|
||||
|
||||
protected String getDefaultAvailabilityZone(){
|
||||
return "us-east-1a";
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId());
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, snapshot.getId());
|
||||
assertNotNull(volume);
|
||||
|
||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
||||
|
@ -125,7 +132,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||
assertEquals(volume.getId(), result.getId());
|
||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
assertEquals(volume.getAvailabilityZone(), defaultZone);
|
||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||
|
||||
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||
|
@ -133,8 +140,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2,
|
||||
snapshot.getId());
|
||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, 2, snapshot.getId());
|
||||
assertNotNull(volume);
|
||||
|
||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
||||
|
@ -144,7 +150,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||
assertEquals(volume.getId(), result.getId());
|
||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
||||
assertEquals(volume.getAvailabilityZone(), defaultZone);
|
||||
assertEquals(volume.getSize(), 2);
|
||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||
|
||||
|
@ -163,8 +169,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
|
||||
@Test
|
||||
void testDescribeSnapshots() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
|
@ -179,32 +184,37 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
|||
|
||||
@Test(enabled = false)
|
||||
public void testAddCreateVolumePermissionsToSnapshot() {
|
||||
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(null, userIds,
|
||||
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(defaultRegion,
|
||||
// userIds,
|
||||
// userGroups,
|
||||
// snapshotId);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testRemoveCreateVolumePermissionsFromSnapshot() {
|
||||
// TODO client.removeCreateVolumePermissionsFromSnapshotInRegion(null, userIds,
|
||||
// TODO
|
||||
// client.removeCreateVolumePermissionsFromSnapshotInRegion(defaultRegion,
|
||||
// userIds,
|
||||
// userGroups,
|
||||
// snapshotId);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testResetCreateVolumePermissionsOnSnapshot() {
|
||||
// TODO client.resetCreateVolumePermissionsOnSnapshotInRegion(null, snapshotId);
|
||||
// TODO
|
||||
// client.resetCreateVolumePermissionsOnSnapshotInRegion(defaultRegion,
|
||||
// snapshotId);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
public void testGetCreateVolumePermissionForSnapshot() {
|
||||
System.out.println(client.getCreateVolumePermissionForSnapshotInRegion(snapshot.getRegion(), snapshot.getId()));
|
||||
client.getCreateVolumePermissionForSnapshotInRegion(snapshot.getRegion(), snapshot.getId());
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||
void testDeleteVolumeInRegion() {
|
||||
client.deleteVolumeInRegion(null, volumeId);
|
||||
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(null, volumeId));
|
||||
client.deleteVolumeInRegion(defaultRegion, volumeId);
|
||||
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, volumeId));
|
||||
assertEquals(result.size(), 1);
|
||||
Volume volume = result.iterator().next();
|
||||
assertEquals(volume.getStatus(), Volume.Status.DELETING);
|
||||
|
|
|
@ -23,14 +23,13 @@ import static org.testng.Assert.assertNotNull;
|
|||
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
|
@ -44,19 +43,20 @@ public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiv
|
|||
provider = "ec2";
|
||||
}
|
||||
|
||||
private EC2Client ec2Client;
|
||||
private ElasticIPAddressClient client;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getElasticIPAddressServices();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeAddresses() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client.describeAddressesInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
|
|
|
@ -22,16 +22,14 @@ import static org.testng.Assert.assertNotNull;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code EC2Client}
|
||||
*
|
||||
|
@ -43,19 +41,20 @@ public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
provider = "ec2";
|
||||
}
|
||||
|
||||
private EC2Client ec2Client;
|
||||
private InstanceClient client;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getInstanceServices();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeInstances() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 0 : allResults.size();
|
||||
|
|
|
@ -24,14 +24,13 @@ import static org.testng.Assert.assertNotNull;
|
|||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.KeyPair;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
|
@ -45,20 +44,20 @@ public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
provider = "ec2";
|
||||
}
|
||||
|
||||
private EC2Client ec2Client;
|
||||
private KeyPairClient client;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getKeyPairServices();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeKeyPairs() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1)) {
|
||||
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
|
|
|
@ -25,9 +25,9 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
|
@ -41,7 +41,6 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SecurityGroupClient}
|
||||
|
@ -54,19 +53,20 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
|||
provider = "ec2";
|
||||
}
|
||||
|
||||
private EC2Client ec2Client;
|
||||
protected SecurityGroupClient client;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices();
|
||||
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
client = ec2Client.getSecurityGroupServices();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribe() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1, Region.AP_NORTHEAST_1)) {
|
||||
for (String region : ec2Client.getConfiguredRegions()) {
|
||||
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
||||
.describeSecurityGroupsInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
|
|
Loading…
Reference in New Issue