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;
|
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.DescribeImagesOptions.Builder.imageIds;
|
||||||
import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
|
||||||
import org.jclouds.compute.RunNodesException;
|
import org.jclouds.compute.RunNodesException;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilderSpec;
|
import org.jclouds.compute.domain.TemplateBuilderSpec;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.compute.predicates.ImagePredicates;
|
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.Image;
|
import org.jclouds.ec2.domain.Image;
|
||||||
import org.jclouds.ec2.domain.Image.ImageType;
|
import org.jclouds.ec2.domain.Image.ImageType;
|
||||||
import org.jclouds.ec2.domain.Reservation;
|
|
||||||
import org.jclouds.ec2.domain.RootDeviceType;
|
import org.jclouds.ec2.domain.RootDeviceType;
|
||||||
import org.jclouds.ec2.domain.RunningInstance;
|
import org.jclouds.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.ec2.domain.Snapshot;
|
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.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AMIClient}
|
* Tests behavior of {@code AMIClient}
|
||||||
|
@ -50,28 +69,37 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
String ebsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template");
|
String ebsSpec = checkNotNull(setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template"), provider
|
||||||
if (ebsSpec != null)
|
+ ".ebs-template");
|
||||||
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
|
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected EC2Client ec2Client;
|
||||||
protected AMIClient client;
|
protected AMIClient client;
|
||||||
|
|
||||||
protected Set<String> imagesToDeregister = Sets.newHashSet();
|
protected RetryablePredicate<RunningInstance> runningTester;
|
||||||
protected Set<String> snapshotsToDelete = Sets.newHashSet();
|
|
||||||
|
protected Set<String> imagesToDeregister = newHashSet();
|
||||||
|
protected Set<String> snapshotsToDelete = newHashSet();
|
||||||
protected String regionId;
|
protected String regionId;
|
||||||
protected String ebsBackedImageId;
|
protected String ebsBackedImageId;
|
||||||
protected String ebsBackedImageName = "jcloudstest1";
|
protected String ebsBackedImageName = "jcloudstest1";
|
||||||
|
protected String imageId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.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) {
|
if (ebsTemplate != null) {
|
||||||
Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
|
Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
|
||||||
regionId = template.getLocation().getId();
|
regionId = template.getLocation().getId();
|
||||||
|
imageId = template.getImage().getProviderId();
|
||||||
for (Image image : client.describeImagesInRegion(regionId)) {
|
for (Image image : client.describeImagesInRegion(regionId)) {
|
||||||
if (ebsBackedImageName.equals(image.getName()))
|
if (ebsBackedImageName.equals(image.getName()))
|
||||||
client.deregisterImageInRegion(regionId, image.getId());
|
client.deregisterImageInRegion(regionId, image.getId());
|
||||||
|
@ -89,8 +117,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeImages() {
|
public void testDescribeImages() {
|
||||||
for (String region : view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices()
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
.describeRegions().keySet()) {
|
|
||||||
Set<? extends Image> allResults = client.describeImagesInRegion(region);
|
Set<? extends Image> allResults = client.describeImagesInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 2 : allResults.size();
|
||||||
|
@ -108,18 +135,16 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndListEBSBackedImage() throws Exception {
|
public void testCreateAndListEBSBackedImage() throws Exception {
|
||||||
ComputeService computeService = view.getComputeService();
|
Snapshot snapshot = createSnapshot();
|
||||||
Snapshot snapshot = createSnapshot(computeService);
|
|
||||||
|
|
||||||
// List of images before...
|
// List of images before...
|
||||||
int sizeBefore = computeService.listImages().size();
|
int sizeBefore = client.describeImagesInRegion(regionId).size();
|
||||||
|
|
||||||
// Register a new image...
|
// Register a new image...
|
||||||
ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(),
|
ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(),
|
||||||
addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
|
addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
|
||||||
imagesToDeregister.add(ebsBackedImageId);
|
imagesToDeregister.add(ebsBackedImageId);
|
||||||
final Image ebsBackedImage = Iterables.getOnlyElement(client.describeImagesInRegion(regionId,
|
final Image ebsBackedImage = getOnlyElement(client.describeImagesInRegion(regionId, imageIds(ebsBackedImageId)));
|
||||||
imageIds(ebsBackedImageId)));
|
|
||||||
assertEquals(ebsBackedImage.getName(), ebsBackedImageName);
|
assertEquals(ebsBackedImage.getName(), ebsBackedImageName);
|
||||||
assertEquals(ebsBackedImage.getImageType(), ImageType.MACHINE);
|
assertEquals(ebsBackedImage.getImageType(), ImageType.MACHINE);
|
||||||
assertEquals(ebsBackedImage.getRootDeviceType(), RootDeviceType.EBS);
|
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),
|
ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true),
|
||||||
"/dev/sda2", new Image.EbsBlockDevice(null, 1, false)).entrySet());
|
"/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
|
// List of images after - should be one larger than before
|
||||||
Set<? extends org.jclouds.compute.domain.Image> after = computeService.listImages();
|
int after = client.describeImagesInRegion(regionId).size();
|
||||||
assertEquals(after.size(), sizeBefore + 1);
|
assertEquals(after, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fires up an instance, finds its root volume ID, takes a snapshot, then
|
// Fires up an instance, finds its root volume ID, takes a snapshot, then
|
||||||
// terminates the instance.
|
// terminates the instance.
|
||||||
private Snapshot createSnapshot(ComputeService computeService) throws RunNodesException {
|
private Snapshot createSnapshot() throws RunNodesException {
|
||||||
Template template = computeService.templateBuilder().from(ebsTemplate).build();
|
|
||||||
regionId = template.getLocation().getId();
|
String instanceId = null;
|
||||||
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup("jcloudstest", 1, template);
|
|
||||||
try {
|
try {
|
||||||
String instanceId = Iterables.getOnlyElement(nodes).getProviderId();
|
RunningInstance instance = getOnlyElement(concat(ec2Client.getInstanceServices().runInstancesInRegion(
|
||||||
Reservation<? extends RunningInstance> reservation = Iterables.getOnlyElement(view
|
regionId, null, imageId, 1, 1)));
|
||||||
.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices()
|
instanceId = instance.getId();
|
||||||
.describeInstancesInRegion(regionId, instanceId));
|
|
||||||
RunningInstance instance = Iterables.getOnlyElement(reservation);
|
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");
|
BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
|
||||||
Snapshot snapshot = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
|
assertNotNull(device, "device: /dev/sda1 not present on: " + instance);
|
||||||
.createSnapshotInRegion(regionId, device.getVolumeId());
|
Snapshot snapshot = ec2Client.getElasticBlockStoreServices().createSnapshotInRegion(regionId,
|
||||||
|
device.getVolumeId());
|
||||||
snapshotsToDelete.add(snapshot.getId());
|
snapshotsToDelete.add(snapshot.getId());
|
||||||
return snapshot;
|
return snapshot;
|
||||||
} finally {
|
} finally {
|
||||||
computeService.destroyNodesMatching(Predicates.in(nodes));
|
if (instanceId != null)
|
||||||
|
ec2Client.getInstanceServices().terminateInstancesInRegion(regionId, instanceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndListEBSBackedImage")
|
@Test(dependsOnMethods = "testCreateAndListEBSBackedImage")
|
||||||
public void testGetLaunchPermissionForImage() {
|
public void testGetLaunchPermissionForImage() {
|
||||||
System.out.println(client.getLaunchPermissionForImageInRegion(regionId, ebsBackedImageId));
|
client.getLaunchPermissionForImageInRegion(regionId, ebsBackedImageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,8 +197,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
for (String imageId : imagesToDeregister)
|
for (String imageId : imagesToDeregister)
|
||||||
client.deregisterImageInRegion(regionId, imageId);
|
client.deregisterImageInRegion(regionId, imageId);
|
||||||
for (String snapshotId : snapshotsToDelete)
|
for (String snapshotId : snapshotsToDelete)
|
||||||
view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
|
ec2Client.getElasticBlockStoreServices().deleteSnapshotInRegion(regionId, snapshotId);
|
||||||
.deleteSnapshotInRegion(regionId, snapshotId);
|
|
||||||
super.tearDownContext();
|
super.tearDownContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,18 +25,17 @@ import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,31 +49,30 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceC
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
private AvailabilityZoneAndRegionClient client;
|
private AvailabilityZoneAndRegionClient client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices();
|
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
|
client = ec2Client.getAvailabilityZoneAndRegionServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeAvailabilityZones() {
|
public void testDescribeAvailabilityZones() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
Set<AvailabilityZoneInfo> allResults = client.describeAvailabilityZonesInRegion(region);
|
Set<AvailabilityZoneInfo> allResults = client.describeAvailabilityZonesInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 1 : allResults.size();
|
||||||
Iterator<AvailabilityZoneInfo> iterator = allResults.iterator();
|
Iterator<AvailabilityZoneInfo> iterator = allResults.iterator();
|
||||||
String id1 = iterator.next().getZone();
|
String id1 = iterator.next().getZone();
|
||||||
String id2 = iterator.next().getZone();
|
Set<AvailabilityZoneInfo> oneResult = client.describeAvailabilityZonesInRegion(region,
|
||||||
Set<AvailabilityZoneInfo> twoResults = client.describeAvailabilityZonesInRegion(region,
|
availabilityZones(id1));
|
||||||
availabilityZones(id1, id2));
|
assertNotNull(oneResult);
|
||||||
assertNotNull(twoResults);
|
assertEquals(oneResult.size(), 1);
|
||||||
assertEquals(twoResults.size(), 2);
|
|
||||||
iterator = allResults.iterator();
|
iterator = allResults.iterator();
|
||||||
assertEquals(iterator.next().getZone(), id1);
|
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();
|
SortedMap<String, URI> allResults = Maps.newTreeMap();
|
||||||
allResults.putAll(client.describeRegions());
|
allResults.putAll(client.describeRegions());
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 2 : allResults.size();
|
assert allResults.size() >= 1 : allResults.size();
|
||||||
Iterator<Entry<String, URI>> iterator = allResults.entrySet().iterator();
|
Iterator<Entry<String, URI>> iterator = allResults.entrySet().iterator();
|
||||||
String r1 = iterator.next().getKey();
|
String r1 = iterator.next().getKey();
|
||||||
String r2 = iterator.next().getKey();
|
SortedMap<String, URI> oneResult = Maps.newTreeMap();
|
||||||
SortedMap<String, URI> twoResults = Maps.newTreeMap();
|
oneResult.putAll(client.describeRegions(regions(r1)));
|
||||||
twoResults.putAll(client.describeRegions(regions(r1, r2)));
|
assertNotNull(oneResult);
|
||||||
assertNotNull(twoResults);
|
assertEquals(oneResult.size(), 1);
|
||||||
assertEquals(twoResults.size(), 2);
|
iterator = oneResult.entrySet().iterator();
|
||||||
iterator = twoResults.entrySet().iterator();
|
|
||||||
assertEquals(iterator.next().getKey(), r1);
|
assertEquals(iterator.next().getKey(), r1);
|
||||||
assertEquals(iterator.next().getKey(), r2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.ec2.services;
|
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.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -26,9 +27,10 @@ import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
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.Snapshot;
|
||||||
import org.jclouds.ec2.domain.Volume;
|
import org.jclouds.ec2.domain.Volume;
|
||||||
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
import org.jclouds.ec2.predicates.SnapshotCompleted;
|
||||||
|
@ -38,8 +40,8 @@ import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +55,12 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
private ElasticBlockStoreClient client;
|
private ElasticBlockStoreClient client;
|
||||||
|
|
||||||
|
private String defaultRegion;
|
||||||
|
private String defaultZone;
|
||||||
|
|
||||||
private String volumeId;
|
private String volumeId;
|
||||||
private Snapshot snapshot;
|
private Snapshot snapshot;
|
||||||
|
|
||||||
|
@ -61,12 +68,17 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.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
|
@Test
|
||||||
void testDescribeVolumes() {
|
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));
|
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
@ -81,14 +93,13 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateVolumeInAvailabilityZone() {
|
void testCreateVolumeInAvailabilityZone() {
|
||||||
Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1);
|
Volume expected = client.createVolumeInAvailabilityZone(defaultZone, 1);
|
||||||
assertNotNull(expected);
|
assertNotNull(expected);
|
||||||
System.out.println(expected);
|
assertEquals(expected.getAvailabilityZone(), defaultZone);
|
||||||
assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone());
|
|
||||||
|
|
||||||
this.volumeId = expected.getId();
|
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);
|
assertNotNull(result);
|
||||||
assertEquals(result.size(), 1);
|
assertEquals(result.size(), 1);
|
||||||
Volume volume = result.iterator().next();
|
Volume volume = result.iterator().next();
|
||||||
|
@ -97,7 +108,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
|
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
|
||||||
void testCreateSnapshotInRegion() {
|
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,
|
Predicate<Snapshot> snapshotted = new RetryablePredicate<Snapshot>(new SnapshotCompleted(client), 600, 10,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
assert snapshotted.apply(snapshot);
|
assert snapshotted.apply(snapshot);
|
||||||
|
@ -109,13 +120,9 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
this.snapshot = result;
|
this.snapshot = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDefaultAvailabilityZone(){
|
|
||||||
return "us-east-1a";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
void testCreateVolumeFromSnapshotInAvailabilityZone() {
|
||||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId());
|
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, snapshot.getId());
|
||||||
assertNotNull(volume);
|
assertNotNull(volume);
|
||||||
|
|
||||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
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()));
|
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||||
assertEquals(volume.getId(), result.getId());
|
assertEquals(volume.getId(), result.getId());
|
||||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
assertEquals(volume.getAvailabilityZone(), defaultZone);
|
||||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||||
|
|
||||||
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
|
||||||
|
@ -133,8 +140,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
|
||||||
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2,
|
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, 2, snapshot.getId());
|
||||||
snapshot.getId());
|
|
||||||
assertNotNull(volume);
|
assertNotNull(volume);
|
||||||
|
|
||||||
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
|
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()));
|
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
|
||||||
assertEquals(volume.getId(), result.getId());
|
assertEquals(volume.getId(), result.getId());
|
||||||
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
assertEquals(volume.getSnapshotId(), snapshot.getId());
|
||||||
assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
|
assertEquals(volume.getAvailabilityZone(), defaultZone);
|
||||||
assertEquals(volume.getSize(), 2);
|
assertEquals(volume.getSize(), 2);
|
||||||
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
|
||||||
|
|
||||||
|
@ -163,8 +169,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeSnapshots() {
|
void testDescribeSnapshots() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
|
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
@ -179,32 +184,37 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testAddCreateVolumePermissionsToSnapshot() {
|
public void testAddCreateVolumePermissionsToSnapshot() {
|
||||||
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(null, userIds,
|
// TODO client.addCreateVolumePermissionsToSnapshotInRegion(defaultRegion,
|
||||||
|
// userIds,
|
||||||
// userGroups,
|
// userGroups,
|
||||||
// snapshotId);
|
// snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testRemoveCreateVolumePermissionsFromSnapshot() {
|
public void testRemoveCreateVolumePermissionsFromSnapshot() {
|
||||||
// TODO client.removeCreateVolumePermissionsFromSnapshotInRegion(null, userIds,
|
// TODO
|
||||||
|
// client.removeCreateVolumePermissionsFromSnapshotInRegion(defaultRegion,
|
||||||
|
// userIds,
|
||||||
// userGroups,
|
// userGroups,
|
||||||
// snapshotId);
|
// snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testResetCreateVolumePermissionsOnSnapshot() {
|
public void testResetCreateVolumePermissionsOnSnapshot() {
|
||||||
// TODO client.resetCreateVolumePermissionsOnSnapshotInRegion(null, snapshotId);
|
// TODO
|
||||||
|
// client.resetCreateVolumePermissionsOnSnapshotInRegion(defaultRegion,
|
||||||
|
// snapshotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
public void testGetCreateVolumePermissionForSnapshot() {
|
public void testGetCreateVolumePermissionForSnapshot() {
|
||||||
System.out.println(client.getCreateVolumePermissionForSnapshotInRegion(snapshot.getRegion(), snapshot.getId()));
|
client.getCreateVolumePermissionForSnapshotInRegion(snapshot.getRegion(), snapshot.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
@Test(dependsOnMethods = "testCreateSnapshotInRegion")
|
||||||
void testDeleteVolumeInRegion() {
|
void testDeleteVolumeInRegion() {
|
||||||
client.deleteVolumeInRegion(null, volumeId);
|
client.deleteVolumeInRegion(defaultRegion, volumeId);
|
||||||
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(null, volumeId));
|
Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, volumeId));
|
||||||
assertEquals(result.size(), 1);
|
assertEquals(result.size(), 1);
|
||||||
Volume volume = result.iterator().next();
|
Volume volume = result.iterator().next();
|
||||||
assertEquals(volume.getStatus(), Volume.Status.DELETING);
|
assertEquals(volume.getStatus(), Volume.Status.DELETING);
|
||||||
|
|
|
@ -23,14 +23,13 @@ import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
|
import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,19 +43,20 @@ public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiv
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
private ElasticIPAddressClient client;
|
private ElasticIPAddressClient client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices();
|
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
|
client = ec2Client.getElasticIPAddressServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeAddresses() {
|
void testDescribeAddresses() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client.describeAddressesInRegion(region));
|
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client.describeAddressesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
|
|
@ -22,16 +22,14 @@ import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.Reservation;
|
import org.jclouds.ec2.domain.Reservation;
|
||||||
import org.jclouds.ec2.domain.RunningInstance;
|
import org.jclouds.ec2.domain.RunningInstance;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code EC2Client}
|
* Tests behavior of {@code EC2Client}
|
||||||
*
|
*
|
||||||
|
@ -43,19 +41,20 @@ public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
private InstanceClient client;
|
private InstanceClient client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices();
|
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
|
client = ec2Client.getInstanceServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeInstances() {
|
void testDescribeInstances() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert allResults.size() >= 0 : allResults.size();
|
assert allResults.size() >= 0 : allResults.size();
|
||||||
|
|
|
@ -24,14 +24,13 @@ import static org.testng.Assert.assertNotNull;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.KeyPair;
|
import org.jclouds.ec2.domain.KeyPair;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,20 +44,20 @@ public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
private KeyPairClient client;
|
private KeyPairClient client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices();
|
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
|
client = ec2Client.getKeyPairServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeKeyPairs() {
|
void testDescribeKeyPairs() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
|
|
||||||
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
import org.jclouds.ec2.EC2ApiMetadata;
|
||||||
|
import org.jclouds.ec2.EC2Client;
|
||||||
import org.jclouds.ec2.domain.IpPermission;
|
import org.jclouds.ec2.domain.IpPermission;
|
||||||
import org.jclouds.ec2.domain.IpProtocol;
|
import org.jclouds.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.ec2.domain.SecurityGroup;
|
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.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code SecurityGroupClient}
|
* Tests behavior of {@code SecurityGroupClient}
|
||||||
|
@ -54,19 +53,20 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EC2Client ec2Client;
|
||||||
protected SecurityGroupClient client;
|
protected SecurityGroupClient client;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices();
|
ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
|
client = ec2Client.getSecurityGroupServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribe() {
|
void testDescribe() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
Region.AP_SOUTHEAST_1, Region.AP_NORTHEAST_1)) {
|
|
||||||
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
||||||
.describeSecurityGroupsInRegion(region));
|
.describeSecurityGroupsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
|
|
Loading…
Reference in New Issue