Issue 491:support new ap-northeast-1 region in aws

This commit is contained in:
Adrian Cole 2011-03-03 09:44:53 -05:00
parent b40c8ccb1b
commit 739bcc4c68
51 changed files with 339 additions and 653 deletions

View File

@ -115,7 +115,7 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
})); }));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
System.err.printf("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations); logger.error("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations);
builder.location(new LocationBuilder().scope(LocationScope.REGION).id(from.getRegion()).description( builder.location(new LocationBuilder().scope(LocationScope.REGION).id(from.getRegion()).description(
from.getRegion()).parent(defaultLocation.get()).build()); from.getRegion()).parent(defaultLocation.get()).build());
} }

View File

@ -20,7 +20,6 @@
package org.jclouds.ec2.compute.strategy; package org.jclouds.ec2.compute.strategy;
import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.getOnlyElement;
import static org.jclouds.ec2.util.EC2Utils.getAllRunningInstancesInRegion;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@ -32,8 +31,10 @@ import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.ec2.services.InstanceClient;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables;
/** /**
* *
@ -66,4 +67,9 @@ public class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
} }
} }
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client, String region,
String id) {
return Iterables.concat(client.describeInstancesInRegion(region, id));
}
} }

View File

@ -1,49 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.domain;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
/**
*
* Availability zones used for all ec2 instance commands.
*
* @author Adrian Cole
*/
public class AvailabilityZone {
public static final String EU_WEST_1A = "eu-west-1a";
public static final String EU_WEST_1B = "eu-west-1b";
public static final String US_EAST_1A = "us-east-1a";
public static final String US_EAST_1B = "us-east-1b";
public static final String US_EAST_1C = "us-east-1c";
public static final String US_EAST_1D = "us-east-1d";
public static final String US_WEST_1A = "us-west-1a";
public static final String US_WEST_1B = "us-west-1b";
public static final String AP_SOUTHEAST_1A = "ap-southeast-1a";
public static final String AP_SOUTHEAST_1B = "ap-southeast-1b";
public static final Set<String> zones = ImmutableSet.of(EU_WEST_1A, EU_WEST_1B,
US_EAST_1A, US_EAST_1B, US_EAST_1C, US_EAST_1D,
US_WEST_1A, US_WEST_1B, AP_SOUTHEAST_1A, AP_SOUTHEAST_1B);
}

View File

@ -22,7 +22,6 @@ package org.jclouds.ec2.options;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
/** /**
@ -61,7 +60,7 @@ public class DescribeRegionsOptions extends BaseEC2RequestOptions {
public static class Builder { public static class Builder {
/** /**
* @see DescribeRegionsOptions#regions(Region[] ) * @see DescribeRegionsOptions#regions(String[] )
*/ */
public static DescribeRegionsOptions regions(String... regions) { public static DescribeRegionsOptions regions(String... regions) {
DescribeRegionsOptions options = new DescribeRegionsOptions(); DescribeRegionsOptions options = new DescribeRegionsOptions();

View File

@ -1,83 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.util;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jclouds.aws.util.AWSUtils;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.ec2.services.InstanceClient;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
public class EC2Utils {
public static String[] getAvailabilityZonesForRegion(String region) {
Set<String> availabilityZones = new HashSet<String>();
for (String az : AvailabilityZone.zones) {
if (az.startsWith(region))
availabilityZones.add(az);
}
return (String[]) availabilityZones.toArray(new String[availabilityZones.size()]);
}
public static Iterable<RunningInstance> getAllRunningInstancesInRegion(InstanceClient client, String region,
String id) {
return Iterables.concat(client.describeInstancesInRegion(region, id));
}
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
for (Object arg : gRequest.getArgs()) {
if (arg instanceof String) {
String zone = (String) arg;
if (AvailabilityZone.zones.contains(zone))
return zone;
}
}
return null;
}
private static final Pattern ELB_PATTERN = Pattern.compile("([^.]+)-[^.]+\\.([^.]+)\\.elb\\.amazonaws\\.com");
public static Map<String, String> getLoadBalancerNameAndRegionFromDnsName(String dnsName) {
Matcher matcher = ELB_PATTERN.matcher(checkNotNull(dnsName, "dnsName"));
checkArgument(matcher.find(), "dnsName syntax is " + ELB_PATTERN + " didn't match: " + dnsName);
String loadBalancerName = matcher.group(1);
String regionName = matcher.group(2);
checkArgument((AWSUtils.isRegion(regionName)),
String.format("Region (%s) parsed from (%s) is not a valid region", regionName, dnsName));
return ImmutableMap.<String, String> of(regionName, loadBalancerName);
}
}

View File

@ -28,16 +28,16 @@ import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.ec2.util.EC2Utils;
import org.jclouds.aws.util.AWSUtils; import org.jclouds.aws.util.AWSUtils;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.location.Region; import org.jclouds.location.Region;
import org.jclouds.location.Zone; import org.jclouds.location.Zone;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -46,8 +46,7 @@ import com.google.common.collect.Sets;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CreateVolumeResponseHandler extends public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
@Resource @Resource
@ -128,8 +127,7 @@ public class CreateVolumeResponseHandler extends
attachTime = dateService.iso8601DateParse(currentText.toString().trim()); attachTime = dateService.iso8601DateParse(currentText.toString().trim());
} else if (qName.equals("item")) { } else if (qName.equals("item")) {
if (inAttachmentSet) { if (inAttachmentSet) {
attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime));
attachTime));
volumeId = null; volumeId = null;
instanceId = null; instanceId = null;
device = null; device = null;
@ -142,8 +140,7 @@ public class CreateVolumeResponseHandler extends
} }
private Volume newVolume() { private Volume newVolume() {
Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments);
createTime, attachments);
id = null; id = null;
size = 0; size = 0;
snapshotId = null; snapshotId = null;
@ -163,14 +160,26 @@ public class CreateVolumeResponseHandler extends
super.setContext(request); super.setContext(request);
region = AWSUtils.findRegionInArgsOrNull(getRequest()); region = AWSUtils.findRegionInArgsOrNull(getRequest());
if (region == null) { if (region == null) {
String zone = EC2Utils.findAvailabilityZoneInArgsOrNull(getRequest()); String zone = findAvailabilityZoneInArgsOrNull(getRequest(), availabilityZoneToRegion.keySet());
if (zone != null) { if (zone != null) {
region = checkNotNull(availabilityZoneToRegion.get(zone), String.format( region = checkNotNull(availabilityZoneToRegion.get(zone),
"zone %s not in %s", zone, availabilityZoneToRegion)); String.format("zone %s not in %s", zone, availabilityZoneToRegion));
} else { } else {
region = defaultRegion; region = defaultRegion;
} }
} }
return this; return this;
} }
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest, Set<String> zones) {
for (Object arg : gRequest.getArgs()) {
if (arg instanceof String) {
String zone = (String) arg;
if (zones.contains(zone))
return zone;
}
}
return null;
}
} }

View File

