mirror of https://github.com/apache/jclouds.git
stable ec2
This commit is contained in:
parent
696f24280a
commit
d766f8d4e3
|
@ -31,7 +31,7 @@ import org.jclouds.javax.annotation.Nullable;
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SecurityGroup implements Comparable<SecurityGroup> {
|
public class SecurityGroup {
|
||||||
|
|
||||||
private final String region;
|
private final String region;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
@ -61,13 +61,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
||||||
return region;
|
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
|
* id of the security group. Not in all EC2 impls
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -130,7 +130,8 @@ public class DescribeSecurityGroupsResponseHandler extends
|
||||||
this.ipProtocol = null;
|
this.ipProtocol = null;
|
||||||
this.ipRanges = Sets.newLinkedHashSet();
|
this.ipRanges = Sets.newLinkedHashSet();
|
||||||
} else if (inIpPermissions && !inIpRanges && inGroups) {
|
} else if (inIpPermissions && !inIpRanges && inGroups) {
|
||||||
this.groups.put(userId, userIdGroupName);
|
if (userId != null && userIdGroupName != null)
|
||||||
|
this.groups.put(userId, userIdGroupName);
|
||||||
this.userId = null;
|
this.userId = null;
|
||||||
this.userIdGroupName = null;
|
this.userIdGroupName = null;
|
||||||
} else if (!inIpPermissions && !inIpRanges && !inGroups) {
|
} else if (!inIpPermissions && !inIpRanges && !inGroups) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
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.IpProtocol;
|
||||||
import org.jclouds.ec2.domain.SecurityGroup;
|
import org.jclouds.ec2.domain.SecurityGroup;
|
||||||
import org.jclouds.ec2.domain.UserIdGroupPair;
|
import org.jclouds.ec2.domain.UserIdGroupPair;
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
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.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
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.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,15 +64,13 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
@Test
|
@Test
|
||||||
void testDescribe() {
|
void testDescribe() {
|
||||||
for (String region : ec2Client.getConfiguredRegions()) {
|
for (String region : ec2Client.getConfiguredRegions()) {
|
||||||
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
|
||||||
.describeSecurityGroupsInRegion(region));
|
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
SecurityGroup group = allResults.last();
|
SecurityGroup group = Iterables.getLast(allResults);
|
||||||
SortedSet<SecurityGroup> result = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
Set<SecurityGroup> result = client.describeSecurityGroupsInRegion(region, group.getName());
|
||||||
.describeSecurityGroupsInRegion(region, group.getName()));
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
SecurityGroup compare = result.last();
|
SecurityGroup compare = Iterables.getLast(result);
|
||||||
assertEquals(compare, group);
|
assertEquals(compare, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,8 +228,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ensureGroupsExist(String group1Name, String group2Name) {
|
protected void ensureGroupsExist(String group1Name, String group2Name) {
|
||||||
SortedSet<SecurityGroup> twoResults = ImmutableSortedSet.copyOf(client.describeSecurityGroupsInRegion(null,
|
Set<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name);
|
||||||
group1Name, group2Name));
|
|
||||||
assertNotNull(twoResults);
|
assertNotNull(twoResults);
|
||||||
assertEquals(twoResults.size(), 2);
|
assertEquals(twoResults.size(), 2);
|
||||||
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
||||||
|
@ -279,8 +273,4 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
public void shutdown() {
|
|
||||||
view.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(PROPERTY_EC2_AMI_QUERY,
|
properties.setProperty(PROPERTY_EC2_AMI_QUERY,
|
||||||
"owner-id=137112412989,801119661308,063491364108,099720109477,411009282317;state=available;image-type=machine");
|
"owner-id=137112412989,801119661308,063491364108,099720109477,411009282317;state=available;image-type=machine");
|
||||||
// amis that work with the cluster instances
|
// 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
|
properties
|
||||||
.setProperty(
|
.setProperty(
|
||||||
PROPERTY_EC2_CC_AMI_QUERY,
|
PROPERTY_EC2_CC_AMI_QUERY,
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
||||||
|
|
||||||
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
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().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
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)
|
Template defaultTemplate = view.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX)
|
||||||
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
||||||
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
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().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||||
|
@ -201,7 +201,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
||||||
.build();
|
.build();
|
||||||
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
||||||
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.HI1_4XLARGE);
|
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().is64Bit(), true);
|
||||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||||
|
|
|
@ -63,7 +63,7 @@ import com.google.inject.Module;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest")
|
||||||
public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest {
|
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() {
|
public PlacementGroupClientLiveTest() {
|
||||||
provider = "aws-ec2";
|
provider = "aws-ec2";
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.jclouds.aws.ec2.predicates.SpotInstanceRequestActive;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.testng.annotations.AfterTest;
|
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;
|
||||||
|
|
||||||
|
@ -160,8 +160,9 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "ec2";
|
public static final String PREFIX = System.getProperty("user.name") + "ec2";
|
||||||
|
|
||||||
@AfterTest
|
@Override
|
||||||
public void shutdown() {
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
protected void tearDownContext() {
|
||||||
if (requests != null) {
|
if (requests != null) {
|
||||||
for (SpotInstanceRequest request : requests)
|
for (SpotInstanceRequest request : requests)
|
||||||
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId());
|
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId());
|
||||||
|
@ -170,5 +171,6 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId());
|
client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId());
|
||||||
}
|
}
|
||||||
|
super.tearDownContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
import org.jclouds.aws.ec2.util.TagFilters.ResourceType;
|
import org.jclouds.aws.ec2.util.TagFilters.ResourceType;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
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.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -69,9 +69,11 @@ public class TagClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = { "live" })
|
@Override
|
||||||
public void deleteSecurityGroup() {
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
protected void tearDownContext() {
|
||||||
view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup);
|
view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup);
|
||||||
|
super.tearDownContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
public static final String PREFIX = System.getProperty("user.name") + "-ec2";
|
||||||
|
|
Loading…
Reference in New Issue