stable ec2

This commit is contained in:
Adrian Cole 2012-09-16 22:37:13 -07:00
parent 696f24280a
commit d766f8d4e3
8 changed files with 23 additions and 35 deletions

View File

@ -31,7 +31,7 @@ import org.jclouds.javax.annotation.Nullable;
* />
* @author Adrian Cole
*/
public class SecurityGroup implements Comparable<SecurityGroup> {
public class SecurityGroup {
private final String region;
private final String id;
@ -61,13 +61,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
return region;
}
/**
* {@inheritDoc}
*/
public int compareTo(SecurityGroup o) {
return (this == o) ? 0 : getName().compareTo(o.getName());
}
/**
* id of the security group. Not in all EC2 impls
*/

View File

@ -130,7 +130,8 @@ public class DescribeSecurityGroupsResponseHandler extends
this.ipProtocol = null;
this.ipRanges = Sets.newLinkedHashSet();
} else if (inIpPermissions && !inIpRanges && inGroups) {
this.groups.put(userId, userIdGroupName);
if (userId != null && userIdGroupName != null)
this.groups.put(userId, userIdGroupName);
this.userId = null;
this.userIdGroupName = null;
} else if (!inIpPermissions && !inIpRanges && !inGroups) {

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertNotNull;
import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.ec2.EC2ApiMetadata;
@ -32,14 +31,12 @@ import org.jclouds.ec2.domain.IpPermission;
import org.jclouds.ec2.domain.IpProtocol;
import org.jclouds.ec2.domain.SecurityGroup;
import org.jclouds.ec2.domain.UserIdGroupPair;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
/**
@ -67,15 +64,13 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
@Test
void testDescribe() {
for (String region : ec2Client.getConfiguredRegions()) {
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
.describeSecurityGroupsInRegion(region));
Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
assertNotNull(allResults);
if (allResults.size() >= 1) {
SecurityGroup group = allResults.last();
SortedSet<SecurityGroup> result = ImmutableSortedSet.<SecurityGroup> copyOf(client
.describeSecurityGroupsInRegion(region, group.getName()));
SecurityGroup group = Iterables.getLast(allResults);
Set<SecurityGroup> result = client.describeSecurityGroupsInRegion(region, group.getName());
assertNotNull(result);
SecurityGroup compare = result.last();
SecurityGroup compare = Iterables.getLast(result);
assertEquals(compare, group);
}
}
@ -233,8 +228,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
}
protected void ensureGroupsExist(String group1Name, String group2Name) {
SortedSet<SecurityGroup> twoResults = ImmutableSortedSet.copyOf(client.describeSecurityGroupsInRegion(null,
group1Name, group2Name));
Set<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name);
assertNotNull(twoResults);
assertEquals(twoResults.size(), 2);
Iterator<SecurityGroup> iterator = twoResults.iterator();
@ -279,8 +273,4 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
@AfterTest
public void shutdown() {
view.close();
}
}

View File

@ -69,7 +69,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
properties.setProperty(PROPERTY_EC2_AMI_QUERY,
"owner-id=137112412989,801119661308,063491364108,099720109477,411009282317;state=available;image-type=machine");
// amis that work with the cluster instances
properties.setProperty(PROPERTY_EC2_CC_REGIONS, Region.US_EAST_1 + "," + Region.EU_WEST_1);
properties.setProperty(PROPERTY_EC2_CC_REGIONS, Region.US_EAST_1 + "," + Region.US_WEST_2 + ","+ Region.EU_WEST_1);
properties
.setProperty(
PROPERTY_EC2_CC_AMI_QUERY,

View File

@ -171,7 +171,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
Template defaultTemplate = view.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.03.3");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.09.rc-0");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
@ -186,7 +186,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
Template defaultTemplate = view.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX)
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.03.3");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.09.rc-0");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
@ -201,7 +201,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
.build();
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.HI1_4XLARGE);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.03.3");
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.09.rc-0");
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");

View File

@ -63,7 +63,7 @@ import com.google.inject.Module;
*/
@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest")
public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest {
ArrayList<String> supportedRegions = newArrayList(Region.US_EAST_1, Region.EU_WEST_1);
ArrayList<String> supportedRegions = newArrayList(Region.US_EAST_1, Region.US_WEST_2, Region.EU_WEST_1);
public PlacementGroupClientLiveTest() {
provider = "aws-ec2";

View File

@ -41,7 +41,7 @@ import org.jclouds.aws.ec2.predicates.SpotInstanceRequestActive;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -160,8 +160,9 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe
public static final String PREFIX = System.getProperty("user.name") + "ec2";
@AfterTest
public void shutdown() {
@Override
@AfterClass(groups = { "integration", "live" })
protected void tearDownContext() {
if (requests != null) {
for (SpotInstanceRequest request : requests)
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId());
@ -170,5 +171,6 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe
if (instance != null) {
client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId());
}
super.tearDownContext();
}
}

View File

@ -30,7 +30,7 @@ import org.jclouds.aws.ec2.domain.Tag;
import org.jclouds.aws.ec2.util.TagFilters;
import org.jclouds.aws.ec2.util.TagFilters.ResourceType;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -69,9 +69,11 @@ public class TagClientLiveTest extends BaseComputeServiceContextLiveTest {
}
}
@AfterGroups(groups = { "live" })
public void deleteSecurityGroup() {
@Override
@AfterClass(groups = { "integration", "live" })
protected void tearDownContext() {
view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup);
super.tearDownContext();
}
public static final String PREFIX = System.getProperty("user.name") + "-ec2";