diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java index c9256be5f3..3783781a50 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java @@ -136,13 +136,15 @@ public class EC2HardwareBuilder extends HardwareBuilder { } public EC2HardwareBuilder virtualizationTypes(VirtualizationType ...virtualizationTypes) { + Preconditions.checkNotNull(virtualizationTypes, "virtualizationTypes"); Preconditions.checkArgument(virtualizationTypes.length > 0, "At least one virtualization type is required."); if (virtualizationTypes.length == 1) { this.virtualizationType = new RequiresVirtualizationType(virtualizationTypes[0]); } else { List supportedVirtualizationTypes = Lists.newArrayList(); for (VirtualizationType virtualizationType : virtualizationTypes) { - supportedVirtualizationTypes.add(new RequiresVirtualizationType(virtualizationType)); + supportedVirtualizationTypes.add(new RequiresVirtualizationType( + Preconditions.checkNotNull(virtualizationType, "virtualizationType"))); } this.virtualizationType = Predicates.or(supportedVirtualizationTypes); } @@ -215,6 +217,15 @@ public class EC2HardwareBuilder extends HardwareBuilder { private EC2HardwareBuilder t2() { virtualizationTypes(VirtualizationType.HVM); + + // TODO T2 is not deprecated, but it requires that you are using a VPC + // until we have a way for hardware instances to be filtered based on network + // we do NOT want T2 selected automatically. + // You get: org.jclouds.aws.AWSResponseException: request POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1 failed with code 400, error: AWSError{requestId='2300b99e-ddc0-42ab-b1ed-9d628a161be4', requestToken='null', code='VPCResourceNotSpecified', message='The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.', context='{Response=, Errors=}'} + // A user can explicitly request a t2.micro if they are also setting up a VPC, + // but the small default will now be m3.medium which supports VPC and "classic". + deprecated(); + return this; } @@ -264,21 +275,25 @@ public class EC2HardwareBuilder extends HardwareBuilder { // http://aws.amazon.com/ec2/previous-generation/ private EC2HardwareBuilder m1() { virtualizationTypes(VirtualizationType.PARAVIRTUAL); + deprecated(); return this; } private EC2HardwareBuilder c1() { virtualizationTypes(VirtualizationType.PARAVIRTUAL); + deprecated(); return this; } private EC2HardwareBuilder cc2() { virtualizationTypes(VirtualizationType.HVM); + deprecated(); return this; } private EC2HardwareBuilder m2() { virtualizationTypes(VirtualizationType.PARAVIRTUAL); + deprecated(); return this; } @@ -286,22 +301,26 @@ public class EC2HardwareBuilder extends HardwareBuilder { private EC2HardwareBuilder hi1() { virtualizationTypes(VirtualizationType.HVM, VirtualizationType.PARAVIRTUAL); + deprecated(); return this; } private EC2HardwareBuilder t1() { virtualizationTypes(VirtualizationType.PARAVIRTUAL); + deprecated(); return this; } private EC2HardwareBuilder cg1() { virtualizationTypes(VirtualizationType.HVM); + deprecated(); return this; } private EC2HardwareBuilder cc1() { // often no longer available - not adding capacity (use cc2) virtualizationTypes(VirtualizationType.HVM); + deprecated(); return this; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java index 1e71648a29..f0504cfbd3 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java @@ -27,6 +27,7 @@ import org.jclouds.compute.domain.Image; import org.jclouds.ec2.compute.domain.RegionAndName; import com.google.common.base.Function; +import com.google.common.base.Preconditions; @Singleton public class ImagesToRegionAndIdMap implements Function, Map> { @@ -43,7 +44,9 @@ public class ImagesToRegionAndIdMap implements Function> images = createMock(Supplier.class); replay(images); - final Image image = new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location) - .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true)) + final Image image = new ImageBuilder().providerId("bogus-image-provider").name("image").id("us-east-1/bogus-image").location(location) + .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "bogus", "ubuntu", true)) .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build()) .status(Image.Status.AVAILABLE) .build(); Map imageMap = ImmutableMap.of( - new RegionAndName(image.getLocation().getId(), image.getProviderId()), image); + new RegionAndName(image.getLocation().getId(), "bogus-image"), image); // weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818 Supplier> imageCache = Suppliers.> ofInstance( CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(imageMap)))); - Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build(); + Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/bogus-image").build(); assert template != null : "The returned template was null, but it should have a value."; - assertEquals(template.getImage().getId(), "us-east-1/cc-image"); + assertEquals(template.getImage().getId(), "us-east-1/bogus-image"); + assertEquals(template.getHardware().getId(), HARDWARE_SUPPORTING_BOGUS.getId()); } @Test(expectedExceptions = {NoSuchElementException.class}) @@ -187,15 +192,20 @@ public class EC2TemplateBuilderTest { private TemplateBuilder newTemplateBuilder() { final Supplier> images = Suppliers.> ofInstance(ImmutableSet. of( - new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location) + new ImageBuilder().providerId("hvm-image-provider").name("image").id("us-east-1/hvm-image").location(location) .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true)) .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build()) .status(Image.Status.AVAILABLE) .build(), - new ImageBuilder().providerId("normal-image").name("image").id("us-east-1/normal-image").location(location) + new ImageBuilder().providerId("pv-image-provider").name("image").id("us-east-1/pv-image").location(location) .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "paravirtual", "ubuntu", true)) .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build()) .status(Image.Status.AVAILABLE) + .build(), + new ImageBuilder().providerId("bogus-image-provider").name("image").id("us-east-1/bogus-image").location(location) + .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "bogus", "ubuntu", true)) + .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build()) + .status(Image.Status.AVAILABLE) .build())); // weird compilation error means have to cast this - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818 @@ -224,7 +234,7 @@ public class EC2TemplateBuilderTest { Supplier> sizes = Suppliers.> ofInstance(ImmutableSet . of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(), m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), - m2_4xlarge().build(), g2_2xlarge().build(), CC1_4XLARGE)); + m2_4xlarge().build(), g2_2xlarge().build(), HARDWARE_SUPPORTING_BOGUS)); return new EC2TemplateBuilderImpl(locations, new ImageCacheSupplier(images, 60), sizes, Suppliers.ofInstance(location), optionsProvider, templateBuilderProvider, getImageStrategy, imageCache) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java index 9c7de8db44..0502175d32 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java @@ -21,6 +21,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; +import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.r3_large; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -109,7 +110,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { Supplier> images = Suppliers.> ofInstance(Sets . newLinkedHashSet()); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet - . of(c1_medium().build())); + . of(c1_medium().build(), r3_large().build())); Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); @@ -133,6 +134,54 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { expect(os.getVersion()).andReturn(null).atLeastOnce(); expect(os.getFamily()).andReturn(null).atLeastOnce(); expect(os.getDescription()).andReturn(null).atLeastOnce(); + expect(os.getArch()).andReturn("hvm").atLeastOnce(); + expect(os.is64Bit()).andReturn(false).atLeastOnce(); + + replay(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); + + TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, region, + optionsProvider, templateBuilderProvider, getImageStrategy); + + assertEquals(template.imageId("us-east-1/ami").build().getImage(), knownImage); + assertEquals(template.imageId("us-east-1/ami").build().getHardware(), r3_large().build()); + + verify(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); + } + + @SuppressWarnings("unchecked") + @Test + public void testParseOnDemandUsesDeprecatedHardwareIfNeeded() { + + Supplier> locations = Suppliers.> ofInstance(ImmutableSet + . of(region)); + Supplier> images = Suppliers.> ofInstance(Sets + . newLinkedHashSet()); + Supplier> sizes = Suppliers.> ofInstance(ImmutableSet + . of(c1_medium().build(), r3_large().build())); + + Provider optionsProvider = createMock(Provider.class); + Provider templateBuilderProvider = createMock(Provider.class); + TemplateOptions defaultOptions = createMock(TemplateOptions.class); + Image knownImage = createMock(Image.class); + OperatingSystem os = createMock(OperatingSystem.class); + GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); + + expect(optionsProvider.get()).andReturn(defaultOptions); + + expect(knownImage.getId()).andReturn("us-east-1/ami").atLeastOnce(); + expect(knownImage.getLocation()).andReturn(region).atLeastOnce(); + expect(knownImage.getName()).andReturn(null).atLeastOnce(); + expect(knownImage.getDescription()).andReturn(null).atLeastOnce(); + expect(knownImage.getVersion()).andReturn(null).atLeastOnce(); + expect(knownImage.getProviderId()).andReturn("ami").atLeastOnce(); + + expect(knownImage.getOperatingSystem()).andReturn(os).atLeastOnce(); + + expect(os.getName()).andReturn(null).atLeastOnce(); + expect(os.getVersion()).andReturn(null).atLeastOnce(); + expect(os.getFamily()).andReturn(null).atLeastOnce(); + expect(os.getDescription()).andReturn(null).atLeastOnce(); + // paravirtual not compatible with r3 so deprecated c1 is forced expect(os.getArch()).andReturn("paravirtual").atLeastOnce(); expect(os.is64Bit()).andReturn(false).atLeastOnce(); @@ -142,6 +191,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { optionsProvider, templateBuilderProvider, getImageStrategy); assertEquals(template.imageId("us-east-1/ami").build().getImage(), knownImage); + assertEquals(template.imageId("us-east-1/ami").build().getHardware(), c1_medium().build()); verify(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/Hardware.java b/compute/src/main/java/org/jclouds/compute/domain/Hardware.java index 93bf52b708..b5d78de537 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/Hardware.java +++ b/compute/src/main/java/org/jclouds/compute/domain/Hardware.java @@ -55,4 +55,9 @@ public interface Hardware extends ComputeMetadata { */ @Nullable String getHypervisor(); + + /** + * True if usage of the hardware profile is now discouraged. + */ + boolean isDeprecated(); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java index 49254a645b..6297be3365 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java @@ -38,6 +38,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder { protected List volumes = Lists.newArrayList(); protected Predicate supportsImage = any(); protected String hypervisor; + protected boolean deprecated = false; public HardwareBuilder() { super(ComputeType.HARDWARE); @@ -78,6 +79,15 @@ public class HardwareBuilder extends ComputeMetadataBuilder { return this; } + public HardwareBuilder deprecated(boolean deprecated) { + this.deprecated = deprecated; + return this; + } + + public HardwareBuilder deprecated() { + return deprecated(true); + } + public HardwareBuilder is64Bit(boolean is64Bit) { supportsImage(is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit())); return this; @@ -126,7 +136,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder { @Override public Hardware build() { return new HardwareImpl(providerId, name, id, location, uri, userMetadata, tags, processors, ram, volumes, - supportsImage, hypervisor); + supportsImage, hypervisor, deprecated); } @SuppressWarnings("unchecked") diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java index 4a547bb0b4..3862b1fa56 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java @@ -46,16 +46,18 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware { private final List volumes; private final Predicate supportsImage; private final String hypervisor; + private final boolean deprecated; public HardwareImpl(String providerId, String name, String id, @Nullable Location location, URI uri, Map userMetadata, Set tags, Iterable processors, int ram, - Iterable volumes, Predicate supportsImage, @Nullable String hypervisor) { + Iterable volumes, Predicate supportsImage, @Nullable String hypervisor, boolean deprecated) { super(ComputeType.HARDWARE, providerId, name, id, location, uri, userMetadata, tags); this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors")); this.ram = ram; this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes")); this.supportsImage = supportsImage; this.hypervisor = hypervisor; + this.deprecated = deprecated; } /** @@ -91,6 +93,14 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware { return hypervisor; } + /** + * {@inheritDoc} + */ + @Override + public boolean isDeprecated() { + return deprecated; + } + /** * {@inheritDoc} */ diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index d2c1a451ef..72a4b473b8 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -483,6 +483,12 @@ public class TemplateBuilderImpl implements TemplateBuilder { return Doubles.compare(getCoresAndSpeed(left), getCoresAndSpeed(right)); } }; + static final Ordering NOT_DEPRECATED_ORDERING = new Ordering() { + public int compare(Hardware left, Hardware right) { + // we take max so deprecated items come first + return ComparisonChain.start().compareTrueFirst(left.isDeprecated(), right.isDeprecated()).result(); + } + }; static final Ordering DEFAULT_IMAGE_ORDERING = new Ordering() { public int compare(Image left, Image right) { /* This currently, and for some time, has *preferred* images whose fields are null, @@ -819,6 +825,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { hardwareOrdering = hardwareOrdering.reverse(); if (fastest) hardwareOrdering = Ordering.compound(ImmutableList.of(BY_CORES_ORDERING, hardwareOrdering)); + hardwareOrdering = Ordering.compound(ImmutableList.of(NOT_DEPRECATED_ORDERING, hardwareOrdering)); return hardwareOrdering; } diff --git a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java index 13ecc9fb5a..eaaf17e6d3 100644 --- a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java +++ b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java @@ -938,10 +938,11 @@ public class TemplateBuilderImplTest { public void testMatchesHardwareWithIdPredicate() { final Supplier> locations = Suppliers.> ofInstance(ImmutableSet . of(region)); + String imageId = getProviderFormatId("Ubuntu 11.04 x64"); final Supplier> images = Suppliers.> ofInstance(ImmutableSet . of( new ImageBuilder() - .ids("Ubuntu 11.04 x64") + .ids(imageId) .name("Ubuntu 11.04 x64") .description("Ubuntu 11.04 x64") .location(region) @@ -950,7 +951,7 @@ public class TemplateBuilderImplTest { OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64") .is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build(), new ImageBuilder() - .ids("Ubuntu 11.04 64-bit") + .ids(getProviderFormatId("Ubuntu 11.04 64-bit")) .name("Ubuntu 11.04 64-bit") .description("Ubuntu 11.04 64-bit") .location(region) @@ -967,14 +968,14 @@ public class TemplateBuilderImplTest { .processors(ImmutableList.of(new Processor(1, 1.0))) .volumes(ImmutableList. of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen") .location(region) - .supportsImage(ImagePredicates.idIn(ImmutableSet.of("Ubuntu 11.04 x64"))).build(), + .supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build(), new HardwareBuilder() .ids(String.format("datacenter(%s)platform(%s)cpuCores(%d)memorySizeMB(%d)diskSizeGB(%d)", "Falkenberg", "OpenVZ", 1, 512, 5)).ram(512) .processors(ImmutableList.of(new Processor(1, 1.0))) .volumes(ImmutableList. of(new VolumeImpl((float) 5, true, true))).hypervisor("OpenVZ") .location(region) - .supportsImage(ImagePredicates.idIn(ImmutableSet.of("Ubuntu 11.04 64-bit"))).build())); + .supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build())); final Provider optionsProvider = new Provider() { @@ -1003,10 +1004,69 @@ public class TemplateBuilderImplTest { Template template = templateBuilder.build(); assertEquals(template.getHardware().getHypervisor(), "OpenVZ"); - assertEquals(template.getImage().getId(), "Ubuntu 11.04 64-bit"); + assertEquals(template.getImage().getId(), imageId); } + @Test + public void testMatchesHardwarePrefersNonDeprecated() { + final Supplier> locations = Suppliers.> ofInstance(ImmutableSet + . of(region)); + String imageId = getProviderFormatId("Ubuntu 11.04 x64"); + final Supplier> images = Suppliers.> ofInstance(ImmutableSet + . of( + new ImageBuilder() + .ids(imageId) + .name("Ubuntu 11.04 x64") + .description("Ubuntu 11.04 x64") + .location(region) + .status(Status.AVAILABLE) + .operatingSystem( + OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64") + .is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build())); + final Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet + . of( + new HardwareBuilder() + .ids(String.format("hardware-deprecated")).ram(512) + .processors(ImmutableList.of(new Processor(1, 1.0))) + .volumes(ImmutableList. of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen") + .location(region) + .deprecated() + .supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build(), + new HardwareBuilder() + .ids(String.format("hardware-good")).ram(512) + .processors(ImmutableList.of(new Processor(1, 1.0))) + .volumes(ImmutableList. of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen") + .location(region) + .supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build())); + + final Provider optionsProvider = new Provider() { + + @Override + public TemplateOptions get() { + return new TemplateOptions(); + } + + }; + + final GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); + + Provider templateBuilderProvider = new Provider() { + + @Override + public TemplateBuilder get() { + return createTemplateBuilder(null, locations, images, hardwares, region, optionsProvider, this, getImageStrategy); + } + + }; + + TemplateBuilder templateBuilder = templateBuilderProvider.get().minRam(512).osFamily(OsFamily.UBUNTU); + + Template template = templateBuilder.build(); + assertEquals(template.getHardware().getId(), "hardware-good"); + assertEquals(template.getImage().getId(), imageId); + } + @Test public void testImageLocationNonDefault() { final Supplier> locations = Suppliers.> ofInstance(ImmutableSet diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceApiMockTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceApiMockTest.java index 2a897957e0..4e55c764de 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceApiMockTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceApiMockTest.java @@ -32,6 +32,20 @@ import com.squareup.okhttp.mockwebserver.MockResponse; @Test(groups = "unit", testName = "AWSEC2ComputeServiceMockTest", singleThreaded = true) public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { + protected String getDefaultSmallestInstanceType() { + // NOT t2.xxx because that requires a VPC + return "m3.medium"; + } + + protected String getDefaultParavirtualInstanceType() { + // smallest non-deprecated instance type supporting paravirtual + return "m3.medium"; + } + + protected String getDefaultImageId() { + return "be3adfd7"; + } + public void launchVPCSpotInstanceSubnetId() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/availabilityZones.xml"); @@ -56,7 +70,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=owner-id&Filter.1.Value.1=137112412989&Filter.1.Value.2=801119661308&Filter.1.Value.3=063491364108&Filter.1.Value.4=099720109477&Filter.1.Value.5=411009282317&Filter.2.Name=state&Filter.2.Value.1=available&Filter.3.Name=image-type&Filter.3.Value.1=machine"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=virtualization-type&Filter.1.Value.1=hvm&Filter.2.Name=architecture&Filter.2.Value.1=x86_64&Filter.3.Name=owner-id&Filter.3.Value.1=137112412989&Filter.3.Value.2=099720109477&Filter.4.Name=hypervisor&Filter.4.Value.1=xen&Filter.5.Name=state&Filter.5.Value.1=available&Filter.6.Name=image-type&Filter.6.Value.1=machine&Filter.7.Name=root-device-type&Filter.7.Value.1=ebs"); - assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.SubnetId=subnet-xyz&LaunchSpecification.KeyName=Demo&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK"); + assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.SubnetId=subnet-xyz&LaunchSpecification.KeyName=Demo&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK"); assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c"); assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406"); @@ -98,7 +112,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654"); - assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver"); + assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver"); assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c"); assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406"); @@ -138,7 +152,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654"); - assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Name=Webserver"); + assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Name=Webserver"); assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c"); assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406"); @@ -174,7 +188,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654"); - assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=t1.micro&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver"); + assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=" + getDefaultParavirtualInstanceType() + "&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver"); assertPosted(DEFAULT_REGION, "Action=DescribeInstances&InstanceId.1=i-2baa5550"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-aecd60c7"); assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-2baa5550&ResourceId.1=i-2baa5550"); @@ -210,7 +224,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest { assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test"); assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654"); - assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=t1.micro&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Name=Webserver"); + assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=" + getDefaultParavirtualInstanceType() + "&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Name=Webserver"); assertPosted(DEFAULT_REGION, "Action=DescribeInstances&InstanceId.1=i-2baa5550"); assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-aecd60c7"); assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-2baa5550&ResourceId.1=i-2baa5550"); 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 0ba7f857dd..a639450a88 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 @@ -93,7 +93,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { } @Test - public void testUbuntuInstanceStoreGoesM1SmallNegativeLookaroundDoesntMatchTestImages() { + public void testUbuntuInstanceStoreGoesM3MediumNegativeLookaroundDoesntMatchTestImages() { Template template = view.getComputeService().templateBuilder() .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)) @@ -114,12 +114,12 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(template.getLocation().getId(), "us-east-1"); assertEquals(getCores(template.getHardware()), 1.0d); - assertEquals(template.getHardware().getId(), InstanceType.M1_SMALL); + assertEquals(template.getHardware().getId(), InstanceType.M3_MEDIUM); // smallest non-deprecated supporting PV assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual"); } @Test - public void testTemplateBuilderCanUseImageIdAndhardwareIdAndAZ() { + public void testTemplateBuilderCanUseImageIdAndHardwareIdAndAZ() { Template template = view.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5") .hardwareId(InstanceType.M2_2XLARGE).locationId("us-east-1a").build(); @@ -141,15 +141,15 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate; - assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().contains("pv-201"), - "Default template version should include 'pv-201' but is " + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().contains("201"), + "Default template version should include '201' but is " + defaultTemplate.getImage().getOperatingSystem().getVersion()); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX); assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); assertEquals(defaultTemplate.getLocation().getId(), "us-east-1"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "paravirtual"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "hvm"); } @Test @@ -158,7 +158,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { Template defaultTemplate = view.getComputeService().templateBuilder().osFamily(AMZN_LINUX) .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build(); assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate; - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2014.09.2"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2015.03.rc-1"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX); assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); @@ -172,13 +172,13 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { Template fastestTemplate = view.getComputeService().templateBuilder().fastest().osFamily(AMZN_LINUX).build(); assert fastestTemplate.getImage().getProviderId().startsWith("ami-") : fastestTemplate; assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.C4_8XLARGE); - assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "vpc-nat-pv-2014.09.1"); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.2"); assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX); assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); assertEquals(fastestTemplate.getLocation().getId(), "us-east-1"); assertEquals(getCores(fastestTemplate.getHardware()), 36.0d); - assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "paravirtual"); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm"); } @Test @@ -219,7 +219,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(template.getLocation().getId(), "us-east-1"); assertEquals(getCores(template.getHardware()), 1.0d); - assertEquals(template.getHardware().getId(), "m1.small"); + assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV // ensure we cache the new image for next time assertEquals(context.getComputeService().listImages().size(), 1); @@ -252,7 +252,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(template.getLocation().getId(), "us-east-1"); assertEquals(getCores(template.getHardware()), 1.0d); - assertEquals(template.getHardware().getId(), "m1.small"); + assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV // ensure we cache the new image for next time assertEquals(context.getComputeService().listImages().size(), 1); @@ -297,7 +297,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(template.getLocation().getId(), "eu-west-1"); assertEquals(getCores(template.getHardware()), 1.0d); - assertEquals(template.getHardware().getId(), "m1.small"); + assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV } finally { if (context != null) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index e30bda6198..4b5b9d46fa 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -45,7 +45,6 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.EC2TemplateBuilderTest; import org.jclouds.ec2.compute.domain.EC2HardwareBuilder; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; @@ -140,7 +139,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT // setup constants String region = Region.US_EAST_1; String group = "group"; - Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE; + Hardware size = EC2HardwareBuilder.cc1_4xlarge().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); @@ -205,7 +204,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT // setup constants String region = Region.US_EAST_1; String group = "group"; - Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE; + Hardware size = EC2HardwareBuilder.cc1_4xlarge().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java index cb4821d9ac..754edcfe3c 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java @@ -165,13 +165,12 @@ public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest assert availableTester.apply(group) : group; } - public void testStartCCInstance() throws Exception { + public void testStartHS1Instance() throws Exception { Template template = view.getComputeService().templateBuilder() - .fromHardware(EC2HardwareBuilder.cc2_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build(); + .fromHardware(EC2HardwareBuilder.hs1_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build(); assert template != null : "The returned template was null, but it should have a value."; - assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE); - assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); + assertEquals(template.getHardware().getProviderId(), InstanceType.HS1_8XLARGE); assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm"); assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java index e944aff0fb..2bdecfc01a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java @@ -139,10 +139,11 @@ public class SpotInstanceApiLiveTest extends BaseComputeServiceContextLiveTest assert spot.getSpotPrice() > 0 : spots; assertEquals(spot.getRegion(), region); assert in( - ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)", + ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)", "Windows", "Windows (Amazon VPC)")).apply(spot.getProductDescription()) : spot; - assert in( - ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large", + assert // sometimes get D2 type, which we don't yet enumerate + spot.getInstanceType().startsWith("d2.") || + in(ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large", "m1.small", "m1.medium", "m1.xlarge", "m2.2xlarge", "m2.4xlarge", "m2.xlarge", "m3.xlarge", "m3.2xlarge", "t1.micro", "cr1.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge")).apply(spot.getInstanceType()) : spot;