@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.easymock.IArgumentMatcher; import org.easymock.IArgumentMatcher;
import org.jclouds.aws.domain.Region;
import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.config.CustomizationResponse;
import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
@ -44,7 +43,6 @@ import org.jclouds.domain.LocationScope;
import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata; import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.ec2.options.RunInstancesOptions; import org.jclouds.ec2.options.RunInstancesOptions;
@ -65,12 +63,12 @@ public class EC2RunNodesAndAddToSetStrategyTest {
@Test @Test
public void testZoneAsALocation() { public void testZoneAsALocation() {
assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, Region.AP_SOUTHEAST_1, AvailabilityZone.AP_SOUTHEAST_1A); assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, "ap-southeast-1", "ap-southeast-1a");
} }
@Test @Test
public void testRegionAsALocation() { public void testRegionAsALocation() {
assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, Region.AP_SOUTHEAST_1, null); assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, "ap-southeast-1", null);
} }
// // fixtures // // fixtures
@ -155,10 +153,10 @@ public class EC2RunNodesAndAddToSetStrategyTest {
} }
private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id( private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id(
Region.AP_SOUTHEAST_1).description(Region.AP_SOUTHEAST_1).parent( "ap-southeast-1").description("ap-southeast-1").parent(
new LocationBuilder().scope(LocationScope.PROVIDER).id("ec2").description("ec2").build()).build(); new LocationBuilder().scope(LocationScope.PROVIDER).id("aws-ec2").description("aws-ec2").build()).build();
private static final Location ZONE_AP_SOUTHEAST_1A = new LocationBuilder().scope(LocationScope.ZONE).id( private static final Location ZONE_AP_SOUTHEAST_1A = new LocationBuilder().scope(LocationScope.ZONE).id(
AvailabilityZone.AP_SOUTHEAST_1A).description(AvailabilityZone.AP_SOUTHEAST_1A).parent( "ap-southeast-1a").description("ap-southeast-1a").parent(
REGION_AP_SOUTHEAST_1).build(); REGION_AP_SOUTHEAST_1).build();
// ///////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////

View File

@ -27,7 +27,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
import org.jclouds.ec2.options.DescribeRegionsOptions; import org.jclouds.ec2.options.DescribeRegionsOptions;
import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler; import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler;
@ -48,17 +47,17 @@ import com.google.inject.TypeLiteral;
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest") @Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest")
public class AvailabilityZoneAndRegionAsyncClientTest extends public class AvailabilityZoneAndRegionAsyncClientTest extends
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> { BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException { public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, Region.US_WEST_1); HttpRequest request = processor.createRequest(method, Region.US_WEST_1);
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones", assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class); assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
@ -69,15 +68,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException { public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, Region.US_EAST_1, availabilityZones( HttpRequest request = processor.createRequest(method, "us-east-1", availabilityZones("us-east-1a", "us-east-1b"));
AvailabilityZone.US_EAST_1A, AvailabilityZone.US_EAST_1B));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, assertPayloadEquals(request,
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b", "Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class); assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class);
@ -87,14 +85,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
} }
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException { public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance( Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
DescribeRegionsOptions.class, 0).getClass()); Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method); HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded", assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded",
false); false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class); assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);
@ -104,15 +102,15 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
} }
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException { public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance( Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
DescribeRegionsOptions.class, 0).getClass()); Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1)); HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, assertPayloadEquals(request,
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1", "Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class); assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class);

View File

@ -34,7 +34,6 @@ import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.EC2ContextBuilder; import org.jclouds.ec2.EC2ContextBuilder;
import org.jclouds.ec2.EC2PropertiesBuilder; import org.jclouds.ec2.EC2PropertiesBuilder;
import org.jclouds.ec2.config.EC2RestClientModule; import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
@ -85,7 +84,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
static class Zones implements javax.inject.Provider<Map<String, String>> { static class Zones implements javax.inject.Provider<Map<String, String>> {
@Override @Override
public Map<String, String> get() { public Map<String, String> get() {
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
} }
} }
} }

View File

@ -26,7 +26,6 @@ import java.io.IOException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable; import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable;
import org.jclouds.ec2.options.CreateSnapshotOptions; import org.jclouds.ec2.options.CreateSnapshotOptions;
import org.jclouds.ec2.options.DescribeSnapshotsOptions; import org.jclouds.ec2.options.DescribeSnapshotsOptions;
@ -59,7 +58,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeInAvailabilityZone", String.class, Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeInAvailabilityZone", String.class,
int.class); int.class);
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, 20); HttpRequest request = processor.createRequest(method, "us-east-1a", 20);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -76,7 +75,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, IOException { public void testCreateVolumeFromSnapShot() throws SecurityException, NoSuchMethodException, IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone", Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
String.class, String.class); String.class, String.class);
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, "snapshotId"); HttpRequest request = processor.createRequest(method, "us-east-1a", "snapshotId");
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -94,7 +93,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException, IOException { public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException, IOException {
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone", Method method = ElasticBlockStoreAsyncClient.class.getMethod("createVolumeFromSnapshotInAvailabilityZone",
String.class, int.class, String.class); String.class, int.class, String.class);
HttpRequest request = processor.createRequest(method, AvailabilityZone.US_EAST_1A, 15, "snapshotId"); HttpRequest request = processor.createRequest(method, "us-east-1a", 15, "snapshotId");
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");

View File

@ -34,7 +34,6 @@ import org.jclouds.aws.domain.Region;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Snapshot;
import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.domain.Volume;
import org.jclouds.ec2.predicates.SnapshotCompleted; import org.jclouds.ec2.predicates.SnapshotCompleted;
@ -104,8 +103,7 @@ public class ElasticBlockStoreClientLiveTest {
@Test @Test
void testDescribeVolumes() { void testDescribeVolumes() {
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
Region.AP_SOUTHEAST_1)) {
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
if (allResults.size() >= 1) { if (allResults.size() >= 1) {
@ -120,10 +118,10 @@ public class ElasticBlockStoreClientLiveTest {
@Test @Test
void testCreateVolumeInAvailabilityZone() { void testCreateVolumeInAvailabilityZone() {
Volume expected = client.createVolumeInAvailabilityZone(AvailabilityZone.US_EAST_1B, 1); Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1);
assertNotNull(expected); assertNotNull(expected);
System.out.println(expected); System.out.println(expected);
assertEquals(expected.getAvailabilityZone(), AvailabilityZone.US_EAST_1B); assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone());
this.volumeId = expected.getId(); this.volumeId = expected.getId();
@ -148,9 +146,13 @@ public class ElasticBlockStoreClientLiveTest {
this.snapshot = result; this.snapshot = result;
} }
protected String getDefaultAvailabilityZone(){
return "us-east-1a";
}
@Test(dependsOnMethods = "testCreateSnapshotInRegion") @Test(dependsOnMethods = "testCreateSnapshotInRegion")
void testCreateVolumeFromSnapshotInAvailabilityZone() { void testCreateVolumeFromSnapshotInAvailabilityZone() {
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1A, snapshot.getId()); Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId());
assertNotNull(volume); assertNotNull(volume);
Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10, Predicate<Volume> availabile = new RetryablePredicate<Volume>(new VolumeAvailable(client), 600, 10,
@ -160,7 +162,7 @@ public class ElasticBlockStoreClientLiveTest {
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId())); Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
assertEquals(volume.getId(), result.getId()); assertEquals(volume.getId(), result.getId());
assertEquals(volume.getSnapshotId(), snapshot.getId()); assertEquals(volume.getSnapshotId(), snapshot.getId());
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1A); assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
assertEquals(result.getStatus(), Volume.Status.AVAILABLE); assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId()); client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId());
@ -168,7 +170,7 @@ public class ElasticBlockStoreClientLiveTest {
@Test(dependsOnMethods = "testCreateSnapshotInRegion") @Test(dependsOnMethods = "testCreateSnapshotInRegion")
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() { void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1B, 2, Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2,
snapshot.getId()); snapshot.getId());
assertNotNull(volume); assertNotNull(volume);
@ -179,7 +181,7 @@ public class ElasticBlockStoreClientLiveTest {
Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId())); Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
assertEquals(volume.getId(), result.getId()); assertEquals(volume.getId(), result.getId());
assertEquals(volume.getSnapshotId(), snapshot.getId()); assertEquals(volume.getSnapshotId(), snapshot.getId());
assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1B); assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone());
assertEquals(volume.getSize(), 2); assertEquals(volume.getSize(), 2);
assertEquals(result.getStatus(), Volume.Status.AVAILABLE); assertEquals(result.getStatus(), Volume.Status.AVAILABLE);

View File

@ -24,8 +24,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.domain.Region;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
@ -131,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException { public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass()); String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", HttpRequest request = processor.createRequest(method, "eu-west-1", "eu-west-1a", "ami-voo",
1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2")); 1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"));
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");

View File

@ -1,52 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.utils;
import static org.testng.Assert.assertEquals;
import org.jclouds.ec2.util.EC2Utils;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
/**
* @author Adrian Cole
*/
@Test(groups = "unit")
public class EC2UtilsTest {
public void testGetLoadBalancerNameAndRegionFromDnsName() {
assertEquals(
ImmutableMap.<String, String> of("us-east-1", "my-load-balancer"),
EC2Utils
.getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.elb.amazonaws.com"));
assertEquals(
ImmutableMap.<String, String> of("us-east-1", "ec2lb"),
EC2Utils
.getLoadBalancerNameAndRegionFromDnsName("ec2lb-915583419.us-east-1.elb.amazonaws.com"));
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testGetLoadBalancerNameAndRegionFromDnsNameFail() {
EC2Utils
.getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.microsoft.com");
}
}

View File

@ -24,7 +24,6 @@ import java.util.Map;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.http.functions.config.SaxParserModule;
@ -68,7 +67,7 @@ public abstract class BaseEC2HandlerTest extends BaseHandlerTest {
@Provides @Provides
@Zone @Zone
Map<String, String> provideAvailabilityZoneRegionMap() { Map<String, String> provideAvailabilityZoneRegionMap() {
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
} }
}); });
factory = injector.getInstance(ParseSax.Factory.class); factory = injector.getInstance(ParseSax.Factory.class);

View File

@ -29,7 +29,6 @@ import java.io.InputStream;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.domain.Volume;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
@ -52,7 +51,7 @@ public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest {
InputStream is = getClass().getResourceAsStream("/created_volume.xml"); InputStream is = getClass().getResourceAsStream("/created_volume.xml");
Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null, Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null,
AvailabilityZone.US_EAST_1A, Volume.Status.CREATING, dateService "us-east-1a", Volume.Status.CREATING, dateService
.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets .iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets
.<Attachment> newLinkedHashSet()); .<Attachment> newLinkedHashSet());

View File

@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.util.Set; import java.util.Set;
import org.jclouds.aws.domain.Region;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.jclouds.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
@ -66,14 +64,14 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of( Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet.<String> of()), new AvailabilityZoneInfo("us-east-1a", "available", "us-east-1", ImmutableSet.<String> of()),
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet new AvailabilityZoneInfo("us-east-1b", "available", "us-east-1", ImmutableSet
.<String> of()), .<String> of()),
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1, ImmutableSet new AvailabilityZoneInfo("us-east-1c", "available", "us-east-1", ImmutableSet
.<String> of("our service is awesome")), .<String> of("our service is awesome")),
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1, ImmutableSet new AvailabilityZoneInfo("us-east-1d", "downlikeaclown", "us-east-1", ImmutableSet
.<String> of())); .<String> of()));
Set<AvailabilityZoneInfo> result = factory.create( Set<AvailabilityZoneInfo> result = factory.create(
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is); injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);

View File

@ -27,7 +27,6 @@ import java.util.Set;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
@ -74,7 +73,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
"174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime( "174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")) dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
// MonitoringState.DISABLED, // MonitoringState.DISABLED,
.availabilityZone(AvailabilityZone.US_EAST_1C).virtualizationType("paravirtual") .availabilityZone("us-east-1c").virtualizationType("paravirtual")
.privateDnsName("ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId( .privateDnsName("ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId(
"ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), "ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
"993194456877", null, "r-a3c508cb")); "993194456877", null, "r-a3c508cb"));
@ -92,7 +91,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime( InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
// MonitoringState.DISABLED, // MonitoringState.DISABLED,
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual") .availabilityZone("us-east-1b").virtualizationType("paravirtual")
.privateDnsName("10-251-50-132.ec2.internal")// product codes .privateDnsName("10-251-50-132.ec2.internal")// product codes
// ImmutableSet.of("774F4FF8") // ImmutableSet.of("774F4FF8")
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(), .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(),
@ -102,7 +101,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name") InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) .launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
// MonitoringState.DISABLED, // MonitoringState.DISABLED,
.availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual") .availabilityZone("us-east-1b").virtualizationType("paravirtual")
.privateDnsName("10-251-50-134.ec2.internal")// product codes .privateDnsName("10-251-50-134.ec2.internal")// product codes
// ImmutableSet.of("774F4FF8") // ImmutableSet.of("774F4FF8")
.ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
@ -124,7 +123,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
.keyName("adriancole.ec2ebs1") .keyName("adriancole.ec2ebs1")
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")) .launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
// MonitoringState.DISABLED // MonitoringState.DISABLED
.availabilityZone(AvailabilityZone.US_EAST_1B) .availabilityZone("us-east-1b")
// "placement" // "placement"
.virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal") .virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
.privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc") .privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc")

View File

@ -27,10 +27,9 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.util.Set; import java.util.Set;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -52,11 +51,11 @@ public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest {
InputStream is = getClass().getResourceAsStream("/describe_volumes.xml"); InputStream is = getClass().getResourceAsStream("/describe_volumes.xml");
Set<Volume> expected = Sets.newLinkedHashSet(); Set<Volume> expected = Sets.newLinkedHashSet();
expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, AvailabilityZone.US_EAST_1A, expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a",
Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"), Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
Sets.<Attachment> newLinkedHashSet())); Sets.<Attachment> newLinkedHashSet()));
expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a", expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
AvailabilityZone.US_EAST_1A, Volume.Status.IN_USE, dateService "us-east-1a", Volume.Status.IN_USE, dateService
.iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets .iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets
.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509", .<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
"/dev/sdh", Attachment.Status.ATTACHED, dateService "/dev/sdh", Attachment.Status.ATTACHED, dateService

View File

@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.Reservation;
@ -70,19 +69,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
.imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType( .imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
.availabilityZone(AvailabilityZone.US_EAST_1B).build(), .availabilityZone("us-east-1b").build(),
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1") new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1")
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType( .imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
.availabilityZone(AvailabilityZone.US_EAST_1B).build(), .availabilityZone("us-east-1b").build(),
new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2") new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2")
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType( .imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED,
.availabilityZone(AvailabilityZone.US_EAST_1B).build()) .availabilityZone("us-east-1b").build())
, "AIDADH4IGTRXXKCD", null, "r-47a5402e"); , "AIDADH4IGTRXXKCD", null, "r-47a5402e");

View File

@ -44,13 +44,13 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.config.S3RestClientModule;
import org.jclouds.s3.domain.AccessControlList; import org.jclouds.s3.domain.AccessControlList;
import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee;
import org.jclouds.s3.domain.AccessControlList.Grant;
import org.jclouds.s3.domain.AccessControlList.Permission;
import org.jclouds.s3.domain.BucketLogging; import org.jclouds.s3.domain.BucketLogging;
import org.jclouds.s3.domain.CannedAccessPolicy; import org.jclouds.s3.domain.CannedAccessPolicy;
import org.jclouds.s3.domain.Payer; import org.jclouds.s3.domain.Payer;
import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.domain.S3Object;
import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee;
import org.jclouds.s3.domain.AccessControlList.Grant;
import org.jclouds.s3.domain.AccessControlList.Permission;
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders; import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState; import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
@ -87,7 +87,7 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance( Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
PutBucketOptions.class, 0).getClass()); PutBucketOptions.class, 0).getClass());
for (String region : Region.ALL_S3) { for (String region : Region.DEFAULT_S3) {
processor.createRequest(method, region, "bucket-name"); processor.createRequest(method, region, "bucket-name");
} }
} }

View File

@ -19,8 +19,15 @@
package org.jclouds.aws.domain; package org.jclouds.aws.domain;
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
@ -84,6 +91,36 @@ public class Region {
*/ */
public static final String AP_SOUTHEAST_1 = "ap-southeast-1"; public static final String AP_SOUTHEAST_1 = "ap-southeast-1";
public static Set<String> ALL_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1); /**
public static Set<String> ALL_SQS = ImmutableSet.of(EU_WEST_1, US_STANDARD, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1); * Region in Tokyo, launched March 2, 2011. This region improves latency for Asia-based users
*/
public static final String AP_NORTHEAST_1 = "ap-northeast-1";
public static Set<String> DEFAULT_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1, AP_NORTHEAST_1);
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1,
AP_NORTHEAST_1);
public static Properties regionPropertiesS3() {
Properties properties = regionProperties();
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_S3));
// note that due to US_STANDARD the codes include US instead of US-VA
properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG,JP-13");
properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ISO3166_CODES, "US");
properties.setProperty(PROPERTY_REGION + "." + EU + "." + ISO3166_CODES, "IE");
return properties;
}
public static Properties regionProperties() {
Properties properties = new Properties();
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG,JP-13");
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA");
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE");
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ISO3166_CODES, "JP-13");
return properties;
}
} }

View File

@ -117,10 +117,9 @@ public class AWSUtils {
return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms); return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms);
} }
// TODO: make this more dynamic
public static boolean isRegion(String regionName) { public static boolean isRegion(String regionName) {
return Region.EU_WEST_1.equals(regionName) || Region.US_WEST_1.equals(regionName) return Region.DEFAULT_REGIONS.contains(regionName);
|| Region.US_EAST_1.equals(regionName) || Region.US_STANDARD.equals(regionName)
|| Region.AP_SOUTHEAST_1.equals(regionName);
} }
public static <R extends HttpRequest> R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) { public static <R extends HttpRequest> R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) {
@ -162,7 +161,7 @@ public class AWSUtils {
for (Object arg : gRequest.getArgs()) { for (Object arg : gRequest.getArgs()) {
if (arg instanceof String) { if (arg instanceof String) {
String regionName = (String) arg; String regionName = (String) arg;
//TODO regions may not be amazon regions! // TODO regions may not be amazon regions!
// take from a configured value // take from a configured value
if (isRegion(regionName)) if (isRegion(regionName))
return regionName; return regionName;

View File

@ -36,7 +36,10 @@ sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder
sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder
aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBuilder
aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder
aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder
aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder
aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder

View File

@ -20,23 +20,13 @@
package org.jclouds.aws.ec2; package org.jclouds.aws.ec2;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
import static org.jclouds.aws.domain.Region.EU_WEST_1;
import static org.jclouds.aws.domain.Region.US_EAST_1;
import static org.jclouds.aws.domain.Region.US_WEST_1;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED; import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED;
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import com.google.common.base.Joiner; import org.jclouds.aws.domain.Region;
import com.google.common.collect.ImmutableSet;
/** /**
* Builds properties used in EC2 Clients * Builds properties used in EC2 Clients
@ -44,17 +34,9 @@ import com.google.common.collect.ImmutableSet;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder { public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder {
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1);
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG");
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA");
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE");
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG");
// sometimes, like in ec2, stop takes a very long time, perhaps // sometimes, like in ec2, stop takes a very long time, perhaps
// due to volume management. one example spent 2 minutes moving // due to volume management. one example spent 2 minutes moving
// from stopping->stopped state on an ec2 micro // from stopping->stopped state on an ec2 micro
@ -65,7 +47,7 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
properties.setProperty("jclouds.ssh.retryable_messages", properties.setProperty("jclouds.ssh.retryable_messages",
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established,connection is closed by foreign host,socket is not established"); "Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established,connection is closed by foreign host,socket is not established");
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); properties.putAll(Region.regionProperties());
// amazon, alestic, canonical, and rightscale // amazon, alestic, canonical, and rightscale
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
// amis that work with the cluster instances // amis that work with the cluster instances

View File

@ -209,7 +209,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override @Override
protected Set<String> getIso3166Codes() { protected Set<String> getIso3166Codes() {
return ImmutableSet.<String> of("US-VA", "US-CA", "IE", "SG"); return ImmutableSet.<String> of("US-VA", "US-CA", "IE", "SG", "JP-13");
} }
} }

View File

@ -17,7 +17,7 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.ec2.services; package org.jclouds.aws.ec2.services;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds; import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
@ -31,14 +31,13 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Image.ImageType;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.services.AMIClient;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
@ -49,7 +48,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.Module; import com.google.inject.Module;
@ -69,7 +67,7 @@ public class AMIClientLiveTest {
private Set<String> imagesToDeregister = Sets.newHashSet(); private Set<String> imagesToDeregister = Sets.newHashSet();
protected String provider = "ec2"; protected String provider = "aws-ec2";
protected String identity; protected String identity;
protected String credential; protected String credential;
protected String endpoint; protected String endpoint;
@ -110,14 +108,13 @@ public class AMIClientLiveTest {
assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0); assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0);
} }
@Test(expectedExceptions = AWSResponseException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testDescribeImageBadId() { public void testDescribeImageBadId() {
client.describeImagesInRegion(null, imageIds("asdaasdsa")); client.describeImagesInRegion(null, imageIds("asdaasdsa"));
} }
public void testDescribeImages() { public void testDescribeImages() {
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
Region.AP_SOUTHEAST_1)) {
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 2 : allResults.size(); assert allResults.size() >= 2 : allResults.size();

View File

@ -31,13 +31,12 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2AsyncClient;
import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.AWSEC2Client;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Image.ImageType;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
@ -49,7 +48,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.Module; import com.google.inject.Module;
@ -102,7 +100,7 @@ public class AWSAMIClientLiveTest {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
client = context.getApi().getAMIServices(); client = context.getApi().getAMIServices();
} }
@ -116,8 +114,7 @@ public class AWSAMIClientLiveTest {
} }
public void testDescribeImages() { public void testDescribeImages() {
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
Region.AP_SOUTHEAST_1)) {
Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); Set<Image> allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 2 : allResults.size(); assert allResults.size() >= 2 : allResults.size();
@ -138,7 +135,7 @@ public class AWSAMIClientLiveTest {
String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
imagesToDeregister.add(imageRegisteredId); imagesToDeregister.add(imageRegisteredId);
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null, Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null,
imageIds(imageRegisteredId))); imageIds(imageRegisteredId)));
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1"); assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE); assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
@ -149,10 +146,10 @@ public class AWSAMIClientLiveTest {
@Test(enabled = false) @Test(enabled = false)
public void testRegisterImageFromManifestOptions() { public void testRegisterImageFromManifestOptions() {
String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2", String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2",
DEFAULT_MANIFEST, withDescription("adrian")); DEFAULT_MANIFEST, withDescription("adrian"));
imagesToDeregister.add(imageRegisteredWithOptionsId); imagesToDeregister.add(imageRegisteredWithOptionsId);
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
imageIds(imageRegisteredWithOptionsId))); imageIds(imageRegisteredWithOptionsId)));
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE); assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
@ -167,7 +164,7 @@ public class AWSAMIClientLiveTest {
String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST);
imagesToDeregister.add(imageRegisteredId); imagesToDeregister.add(imageRegisteredId);
Image imageRegistered = Iterables Image imageRegistered = Iterables
.getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId))); .getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId)));
assertEquals(imageRegistered.getName(), "jcloudstest1"); assertEquals(imageRegistered.getName(), "jcloudstest1");
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE); assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS); assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
@ -178,18 +175,19 @@ public class AWSAMIClientLiveTest {
// awaiting EBS functionality to be added to jclouds // awaiting EBS functionality to be added to jclouds
public void testRegisterImageBackedByEBSOptions() { public void testRegisterImageBackedByEBSOptions() {
String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2", String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2",
DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
imagesToDeregister.add(imageRegisteredWithOptionsId); imagesToDeregister.add(imageRegisteredWithOptionsId);
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null,
imageIds(imageRegisteredWithOptionsId))); imageIds(imageRegisteredWithOptionsId)));
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE); assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS); assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1"); assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1");
assertEquals(imageRegisteredWithOptions.getDescription(), "adrian"); assertEquals(imageRegisteredWithOptions.getDescription(), "adrian");
assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of("/dev/sda1", assertEquals(
new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2", imageRegisteredWithOptions.getEbsBlockDevices().entrySet(),
new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet()); ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2",
new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet());
} }
@Test(enabled = false) @Test(enabled = false)

View File

@ -24,11 +24,9 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.options.AWSRunInstancesOptions; import org.jclouds.aws.ec2.options.AWSRunInstancesOptions;
import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler; import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler;
import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler; import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
@ -132,22 +130,22 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException { public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, Method method = AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass()); String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, Region.EU_WEST_1, AvailabilityZone.EU_WEST_1A, "ami-voo", HttpRequest request = processor.createRequest(method, "us-east-1", "us-east-1a", "ami-voo",
1, 5, new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring().withSecurityGroups( 1, 5, new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring().withSecurityGroups(
"group1", "group2")); "group1", "group2"));
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1"); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
try { try {
assertPayloadEquals( assertPayloadEquals(
request, request,
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a", "Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
} catch (AssertionError e) { } catch (AssertionError e) {
// mvn 3.0 osx 10.6.5 somehow sorts differently // mvn 3.0 osx 10.6.5 somehow sorts differently
assertPayloadEquals( assertPayloadEquals(
request, request,
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a", "Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
} }
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -26,7 +26,6 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2AsyncClient;
import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.AWSEC2Client;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
@ -39,7 +38,6 @@ import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -91,8 +89,7 @@ public class AWSInstanceClientLiveTest {
@Test @Test
void testDescribeInstances() { void testDescribeInstances() {
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
Region.AP_SOUTHEAST_1)) {
Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region); Set<? extends Reservation<? extends RunningInstance>> allResults = client.describeInstancesInRegion(region);
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 0 : allResults.size(); assert allResults.size() >= 0 : allResults.size();

View File

@ -11,7 +11,6 @@ import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.aws.ec2.config.AWSEC2RestClientModule;
import org.jclouds.aws.filters.FormSigner; import org.jclouds.aws.filters.FormSigner;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
@ -59,7 +58,7 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
static class Zones implements javax.inject.Provider<Map<String, String>> { static class Zones implements javax.inject.Provider<Map<String, String>> {
@Override @Override
public Map<String, String> get() { public Map<String, String> get() {
return ImmutableMap.<String, String> of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); return ImmutableMap.<String, String> of("us-east-1a", "us-east-1");
} }
} }
} }

View File

@ -112,14 +112,14 @@ public class PlacementGroupClientLiveTest {
public void setupClient() throws FileNotFoundException, IOException { public void setupClient() throws FileNotFoundException, IOException {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of( context = new ComputeServiceContextFactory().createContext(provider,
new Log4JLoggingModule(), new JschSshClientModule()), overrides); ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides);
keyPair = setupKeyPair(); keyPair = setupKeyPair();
client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());
availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1, availableTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupAvailable(client), 60, 1,
TimeUnit.SECONDS); TimeUnit.SECONDS);
deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS); deletedTester = new RetryablePredicate<PlacementGroup>(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS);
} }
@ -128,24 +128,25 @@ public class PlacementGroupClientLiveTest {
void testDescribe() { void testDescribe() {
for (String region : newArrayList(Region.US_EAST_1)) { for (String region : newArrayList(Region.US_EAST_1)) {
SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices() SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region)); .describePlacementGroupsInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
if (allResults.size() >= 1) { if (allResults.size() >= 1) {
PlacementGroup group = allResults.last(); PlacementGroup group = allResults.last();
SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices() SortedSet<PlacementGroup> result = newTreeSet(client.getPlacementGroupServices()
.describePlacementGroupsInRegion(region, group.getName())); .describePlacementGroupsInRegion(region, group.getName()));
assertNotNull(result); assertNotNull(result);
PlacementGroup compare = result.last(); PlacementGroup compare = result.last();
assertEquals(compare, group); assertEquals(compare, group);
} }
} }
for (String region : newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) { for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
try { if (!region.equals(Region.US_EAST_1))
client.getPlacementGroupServices().describePlacementGroupsInRegion(region); try {
assert false : "should be unsupported"; client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
} catch (UnsupportedOperationException e) { assert false : "should be unsupported";
} } catch (UnsupportedOperationException e) {
}
} }
} }
@ -161,7 +162,7 @@ public class PlacementGroupClientLiveTest {
private void verifyPlacementGroup(String groupName) { private void verifyPlacementGroup(String groupName) {
assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group; assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group;
Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null, Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null,
groupName); groupName);
assertNotNull(oneResult); assertNotNull(oneResult);
assertEquals(oneResult.size(), 1); assertEquals(oneResult.size(), 1);
group = oneResult.iterator().next(); group = oneResult.iterator().next();
@ -197,7 +198,7 @@ public class PlacementGroupClientLiveTest {
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17"); assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
.runScript(buildScript(template.getImage().getOperatingSystem())); .runScript(buildScript(template.getImage().getOperatingSystem()));
String group = PREFIX + "cccluster"; String group = PREFIX + "cccluster";
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
@ -209,7 +210,7 @@ public class PlacementGroupClientLiveTest {
NodeMetadata node = getOnlyElement(nodes); NodeMetadata node = getOnlyElement(nodes);
getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null,
node.getProviderId()))); node.getProviderId())));
} catch (RunNodesException e) { } catch (RunNodesException e) {
System.err.println(e.getNodeErrors().keySet()); System.err.println(e.getNodeErrors().keySet());

View File

@ -29,7 +29,6 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
@ -77,7 +76,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId( .instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId(
"aki-a71cf9ce").keyName("adriancole.ec21").launchTime( "aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState( dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState(
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1C) MonitoringState.DISABLED).availabilityZone("us-east-1c")
.virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal") .virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal")
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType( .privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType(
RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb")); RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb"));
@ -95,7 +94,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId( .instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId(
"aki-ba3adfd3").keyName("example-key-name").launchTime( "aki-ba3adfd3").keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState( dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) MonitoringState.DISABLED).availabilityZone("us-east-1b")
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode( .virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode(
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE) "774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
.build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default") .build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default")
@ -103,7 +102,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType( .instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType(
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name") InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState( .launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) MonitoringState.DISABLED).availabilityZone("us-east-1b")
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode( .virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode(
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE) "774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
.build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d")); .build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d"));
@ -123,7 +122,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId( .instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId(
"aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime( "aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime(
dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState( dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState(
MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) MonitoringState.DISABLED).availabilityZone("us-east-1b")
.placementGroup("placement").virtualizationType("hvm").privateDnsName( .placementGroup("placement").virtualizationType("hvm").privateDnsName(
"domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress( "domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress(
"10.210.209.157").ramdiskId("ari-a51cf9cc") "10.210.209.157").ramdiskId("ari-a51cf9cc")

View File

@ -29,7 +29,6 @@ import java.io.InputStream;
import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.AvailabilityZone;
import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.Reservation;
@ -86,19 +85,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
"ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType( "ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(), MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId( new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId(
"ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType( "ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(), MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId( new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId(
"ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType( "ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
InstanceType.M1_SMALL).keyName("example-key-name").launchTime( InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build()) MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
, "AIDADH4IGTRXXKCD", null, "r-47a5402e"); , "AIDADH4IGTRXXKCD", null, "r-47a5402e");

View File

@ -20,49 +20,36 @@
package org.jclouds.aws.s3; package org.jclouds.aws.s3;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
import static org.jclouds.aws.domain.Region.EU_WEST_1; import static org.jclouds.aws.domain.Region.US_STANDARD;
import static org.jclouds.aws.domain.Region.US_EAST_1;
import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.aws.domain.Region.US_WEST_1;
import static org.jclouds.location.reference.LocationConstants.ENDPOINT; import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
/** /**
* Builds properties used in S3 Clients * Builds properties used in S3 Clients
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder { public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder {
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG"); properties.putAll(Region.regionPropertiesS3());
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_STANDARD, Region.US_WEST_1, "EU",
Region.AP_SOUTHEAST_1));
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com"); properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ISO3166_CODES, "US"); properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ENDPOINT,
"https://s3-us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ISO3166_CODES, "IE"); properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ENDPOINT,
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ENDPOINT, "https://s3-ap-southeast-1.amazonaws.com");
"https://s3-ap-southeast-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT,
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG"); "https://s3-ap-northeast-1.amazonaws.com");
return properties; return properties;
} }

View File

@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest { public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest {
@Override @Override
protected Set<String> getIso3166Codes() { protected Set<String> getIso3166Codes() {
return ImmutableSet.<String> of("US", "US-CA", "IE", "SG"); return ImmutableSet.<String> of("US", "US-CA", "IE", "SG", "JP-13");
} }
} }

View File

@ -61,6 +61,12 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>

View File

@ -18,44 +18,43 @@
*/ */
package org.jclouds.cloudwatch; package org.jclouds.cloudwatch;
import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import org.jclouds.PropertiesBuilder; import org.jclouds.PropertiesBuilder;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import com.google.common.base.Joiner;
/** /**
* Builds properties used in Cloud Watch Clients * Builds properties used in Cloud Watch Clients
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudWatchPropertiesBuilder extends PropertiesBuilder { public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_HEADER_TAG, "amz");
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION); properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1, properties.putAll(Region.regionProperties());
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1)); properties.setProperty(PROPERTY_ENDPOINT, "https://monitoring.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT,
"https://monitoring.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
"https://monitoring.us-east-1.amazonaws.com"); "https://monitoring.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
"https://monitoring.us-west-1.amazonaws.com"); "https://monitoring.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
"https://monitoring.eu-west-1.amazonaws.com"); "https://monitoring.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
"https://monitoring.ap-southeast-1.amazonaws.com"); "https://monitoring.ap-southeast-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.AP_NORTHEAST_1 + ".endpoint",
"https://monitoring.ap-northeast-1.amazonaws.com");
return properties; return properties;
} }

View File

@ -35,7 +35,6 @@ import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -57,10 +56,9 @@ public class CloudWatchClientLiveTest {
protected void setupCredentials() { protected void setupCredentials() {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential"); + ".credential");
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); endpoint = System.getProperty("test." + provider + ".endpoint", null);
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider apiversion = System.getProperty("test." + provider + ".apiversion", null);
+ ".apiversion");
} }
protected Properties setupProperties() { protected Properties setupProperties() {
@ -69,8 +67,10 @@ public class CloudWatchClientLiveTest {
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
overrides.setProperty(provider + ".identity", identity); overrides.setProperty(provider + ".identity", identity);
overrides.setProperty(provider + ".credential", credential); overrides.setProperty(provider + ".credential", credential);
overrides.setProperty(provider + ".endpoint", endpoint); if (endpoint != null)
overrides.setProperty(provider + ".apiversion", apiversion); overrides.setProperty(provider + ".endpoint", endpoint);
if (apiversion != null)
overrides.setProperty(provider + ".apiversion", apiversion);
return overrides; return overrides;
} }
@ -79,7 +79,7 @@ public class CloudWatchClientLiveTest {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()), context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
overrides); overrides);
client = context.getApi(); client = context.getApi();
} }
@ -87,8 +87,7 @@ public class CloudWatchClientLiveTest {
void testGetMetricStatisticsInRegion() { void testGetMetricStatisticsInRegion() {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, -1); cal.add(Calendar.MINUTE, -1);
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, for (String region : Region.DEFAULT_REGIONS) {
Region.AP_SOUTHEAST_1)) {
assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null; assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null;
} }
} }

View File

@ -68,7 +68,7 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n"); assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
assertPayloadEquals( assertPayloadEquals(
request, request,
"Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.InstancePort=80&Listeners.member.1.LoadBalancerPort=80", "Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.LoadBalancerPort=80&Listeners.member.1.InstancePort=80",
"application/x-www-form-urlencoded", false); "application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -180,9 +180,19 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
protected String provider = "elb"; protected String provider = "elb";
@Override
protected Properties getProperties() {
Properties overrides = new Properties();
overrides.setProperty(provider + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com");
overrides.setProperty(provider + ".propertiesbuilder", ELBPropertiesBuilder.class.getName());
overrides.setProperty(provider + ".contextbuilder", ELBContextBuilder.class.getName());
return overrides;
}
@Override @Override
public RestContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties()); return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
new Properties());
} }
@Override @Override

View File

@ -1,41 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.elb;
import org.jclouds.rest.Providers;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "elb") : providers;
}
}

View File

@ -23,15 +23,10 @@ import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import org.jclouds.PropertiesBuilder; import org.jclouds.PropertiesBuilder;
import org.jclouds.aws.domain.Region;
import com.google.common.base.Joiner;
/** /**
* Builds properties used in SQS Clients * Builds properties used in SQS Clients
@ -45,17 +40,7 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_HEADER_TAG, "amz");
properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION); properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION);
properties.setProperty(PROPERTY_REGIONS,
Joiner.on(',').join(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
properties.setProperty(PROPERTY_ENDPOINT, "https://sqs.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_ENDPOINT, "https://sqs.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint",
"https://sqs.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint",
"https://sqs.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint",
"https://sqs.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint",
"https://sqs.ap-southeast-1.amazonaws.com");
return properties; return properties;
} }

View File

@ -19,8 +19,6 @@
package org.jclouds.sqs; package org.jclouds.sqs;
import static com.google.common.base.Predicates.equalTo;
import static com.google.common.base.Predicates.not;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
@ -31,7 +29,6 @@ import java.util.Properties;
import javax.inject.Named; import javax.inject.Named;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.filters.FormSigner; import org.jclouds.aws.filters.FormSigner;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -48,7 +45,6 @@ import org.jclouds.sqs.xml.RegexListQueuesResponseHandler;
import org.jclouds.sqs.xml.RegexQueueHandler; import org.jclouds.sqs.xml.RegexQueueHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -145,14 +141,6 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
checkFilters(request); checkFilters(request);
} }
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = SQSAsyncClient.class.getMethod("createQueueInRegion", String.class, String.class, Array
.newInstance(CreateQueueOptions.class, 0).getClass());
for (String region : Iterables.filter(Region.ALL_SQS, not(equalTo("us-standard")))) {
processor.createRequest(method, region, "queueName");
}
}
@Override @Override
protected void checkFilters(HttpRequest request) { protected void checkFilters(HttpRequest request) {
assertEquals(request.getFilters().size(), 1); assertEquals(request.getFilters().size(), 1);
@ -172,9 +160,19 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
protected String provider = "sqs"; protected String provider = "sqs";
@Override
protected Properties getProperties() {
Properties overrides = new Properties();
overrides.setProperty(provider + ".endpoint", "https://sqs.us-east-1.amazonaws.com");
overrides.setProperty(provider + ".propertiesbuilder", SQSPropertiesBuilder.class.getName());
overrides.setProperty(provider + ".contextbuilder", SQSContextBuilder.class.getName());
return overrides;
}
@Override @Override
public RestContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties()); return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
new Properties());
} }
} }

View File

@ -31,7 +31,6 @@ import java.util.SortedSet;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException; import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.domain.Region;
import org.jclouds.crypto.CryptoStreams; import org.jclouds.crypto.CryptoStreams;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
@ -42,7 +41,6 @@ import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.Module; import com.google.inject.Module;
@ -97,60 +95,61 @@ public class SQSClientLiveTest {
} }
@Test @Test
void testListQueuesInRegion() throws InterruptedException { protected void testListQueues() throws InterruptedException {
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, listQueuesInRegion(null);
Region.AP_SOUTHEAST_1)) { }
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
assertNotNull(allResults); protected void listQueuesInRegion(String region) throws InterruptedException {
if (allResults.size() >= 1) { SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
Queue queue = allResults.last(); assertNotNull(allResults);
assertQueueInList(region, queue); if (allResults.size() >= 1) {
} Queue queue = allResults.last();
assertQueueInList(region, queue);
} }
} }
public static final String PREFIX = System.getProperty("user.name") + "-sqs"; public static final String PREFIX = System.getProperty("user.name") + "-sqs";
@Test @Test
void testCreateQueue() throws InterruptedException { protected void testCreateQueue() throws InterruptedException {
String queueName = PREFIX + "1"; createQueueInRegion(null, PREFIX + "1");
}
for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, public String createQueueInRegion(final String region, String queueName) throws InterruptedException {
Region.AP_SOUTHEAST_1)) { try {
try { SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName)));
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName))); if (result.size() >= 1) {
if (result.size() >= 1) { client.deleteQueue(result.last());
client.deleteQueue(result.last()); queueName += 1;// cannot recreate a queue within 60 seconds
queueName += 1;// cannot recreate a queue within 60 seconds }
} } catch (Exception e) {
} catch (Exception e) {
}
Queue queue = null;
int tries = 0;
while (queue == null && tries < 5) {
try {
tries++;
queue = client.createQueueInRegion(region, queueName);
} catch (AWSResponseException e) {
queueName += "1";
if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO
// retry
// handler
continue;
throw e;
}
}
if (region != null)
assertEquals(queue.getRegion(), region);
assertEquals(queue.getName(), queueName);
assertQueueInList(region, queue);
queues.add(queue);
} }
Queue queue = null;
int tries = 0;
while (queue == null && tries < 5) {
try {
tries++;
queue = client.createQueueInRegion(region, queueName);
} catch (AWSResponseException e) {
queueName += "1";
if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO
// retry
// handler
continue;
throw e;
}
}
if (region != null)
assertEquals(queue.getRegion(), region);
assertEquals(queue.getName(), queueName);
assertQueueInList(region, queue);
queues.add(queue);
return queueName;
} }
@Test(dependsOnMethods = "testCreateQueue") @Test(dependsOnMethods = "testCreateQueue")
void testSendMessage() throws InterruptedException, IOException { protected void testSendMessage() throws InterruptedException, IOException {
String message = "hardyharhar"; String message = "hardyharhar";
byte[] md5 = CryptoStreams.md5(message.getBytes()); byte[] md5 = CryptoStreams.md5(message.getBytes());
for (Queue queue : queues) { for (Queue queue : queues) {

View File

@ -1,93 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.sqs.config;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Map;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.RestContextFactory;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
/**
* @author Adrian Cole
*/
@Test(groups = "unit")
public class SQSRestClientModuleTest {
Injector createInjector() {
return new RestContextFactory().createContextBuilder("sqs", "uid", "key",
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
}
@Test
void testServerErrorHandler() {
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
assertEquals(handler.getServerErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
}
@Test
void testRegions() {
Map<String, URI> regionMap = createInjector().getInstance(
new Key<Map<String, URI>>(org.jclouds.location.Region.class) {
});
assertEquals(regionMap, ImmutableMap.<String, URI> of(Region.US_EAST_1, URI
.create("https://sqs.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
.create("https://sqs.us-west-1.amazonaws.com"), Region.EU_WEST_1, URI
.create("https://sqs.eu-west-1.amazonaws.com"), Region.AP_SOUTHEAST_1, URI
.create("https://sqs.ap-southeast-1.amazonaws.com")));
}
@Test
void testClientErrorHandler() {
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
assertEquals(handler.getClientErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
}
@Test
void testClientRetryHandler() {
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
assertEquals(handler.getClientErrorRetryHandler().getClass(),
AWSClientErrorRetryHandler.class);
}
@Test
void testRedirectionRetryHandler() {
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
assertEquals(handler.getRedirectionRetryHandler().getClass(),
AWSRedirectionRetryHandler.class);
}
}

View File

@ -74,6 +74,12 @@
<type>test-jar</type> <type>test-jar</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-ec2</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.jclouds.driver</groupId> <groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-log4j</artifactId> <artifactId>jclouds-log4j</artifactId>

View File

@ -21,6 +21,7 @@ package org.jclouds.aws.elb;
import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
import static org.jclouds.aws.domain.Region.EU_WEST_1; import static org.jclouds.aws.domain.Region.EU_WEST_1;
import static org.jclouds.aws.domain.Region.US_EAST_1; import static org.jclouds.aws.domain.Region.US_EAST_1;
@ -28,41 +29,37 @@ import static org.jclouds.aws.domain.Region.US_WEST_1;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBAsyncClient;
import org.jclouds.elb.ELBPropertiesBuilder; import org.jclouds.elb.ELBPropertiesBuilder;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
/** /**
* Builds properties used in ELB Clients * Builds properties used in ELB Clients
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder { public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder {
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); properties.putAll(Region.regionProperties());
properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION); properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION);
properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint",
"https://elasticloadbalancing.us-east-1.amazonaws.com"); "https://elasticloadbalancing.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
"https://elasticloadbalancing.us-west-1.amazonaws.com"); "https://elasticloadbalancing.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint",
"https://elasticloadbalancing.eu-west-1.amazonaws.com"); "https://elasticloadbalancing.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint",
"https://elasticloadbalancing.ap-southeast-1.amazonaws.com"); "https://elasticloadbalancing.ap-southeast-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
"https://elasticloadbalancing.ap-northeast-1.amazonaws.com");
properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
return properties; return properties;
} }

View File

@ -19,6 +19,7 @@
package org.jclouds.aws.elb; package org.jclouds.aws.elb;
import org.jclouds.aws.domain.Region;
import org.jclouds.elb.ELBClientLiveTest; import org.jclouds.elb.ELBClientLiveTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -35,21 +36,21 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest {
@Test @Test
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
createLoadBalancerInRegionZone(region, region + "a", name); createLoadBalancerInRegionZone(region, region + "a", name);
} }
} }
@Test(dependsOnMethods = "testCreateLoadBalancer") @Test(dependsOnMethods = "testCreateLoadBalancer")
public void testDescribeLoadBalancers() { public void testDescribeLoadBalancers() {
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
describeLoadBalancerInRegion(region); describeLoadBalancerInRegion(region);
} }
} }
@Test @Test
public void testDeleteLoadBalancer() { public void testDeleteLoadBalancer() {
for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
deleteLoadBalancerInRegion(region); deleteLoadBalancerInRegion(region);
} }
} }

View File

@ -19,12 +19,13 @@
package org.jclouds.aws.elb; package org.jclouds.aws.elb;
import static org.jclouds.aws.elb.AWSELBPropertiesBuilder.DEFAULT_REGIONS;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Properties;
import org.jclouds.aws.domain.Region;
import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBAsyncClient;
import org.jclouds.rest.RestContextFactory;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -40,9 +41,14 @@ public class ELBAsyncClientTest extends org.jclouds.elb.ELBAsyncClientTest {
this.provider = "aws-elb"; this.provider = "aws-elb";
} }
@Override
protected Properties getProperties() {
return RestContextFactory.getPropertiesFromResource("/rest.properties");
}
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class); Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class);
for (String region : DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
processor.createRequest(method, region); processor.createRequest(method, region);
} }
} }

View File

@ -20,51 +20,49 @@
package org.jclouds.aws.simpledb; package org.jclouds.aws.simpledb;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
import static org.jclouds.aws.domain.Region.EU_WEST_1; import static org.jclouds.aws.domain.Region.EU_WEST_1;
import static org.jclouds.aws.domain.Region.US_EAST_1; import static org.jclouds.aws.domain.Region.US_EAST_1;
import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.aws.domain.Region.US_WEST_1;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
/** /**
* Builds properties used in SimpleDB Clients * Builds properties used in SimpleDB Clients
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class SimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder { public class AWSSimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder {
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); properties.putAll(Region.regionProperties());
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com"); properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
"https://sdb.us-west-1.amazonaws.com"); "https://sdb.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint",
"https://sdb.eu-west-1.amazonaws.com"); "https://sdb.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint",
"https://sdb.ap-southeast-1.amazonaws.com"); "https://sdb.ap-southeast-1.amazonaws.com");
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
"https://sdb.ap-northeast-1.amazonaws.com");
return properties; return properties;
} }
public SimpleDBPropertiesBuilder() { public AWSSimpleDBPropertiesBuilder() {
super(); super();
} }
public SimpleDBPropertiesBuilder(Properties properties) { public AWSSimpleDBPropertiesBuilder(Properties properties) {
super(properties); super(properties);
} }

View File

@ -19,12 +19,14 @@
package org.jclouds.aws.simpledb; package org.jclouds.aws.simpledb;
import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Properties;
import org.jclouds.aws.domain.Region;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.simpledb.SimpleDBAsyncClient; import org.jclouds.simpledb.SimpleDBAsyncClient;
import org.jclouds.simpledb.SimpleDBAsyncClientTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -34,17 +36,20 @@ import org.testng.annotations.Test;
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "aws.SimpleDBAsyncClientTest") @Test(groups = "unit", testName = "aws.SimpleDBAsyncClientTest")
public class SimpleDBAsyncClientTest extends org.jclouds.simpledb.SimpleDBAsyncClientTest { public class AWSSimpleDBAsyncClientTest extends SimpleDBAsyncClientTest {
public SimpleDBAsyncClientTest() { public AWSSimpleDBAsyncClientTest() {
this.provider = "aws-simpledb"; this.provider = "aws-simpledb";
} }
// TODO fix this test as it has the wrong arg count @Override
@Test(enabled = false) protected Properties getProperties() {
return RestContextFactory.getPropertiesFromResource("/rest.properties");
}
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class); Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class);
for (String region : DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
processor.createRequest(method, region, "domainName"); processor.createRequest(method, region, "domainName");
} }
} }

View File

@ -19,8 +19,7 @@
package org.jclouds.aws.simpledb; package org.jclouds.aws.simpledb;
import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS; import org.jclouds.aws.domain.Region;
import org.jclouds.simpledb.SimpleDBClientLiveTest; import org.jclouds.simpledb.SimpleDBClientLiveTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -36,7 +35,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
} }
@Test @Test
void testListDomainsInRegion() throws InterruptedException { void testListDomainsInRegion() throws InterruptedException {
for (String region : DEFAULT_REGIONS) { for (String region : Region.DEFAULT_REGIONS) {
listDomainInRegion(region); listDomainInRegion(region);
} }
} }
@ -44,8 +43,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest {
@Test @Test
void testCreateDomainInRegions() throws InterruptedException { void testCreateDomainInRegions() throws InterruptedException {
String domainName = PREFIX + "1"; String domainName = PREFIX + "1";
for (String region : Region.DEFAULT_REGIONS) {
for (String region : DEFAULT_REGIONS) {
domainName = createDomainInRegion(region, domainName); domainName = createDomainInRegion(region, domainName);
} }
} }