mirror of https://github.com/apache/jclouds.git
spot requests are not opening in us-east-1 or us-west-1: switching to eu-west-1
This commit is contained in:
parent
0dbf453dd0
commit
326328b71b
|
@ -110,7 +110,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
String startedId = null;
|
String startedId = null;
|
||||||
try {
|
try {
|
||||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);
|
||||||
|
|
||||||
// create a security group that allows ssh in so that our scripts later
|
// create a security group that allows ssh in so that our scripts later
|
||||||
// will work
|
// will work
|
||||||
|
@ -159,7 +159,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1);
|
assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1);
|
||||||
assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1);
|
assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1);
|
||||||
}
|
}
|
||||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,20 +242,20 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient,
|
protected void cleanupExtendedStuffInRegion(String region, SecurityGroupClient securityGroupClient,
|
||||||
String group) throws InterruptedException {
|
KeyPairClient keyPairClient, String group) throws InterruptedException {
|
||||||
try {
|
try {
|
||||||
for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(null))
|
for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(region))
|
||||||
if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) {
|
if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) {
|
||||||
securityGroupClient.deleteSecurityGroupInRegion(null, secgroup.getName());
|
securityGroupClient.deleteSecurityGroupInRegion(region, secgroup.getName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(null))
|
for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(region))
|
||||||
if (pair.getKeyName().startsWith("jclouds#" + group) || pair.getKeyName().equals(group)) {
|
if (pair.getKeyName().startsWith("jclouds#" + group) || pair.getKeyName().equals(group)) {
|
||||||
keyPairClient.deleteKeyPairInRegion(null, pair.getKeyName());
|
keyPairClient.deleteKeyPairInRegion(region, pair.getKeyName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,9 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
||||||
// from stopping->stopped state on an ec2 micro
|
// from stopping->stopped state on an ec2 micro
|
||||||
properties.setProperty(PROPERTY_TIMEOUT_NODE_SUSPENDED, 120 * 1000 + "");
|
properties.setProperty(PROPERTY_TIMEOUT_NODE_SUSPENDED, 120 * 1000 + "");
|
||||||
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
||||||
// authorized key executes after ssh has started
|
// authorized key executes after ssh has started. with amazon linux, ssh
|
||||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
// starts after package updates, which means that this value can be higher.
|
||||||
|
properties.setProperty("jclouds.ssh.max-retries", "10");
|
||||||
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
properties.setProperty("jclouds.ssh.retry-auth", "true");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||||
properties.putAll(Region.regionProperties());
|
properties.putAll(Region.regionProperties());
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.cloudwatch.CloudWatchAsyncClient;
|
||||||
import org.jclouds.cloudwatch.CloudWatchClient;
|
import org.jclouds.cloudwatch.CloudWatchClient;
|
||||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.predicates.NodePredicates;
|
import org.jclouds.compute.predicates.NodePredicates;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -77,6 +78,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
@Override
|
@Override
|
||||||
@Test(dependsOnMethods = "testCompareSizes")
|
@Test(dependsOnMethods = "testCompareSizes")
|
||||||
public void testExtendedOptionsAndLogin() throws Exception {
|
public void testExtendedOptionsAndLogin() throws Exception {
|
||||||
|
//note that this is sensitive to regions that quickly fill spot requests
|
||||||
|
String region = "eu-west-1";
|
||||||
|
|
||||||
AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi())
|
AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi())
|
||||||
.getSecurityGroupServices();
|
.getSecurityGroupServices();
|
||||||
|
|
||||||
|
@ -100,19 +104,19 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
|
|
||||||
String startedId = null;
|
String startedId = null;
|
||||||
try {
|
try {
|
||||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
cleanupExtendedStuffInRegion(region, securityGroupClient, keyPairClient, group);
|
||||||
|
|
||||||
// create a security group that allows ssh in so that our scripts later
|
// create a security group that allows ssh in so that our scripts later
|
||||||
// will work
|
// will work
|
||||||
String groupId = securityGroupClient.createSecurityGroupInRegionAndReturnId(null, group, group);
|
String groupId = securityGroupClient.createSecurityGroupInRegionAndReturnId(region, group, group);
|
||||||
|
|
||||||
securityGroupClient.authorizeSecurityGroupIngressInRegion(null, groupId,
|
securityGroupClient.authorizeSecurityGroupIngressInRegion(region, groupId,
|
||||||
IpPermissions.permit(IpProtocol.TCP).port(22));
|
IpPermissions.permit(IpProtocol.TCP).port(22));
|
||||||
|
|
||||||
options.as(AWSEC2TemplateOptions.class).securityGroupIds(groupId);
|
options.as(AWSEC2TemplateOptions.class).securityGroupIds(groupId);
|
||||||
|
|
||||||
// create a keypair to pass in as well
|
// create a keypair to pass in as well
|
||||||
KeyPair result = keyPairClient.createKeyPairInRegion(null, group);
|
KeyPair result = keyPairClient.createKeyPairInRegion(region, group);
|
||||||
options.as(AWSEC2TemplateOptions.class).keyPair(result.getKeyName());
|
options.as(AWSEC2TemplateOptions.class).keyPair(result.getKeyName());
|
||||||
|
|
||||||
// pass in the private key, so that we can run a script with it
|
// pass in the private key, so that we can run a script with it
|
||||||
|
@ -122,7 +126,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
// an arbitrary command to run
|
// an arbitrary command to run
|
||||||
options.runScript(Statements.exec("find /usr"));
|
options.runScript(Statements.exec("find /usr"));
|
||||||
|
|
||||||
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
|
Template template = client.templateBuilder().locationId(region).options(options).build();
|
||||||
|
|
||||||
|
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
|
||||||
NodeMetadata first = Iterables.get(nodes, 0);
|
NodeMetadata first = Iterables.get(nodes, 0);
|
||||||
|
|
||||||
checkUserMetadataInNodeEquals(first, userMetadata);
|
checkUserMetadataInNodeEquals(first, userMetadata);
|
||||||
|
@ -166,10 +172,10 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
client.destroyNodesMatching(NodePredicates.inGroup(group));
|
client.destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
if (startedId != null) {
|
if (startedId != null) {
|
||||||
// ensure we didn't delete these resources!
|
// ensure we didn't delete these resources!
|
||||||
assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1);
|
assertEquals(keyPairClient.describeKeyPairsInRegion(region, group).size(), 1);
|
||||||
assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1);
|
assertEquals(securityGroupClient.describeSecurityGroupsInRegion(region, group).size(), 1);
|
||||||
}
|
}
|
||||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
cleanupExtendedStuffInRegion(region, securityGroupClient, keyPairClient, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
Template defaultTemplate = context.getComputeService().templateBuilder().build();
|
Template defaultTemplate = context.getComputeService().templateBuilder().build();
|
||||||
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.rc-1");
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.1");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||||
|
@ -157,7 +157,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
Template defaultTemplate = context.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX)
|
Template defaultTemplate = context.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX)
|
||||||
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
||||||
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.rc-1");
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.1");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||||
|
@ -172,7 +172,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
.build();
|
.build();
|
||||||
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
||||||
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE);
|
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE);
|
||||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.rc-1");
|
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.1");
|
||||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
|
||||||
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||||
|
|
|
@ -65,7 +65,7 @@ import com.google.inject.Module;
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true)
|
||||||
public class SpotInstanceClientLiveTest {
|
public class SpotInstanceClientLiveTest {
|
||||||
|
|
||||||
private static final int SPOT_DELAY_SECONDS = 300;
|
private static final int SPOT_DELAY_SECONDS = 600;
|
||||||
private AWSEC2Client client;
|
private AWSEC2Client client;
|
||||||
private ComputeServiceContext context;
|
private ComputeServiceContext context;
|
||||||
private RetryablePredicate<SpotInstanceRequest> activeTester;
|
private RetryablePredicate<SpotInstanceRequest> activeTester;
|
||||||
|
@ -132,7 +132,7 @@ public class SpotInstanceClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeSpotPriceHistoryInRegion() {
|
void testDescribeSpotPriceHistoryInRegion() {
|
||||||
for (final String region : Region.DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
Set<Spot> spots = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(region, from(new Date()));
|
Set<Spot> spots = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(region, from(new Date()));
|
||||||
assertNotNull(spots);
|
assertNotNull(spots);
|
||||||
assert spots.size() > 0;
|
assert spots.size() > 0;
|
||||||
|
@ -153,19 +153,21 @@ public class SpotInstanceClientLiveTest {
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
void testCreateSpotInstance() {
|
void testCreateSpotInstance() {
|
||||||
String launchGroup = PREFIX + "1";
|
String launchGroup = PREFIX + "1";
|
||||||
|
for (String region : Region.DEFAULT_REGIONS)
|
||||||
for (SpotInstanceRequest request : client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
|
for (SpotInstanceRequest request : client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
|
||||||
"us-west-1"))
|
region))
|
||||||
if (launchGroup.equals(request.getLaunchGroup()))
|
if (launchGroup.equals(request.getLaunchGroup()))
|
||||||
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion("us-west-1", request.getId());
|
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(region, request.getId());
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
|
|
||||||
requests = client.getSpotInstanceServices().requestSpotInstancesInRegion(
|
requests = client.getSpotInstanceServices().requestSpotInstancesInRegion(
|
||||||
"us-west-1",
|
"eu-west-1",
|
||||||
0.03f,
|
0.09f,
|
||||||
1,
|
1,
|
||||||
LaunchSpecification.builder().imageId("ami-595a0a1c").instanceType(InstanceType.T1_MICRO).build(),
|
LaunchSpecification.builder().imageId("ami-24506250").instanceType(InstanceType.M1_SMALL).build(),
|
||||||
launchGroup(launchGroup).availabilityZoneGroup(launchGroup).validFrom(
|
launchGroup(launchGroup).availabilityZoneGroup(launchGroup).validFrom(
|
||||||
new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(1))).validUntil(
|
new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(2))).validUntil(
|
||||||
new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(SPOT_DELAY_SECONDS))));
|
new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(SPOT_DELAY_SECONDS))));
|
||||||
assertNotNull(requests);
|
assertNotNull(requests);
|
||||||
|
|
||||||
|
@ -181,13 +183,13 @@ public class SpotInstanceClientLiveTest {
|
||||||
System.out.println(System.currentTimeMillis() - start);
|
System.out.println(System.currentTimeMillis() - start);
|
||||||
spot = refresh(request);
|
spot = refresh(request);
|
||||||
assert spot.getInstanceId() != null : spot;
|
assert spot.getInstanceId() != null : spot;
|
||||||
instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion("us-west-1",
|
instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(spot.getRegion(),
|
||||||
spot.getInstanceId())));
|
spot.getInstanceId())));
|
||||||
assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
|
assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpotInstanceRequest refresh(SpotInstanceRequest request) {
|
public SpotInstanceRequest refresh(SpotInstanceRequest request) {
|
||||||
return getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion("us-west-1",
|
return getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(request.getRegion(),
|
||||||
request.getId()));
|
request.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ public class SpotInstanceClientLiveTest {
|
||||||
// assert deletedTester.apply(request) : request;
|
// assert deletedTester.apply(request) : request;
|
||||||
}
|
}
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
client.getInstanceServices().terminateInstancesInRegion("us-west-1", instance.getId());
|
client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId());
|
||||||
}
|
}
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue