From d766f8d4e3d4ba999183a248a8ca4300a8e6b5c5 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 16 Sep 2012 22:37:13 -0700 Subject: [PATCH] stable ec2 --- .../org/jclouds/ec2/domain/SecurityGroup.java | 9 +-------- ...DescribeSecurityGroupsResponseHandler.java | 3 ++- .../services/SecurityGroupClientLiveTest.java | 20 +++++-------------- .../aws/ec2/AWSEC2ProviderMetadata.java | 2 +- .../AWSEC2TemplateBuilderLiveTest.java | 6 +++--- .../PlacementGroupClientLiveTest.java | 2 +- .../services/SpotInstanceClientLiveTest.java | 8 +++++--- .../aws/ec2/services/TagClientLiveTest.java | 8 +++++--- 8 files changed, 23 insertions(+), 35 deletions(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java index db36b5a634..ee39cc56dc 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java @@ -31,7 +31,7 @@ import org.jclouds.javax.annotation.Nullable; * /> * @author Adrian Cole */ -public class SecurityGroup implements Comparable { +public class SecurityGroup { private final String region; private final String id; @@ -61,13 +61,6 @@ public class SecurityGroup implements Comparable { 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 */ diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java index 9b1b53ddf9..96cb1d1baf 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java @@ -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) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java index 0f0c9e67a0..3cfa7738e2 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java @@ -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 allResults = ImmutableSortedSet. copyOf(client - .describeSecurityGroupsInRegion(region)); + Set allResults = client.describeSecurityGroupsInRegion(region); assertNotNull(allResults); if (allResults.size() >= 1) { - SecurityGroup group = allResults.last(); - SortedSet result = ImmutableSortedSet. copyOf(client - .describeSecurityGroupsInRegion(region, group.getName())); + SecurityGroup group = Iterables.getLast(allResults); + Set 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 twoResults = ImmutableSortedSet.copyOf(client.describeSecurityGroupsInRegion(null, - group1Name, group2Name)); + Set twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name); assertNotNull(twoResults); assertEquals(twoResults.size(), 2); Iterator 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(); - } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index 4cffbd31ca..ef304cb991 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -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, diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 00d3ba3e56..f6ac142c0a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -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"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index 9d33a3b6ef..dc93bd90f3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -63,7 +63,7 @@ import com.google.inject.Module; */ @Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest") public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { - ArrayList supportedRegions = newArrayList(Region.US_EAST_1, Region.EU_WEST_1); + ArrayList supportedRegions = newArrayList(Region.US_EAST_1, Region.US_WEST_2, Region.EU_WEST_1); public PlacementGroupClientLiveTest() { provider = "aws-ec2"; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 7bbc22c6ee..26188dc5f7 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -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(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java index 42286e54a5..f6d3466159 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java @@ -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";