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;
|
||||
try {
|
||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
||||
cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);
|
||||
|
||||
// create a security group that allows ssh in so that our scripts later
|
||||
// will work
|
||||
|
@ -159,7 +159,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
assertEquals(keyPairClient.describeKeyPairsInRegion(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;
|
||||
}
|
||||
|
||||
protected void cleanupExtendedStuff(SecurityGroupClient securityGroupClient, KeyPairClient keyPairClient,
|
||||
String group) throws InterruptedException {
|
||||
protected void cleanupExtendedStuffInRegion(String region, SecurityGroupClient securityGroupClient,
|
||||
KeyPairClient keyPairClient, String group) throws InterruptedException {
|
||||
try {
|
||||
for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(null))
|
||||
for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(region))
|
||||
if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) {
|
||||
securityGroupClient.deleteSecurityGroupInRegion(null, secgroup.getName());
|
||||
securityGroupClient.deleteSecurityGroupInRegion(region, secgroup.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
try {
|
||||
for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(null))
|
||||
for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(region))
|
||||
if (pair.getKeyName().startsWith("jclouds#" + group) || pair.getKeyName().equals(group)) {
|
||||
keyPairClient.deleteKeyPairInRegion(null, pair.getKeyName());
|
||||
keyPairClient.deleteKeyPairInRegion(region, pair.getKeyName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
|
|
|
@ -45,8 +45,9 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
|||
// from stopping->stopped state on an ec2 micro
|
||||
properties.setProperty(PROPERTY_TIMEOUT_NODE_SUSPENDED, 120 * 1000 + "");
|
||||
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
||||
// authorized key executes after ssh has started
|
||||
properties.setProperty("jclouds.ssh.max-retries", "7");
|
||||
// authorized key executes after ssh has started. with amazon linux, ssh
|
||||
// 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(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.putAll(Region.regionProperties());
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.cloudwatch.CloudWatchAsyncClient;
|
|||
import org.jclouds.cloudwatch.CloudWatchClient;
|
||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.compute.predicates.NodePredicates;
|
||||
import org.jclouds.domain.Credentials;
|
||||
|
@ -77,6 +78,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
@Override
|
||||
@Test(dependsOnMethods = "testCompareSizes")
|
||||
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())
|
||||
.getSecurityGroupServices();
|
||||
|
||||
|
@ -100,19 +104,19 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
String startedId = null;
|
||||
try {
|
||||
cleanupExtendedStuff(securityGroupClient, keyPairClient, group);
|
||||
cleanupExtendedStuffInRegion(region, securityGroupClient, keyPairClient, group);
|
||||
|
||||
// create a security group that allows ssh in so that our scripts later
|
||||
// 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));
|
||||
|
||||
options.as(AWSEC2TemplateOptions.class).securityGroupIds(groupId);
|
||||
|
||||
// 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());
|
||||
|
||||
// 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
|
||||
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);
|
||||
|
||||
checkUserMetadataInNodeEquals(first, userMetadata);
|
||||
|
@ -166,10 +172,10 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
client.destroyNodesMatching(NodePredicates.inGroup(group));
|
||||
if (startedId != null) {
|
||||
// ensure we didn't delete these resources!
|
||||
assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1);
|
||||
assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1);
|
||||
assertEquals(keyPairClient.describeKeyPairsInRegion(region, 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();
|
||||
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().getFamily(), OsFamily.AMZN_LINUX);
|
||||
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)
|
||||
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
||||
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().getFamily(), OsFamily.AMZN_LINUX);
|
||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
|
@ -172,7 +172,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|||
.build();
|
||||
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
||||
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().getFamily(), OsFamily.AMZN_LINUX);
|
||||
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||
|
|
|
@ -65,7 +65,7 @@ import com.google.inject.Module;
|
|||
@Test(groups = "live", singleThreaded = true)
|
||||
public class SpotInstanceClientLiveTest {
|
||||
|
||||
private static final int SPOT_DELAY_SECONDS = 300;
|
||||
private static final int SPOT_DELAY_SECONDS = 600;
|
||||
private AWSEC2Client client;
|
||||
private ComputeServiceContext context;
|
||||
private RetryablePredicate<SpotInstanceRequest> activeTester;
|
||||
|
@ -132,7 +132,7 @@ public class SpotInstanceClientLiveTest {
|
|||
|
||||
@Test
|
||||
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()));
|
||||
assertNotNull(spots);
|
||||
assert spots.size() > 0;
|
||||
|
@ -153,19 +153,21 @@ public class SpotInstanceClientLiveTest {
|
|||
@Test(enabled = true)
|
||||
void testCreateSpotInstance() {
|
||||
String launchGroup = PREFIX + "1";
|
||||
for (SpotInstanceRequest request : client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
|
||||
"us-west-1"))
|
||||
if (launchGroup.equals(request.getLaunchGroup()))
|
||||
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion("us-west-1", request.getId());
|
||||
for (String region : Region.DEFAULT_REGIONS)
|
||||
for (SpotInstanceRequest request : client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
|
||||
region))
|
||||
if (launchGroup.equals(request.getLaunchGroup()))
|
||||
client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(region, request.getId());
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
requests = client.getSpotInstanceServices().requestSpotInstancesInRegion(
|
||||
"us-west-1",
|
||||
0.03f,
|
||||
"eu-west-1",
|
||||
0.09f,
|
||||
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(
|
||||
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))));
|
||||
assertNotNull(requests);
|
||||
|
||||
|
@ -181,13 +183,13 @@ public class SpotInstanceClientLiveTest {
|
|||
System.out.println(System.currentTimeMillis() - start);
|
||||
spot = refresh(request);
|
||||
assert spot.getInstanceId() != null : spot;
|
||||
instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion("us-west-1",
|
||||
instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(spot.getRegion(),
|
||||
spot.getInstanceId())));
|
||||
assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
|
||||
}
|
||||
|
||||
public SpotInstanceRequest refresh(SpotInstanceRequest request) {
|
||||
return getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion("us-west-1",
|
||||
return getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(request.getRegion(),
|
||||
request.getId()));
|
||||
}
|
||||
|
||||
|
@ -201,7 +203,7 @@ public class SpotInstanceClientLiveTest {
|
|||
// assert deletedTester.apply(request) : request;
|
||||
}
|
||||
if (instance != null) {
|
||||
client.getInstanceServices().terminateInstancesInRegion("us-west-1", instance.getId());
|
||||
client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId());
|
||||
}
|
||||
context.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue