From 1858f77451141ed307dd282c64ed334247f1f604 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 1 Jun 2011 16:18:24 -0700 Subject: [PATCH] fixed regressions on ec2 --- .../ec2/compute/EC2ComputeServiceLiveTest.java | 14 ++++++++------ .../ec2/options/RequestSpotInstancesOptions.java | 4 ++-- .../ec2/compute/AWSEC2ComputeServiceLiveTest.java | 2 +- .../options/RequestSpotInstancesOptionsTest.java | 8 ++++---- .../ec2/services/SpotInstanceAsyncClientTest.java | 2 +- .../ec2/services/SpotInstanceClientLiveTest.java | 10 ++++++---- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index e26a487b67..3c2d3819ab 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -26,6 +26,7 @@ import java.util.Set; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.predicates.NodePredicates; @@ -159,12 +160,16 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { String group = this.group + "e"; int volumeSize = 8; + + final Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL) + .osFamily(OsFamily.UBUNTU).osVersionMatches("10.04").imageDescriptionMatches(".*ebs.*").build(); Location zone = Iterables.find(context.getComputeService().listAssignableLocations(), new Predicate() { @Override public boolean apply(Location arg0) { - return arg0.getScope() == LocationScope.ZONE; + return arg0.getScope() == LocationScope.ZONE + && arg0.getParent().getId().equals(template.getLocation().getId()); } }); @@ -174,9 +179,6 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { Snapshot snapshot = ebsClient.createSnapshotInRegion(volume.getRegion(), volume.getId()); ebsClient.deleteVolumeInRegion(volume.getRegion(), volume.getId()); - Template template = context.getComputeService().templateBuilder().locationId(volume.getRegion()).hardwareId( - InstanceType.M1_SMALL).imageDescriptionMatches(".*ebs.*").build(); - template.getOptions().as(EC2TemplateOptions.class)// // .unmapDeviceNamed("/dev/foo) .mapEphemeralDeviceToDeviceName("/dev/sdm", "ephemeral0")// @@ -223,8 +225,8 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { return instance; } - protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient, String group) - throws InterruptedException { + protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient, + String group) throws InterruptedException { try { for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(null)) if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) { diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java index 5ef9dc6e4f..1e9864e0b4 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java @@ -56,7 +56,7 @@ public class RequestSpotInstancesOptions extends BaseEC2RequestOptions { * time and remains active until it expires or is canceled. */ public RequestSpotInstancesOptions validFrom(Date start) { - formParameters.put("ValidFrom", service.iso8601DateFormat(checkNotNull(start, "start"))); + formParameters.put("ValidFrom", service.iso8601SecondsDateFormat(checkNotNull(start, "start"))); return this; } @@ -66,7 +66,7 @@ public class RequestSpotInstancesOptions extends BaseEC2RequestOptions { * persistent, it remains active until it is canceled or this date and time is reached. */ public RequestSpotInstancesOptions validUntil(Date end) { - formParameters.put("ValidUntil", service.iso8601DateFormat(checkNotNull(end, "end"))); + formParameters.put("ValidUntil", service.iso8601SecondsDateFormat(checkNotNull(end, "end"))); return this; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 26c7c4891b..feccab95e5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -46,7 +46,7 @@ import com.google.common.collect.Sets; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true, testName = "AWSEC2ComputeServiceLiveTest") +@Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest") public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public AWSEC2ComputeServiceLiveTest() { diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java index 18df559718..14d18b6024 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java @@ -104,7 +104,7 @@ public class RequestSpotInstancesOptionsTest { RequestSpotInstancesOptions options = new RequestSpotInstancesOptions(); options.validFrom(test); assertEquals(options.buildFormParameters().get("ValidFrom"), - Collections.singletonList("1970-05-23T21:21:18.910Z")); + Collections.singletonList("1970-05-23T21:21:18Z")); } Date test = new Date(12345678910l); @@ -113,7 +113,7 @@ public class RequestSpotInstancesOptionsTest { public void testFromStatic() { RequestSpotInstancesOptions options = validFrom(test); assertEquals(options.buildFormParameters().get("ValidFrom"), - Collections.singletonList("1970-05-23T21:21:18.910Z")); + Collections.singletonList("1970-05-23T21:21:18Z")); } @Test(expectedExceptions = NullPointerException.class) @@ -126,14 +126,14 @@ public class RequestSpotInstancesOptionsTest { RequestSpotInstancesOptions options = new RequestSpotInstancesOptions(); options.validUntil(test); assertEquals(options.buildFormParameters().get("ValidUntil"), - Collections.singletonList("1970-05-23T21:21:18.910Z")); + Collections.singletonList("1970-05-23T21:21:18Z")); } @Test public void testToStatic() { RequestSpotInstancesOptions options = validUntil(test); assertEquals(options.buildFormParameters().get("ValidUntil"), - Collections.singletonList("1970-05-23T21:21:18.910Z")); + Collections.singletonList("1970-05-23T21:21:18Z")); } @Test(expectedExceptions = NullPointerException.class) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java index bed776701b..8ec1e62822 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java @@ -77,7 +77,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest