added southeast asia to sqs and added better region tests

This commit is contained in:
Adrian Cole 2010-05-20 10:06:19 -07:00
parent 570e6366a6
commit d3690c44f2
14 changed files with 64 additions and 52 deletions

View File

@ -23,6 +23,7 @@ import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT; import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1; import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1; import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1;
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1; import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1;
@ -41,12 +42,15 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_SQS_ENDPOINT, "https://queue.amazonaws.com"); properties.setProperty(PROPERTY_SQS_ENDPOINT, "https://sqs.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://queue.amazonaws.com"); properties
properties.setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1, .setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://sqs.us-east-1.amazonaws.com");
"https://us-west-1.queue.amazonaws.com"); properties
properties.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1, .setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1, "https://sqs.us-west-1.amazonaws.com");
"https://eu-west-1.queue.amazonaws.com"); properties
.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1, "https://sqs.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1,
"https://sqs.ap-southeast-1.amazonaws.com");
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60"); properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
return properties; return properties;
} }

View File

@ -94,9 +94,11 @@ public class SQSRestClientModule extends AbstractModule {
Map<String, URI> provideRegions( Map<String, URI> provideRegions(
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast, @Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast,
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest, @Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest,
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1) String euwest) { @Named(SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1) String euwest,
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1) String apsoutheast) {
return ImmutableMap.<String, URI> of(Region.US_EAST_1, URI.create(useast), Region.US_WEST_1, return ImmutableMap.<String, URI> of(Region.US_EAST_1, URI.create(useast), Region.US_WEST_1,
URI.create(uswest), Region.EU_WEST_1, URI.create(euwest)); URI.create(uswest), Region.EU_WEST_1, URI.create(euwest), Region.AP_SOUTHEAST_1, URI
.create(apsoutheast));
} }
@Provides @Provides

View File

@ -31,4 +31,6 @@ public interface SQSConstants extends AWSConstants {
public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1"; public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1";
public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1"; public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1";
public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1"; public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1";
public static final String PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1 = "jclouds.sqs.endpoint.ap_southeast_1";
} }

View File

@ -43,10 +43,10 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.ImmutableMap; import com.google.inject.internal.ImmutableMap;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code AMIClient} * Tests behavior of {@code AMIClient}
@ -85,9 +85,9 @@ public class AMIClientLiveTest {
client.describeImagesInRegion(null, imageIds("asdaasdsa")); client.describeImagesInRegion(null, imageIds("asdaasdsa"));
} }
@Test(enabled = false)
public void testDescribeImages() { public void testDescribeImages() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1)) { for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImagesInRegion(region)); SortedSet<Image> allResults = Sets.newTreeSet(client.describeImagesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 2 : allResults.size(); assert allResults.size() >= 2 : allResults.size();

View File

@ -41,9 +41,9 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code AvailabilityZoneAndRegionClient} * Tests behavior of {@code AvailabilityZoneAndRegionClient}
@ -67,8 +67,8 @@ public class AvailabilityZoneAndRegionClientLiveTest {
} }
public void testDescribeAvailabilityZones() { public void testDescribeAvailabilityZones() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<AvailabilityZoneInfo> allResults = Sets.newTreeSet(client SortedSet<AvailabilityZoneInfo> allResults = Sets.newTreeSet(client
.describeAvailabilityZonesInRegion(region)); .describeAvailabilityZonesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);

View File

@ -44,9 +44,9 @@ import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code ElasticBlockStoreClient} * Tests behavior of {@code ElasticBlockStoreClient}
@ -72,8 +72,8 @@ public class ElasticBlockStoreClientLiveTest {
@Test @Test
void testDescribeVolumes() { void testDescribeVolumes() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, 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) {
@ -96,8 +96,8 @@ public class ElasticBlockStoreClientLiveTest {
this.volumeId = expected.getId(); this.volumeId = expected.getId();
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null, SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null, expected
expected.getId())); .getId()));
assertNotNull(result); assertNotNull(result);
assertEquals(result.size(), 1); assertEquals(result.size(), 1);
Volume volume = result.iterator().next(); Volume volume = result.iterator().next();
@ -171,8 +171,8 @@ public class ElasticBlockStoreClientLiveTest {
@Test @Test
void testDescribeSnapshots() { void testDescribeSnapshots() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
if (allResults.size() >= 1) { if (allResults.size() >= 1) {
@ -213,8 +213,7 @@ public class ElasticBlockStoreClientLiveTest {
@Test(dependsOnMethods = "testCreateSnapshotInRegion") @Test(dependsOnMethods = "testCreateSnapshotInRegion")
void testDeleteVolumeInRegion() { void testDeleteVolumeInRegion() {
client.deleteVolumeInRegion(null, volumeId); client.deleteVolumeInRegion(null, volumeId);
SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null, SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(null, volumeId));
volumeId));
assertEquals(result.size(), 1); assertEquals(result.size(), 1);
Volume volume = result.iterator().next(); Volume volume = result.iterator().next();
assertEquals(volume.getStatus(), Volume.Status.DELETING); assertEquals(volume.getStatus(), Volume.Status.DELETING);

View File

@ -35,8 +35,8 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code ElasticIPAddressClient} * Tests behavior of {@code ElasticIPAddressClient}
@ -61,8 +61,8 @@ public class ElasticIPAddressClientLiveTest {
@Test @Test
void testDescribeAddresses() { void testDescribeAddresses() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client SortedSet<PublicIpInstanceIdPair> allResults = Sets.newTreeSet(client
.describeAddressesInRegion(region)); .describeAddressesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);

View File

@ -37,7 +37,7 @@ import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; 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.inject.internal.Lists;
/** /**
* Tests behavior of {@code ElasticIPAddressClient} * Tests behavior of {@code ElasticIPAddressClient}
@ -77,8 +77,8 @@ public class ElasticLoadBalancerClientLiveTest {
@Test(dependsOnMethods = "testCreateLoadBalancer") @Test(dependsOnMethods = "testCreateLoadBalancer")
void testDescribeLoadBalancers() { void testDescribeLoadBalancers() {
String name = "TestDescribeLoadBalancer"; String name = "TestDescribeLoadBalancer";
for (String region : ImmutableSet.of(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.AP_SOUTHEAST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
Set<ElasticLoadBalancer> allResults = client.describeLoadBalancers(region, name); Set<ElasticLoadBalancer> allResults = client.describeLoadBalancers(region, name);
assertNotNull(allResults); assertNotNull(allResults);
assert (allResults.size() >= 1); assert (allResults.size() >= 1);
@ -87,8 +87,8 @@ public class ElasticLoadBalancerClientLiveTest {
@Test @Test
void testDeleteLoadBalancer() { void testDeleteLoadBalancer() {
for (String region : ImmutableSet.of(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.AP_SOUTHEAST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
client.deleteLoadBalancer(region, "TestLoadBalancer"); client.deleteLoadBalancer(region, "TestLoadBalancer");
} }
} }

View File

@ -34,7 +34,7 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code EC2Client} * Tests behavior of {@code EC2Client}
@ -61,8 +61,8 @@ public class InstanceClientLiveTest {
@Test @Test
void testDescribeInstances() { void testDescribeInstances() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
Set<Reservation> allResults = client.describeInstancesInRegion(region); Set<Reservation> allResults = client.describeInstancesInRegion(region);
assertNotNull(allResults); assertNotNull(allResults);
assert allResults.size() >= 0 : allResults.size(); assert allResults.size() >= 0 : allResults.size();

View File

@ -35,8 +35,8 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code KeyPairClient} * Tests behavior of {@code KeyPairClient}
@ -61,8 +61,8 @@ public class KeyPairClientLiveTest {
@Test @Test
void testDescribeKeyPairs() { void testDescribeKeyPairs() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region)); SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
@ -95,8 +95,8 @@ public class KeyPairClientLiveTest {
assertNotNull(result.getKeyFingerprint()); assertNotNull(result.getKeyFingerprint());
assertEquals(result.getKeyName(), keyName); assertEquals(result.getKeyName(), keyName);
SortedSet<KeyPair> twoResults = Sets.newTreeSet(client.describeKeyPairsInRegion( SortedSet<KeyPair> twoResults = Sets.newTreeSet(client
null, keyName)); .describeKeyPairsInRegion(null, keyName));
assertNotNull(twoResults); assertNotNull(twoResults);
assertEquals(twoResults.size(), 1); assertEquals(twoResults.size(), 1);
KeyPair listPair = twoResults.iterator().next(); KeyPair listPair = twoResults.iterator().next();

View File

@ -42,9 +42,9 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code SecurityGroupClient} * Tests behavior of {@code SecurityGroupClient}
@ -69,7 +69,8 @@ public class SecurityGroupClientLiveTest {
@Test @Test
void testDescribe() { void testDescribe() {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1)) { for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<SecurityGroup> allResults = Sets.newTreeSet(client SortedSet<SecurityGroup> allResults = Sets.newTreeSet(client
.describeSecurityGroupsInRegion(region)); .describeSecurityGroupsInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);

View File

@ -37,8 +37,8 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; 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.Sets; import com.google.common.collect.Sets;
import com.google.inject.internal.Lists;
/** /**
* Tests behavior of {@code SQSClient} * Tests behavior of {@code SQSClient}
@ -66,7 +66,8 @@ public class SQSClientLiveTest {
@Test @Test
void testListQueuesInRegion() throws InterruptedException { void testListQueuesInRegion() throws InterruptedException {
for (String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1)) { for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region)); SortedSet<Queue> allResults = Sets.newTreeSet(client.listQueuesInRegion(region));
assertNotNull(allResults); assertNotNull(allResults);
if (allResults.size() >= 1) { if (allResults.size() >= 1) {
@ -82,8 +83,8 @@ public class SQSClientLiveTest {
void testCreateQueue() throws InterruptedException { void testCreateQueue() throws InterruptedException {
String queueName = PREFIX + "1"; String queueName = PREFIX + "1";
for (final String region : ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1, for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
Region.US_WEST_1)) { Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
try { try {
SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region, SortedSet<Queue> result = Sets.newTreeSet(client.listQueuesInRegion(region,
queuePrefix(queueName))); queuePrefix(queueName)));
@ -109,6 +110,7 @@ public class SQSClientLiveTest {
throw e; throw e;
} }
} }
if (region != null)
assertEquals(queue.getRegion(), region); assertEquals(queue.getRegion(), region);
assertEquals(queue.getName(), queueName); assertEquals(queue.getName(), queueName);
assertQueueInList(region, queue); assertQueueInList(region, queue);

View File

@ -75,12 +75,14 @@ public class SQSRestClientModuleTest {
@Test @Test
void testRegions() { void testRegions() {
Map<String, URI> regionMap = createInjector().getInstance(new Key<Map<String, URI>>(SQS.class) { Map<String, URI> regionMap = createInjector().getInstance(
new Key<Map<String, URI>>(SQS.class) {
}); });
assertEquals(regionMap, ImmutableMap.<String, URI> of(Region.US_EAST_1, URI assertEquals(regionMap, ImmutableMap.<String, URI> of(Region.US_EAST_1, URI
.create("https://queue.amazonaws.com"), Region.US_WEST_1, URI .create("https://sqs.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
.create("https://us-west-1.queue.amazonaws.com"), Region.EU_WEST_1, URI .create("https://sqs.us-west-1.amazonaws.com"), Region.EU_WEST_1, URI
.create("https://eu-west-1.queue.amazonaws.com"))); .create("https://sqs.eu-west-1.amazonaws.com"), Region.AP_SOUTHEAST_1, URI
.create("https://sqs.ap-southeast-1.amazonaws.com")));
} }
@Test @Test