mirror of https://github.com/apache/jclouds.git
added support for m2.xlarge instance type in ec2. added tests in EC2ComputeServiceTest
This commit is contained in:
parent
e6b5978616
commit
c0b5d832b5
|
@ -90,7 +90,7 @@ import com.google.common.collect.Sets;
|
|||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the {@link EC2ComputeServiceContext}; requires {@link EC2ComputeService} bound.
|
||||
* Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -246,8 +246,8 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
@Singleton
|
||||
Map<String, ? extends Size> provideSizes(Function<ComputeMetadata, String> indexer) {
|
||||
return Maps.uniqueIndex(ImmutableSet.of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE,
|
||||
EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE, EC2Size.M2_2XLARGE,
|
||||
EC2Size.M2_4XLARGE), indexer);
|
||||
EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE, EC2Size.M2_XLARGE,
|
||||
EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE), indexer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -68,6 +68,11 @@ public class EC2Size extends SizeImpl {
|
|||
*/
|
||||
public static final EC2Size M1_XLARGE = new EC2Size(InstanceType.M1_XLARGE, 8, 15360, 1690,
|
||||
ImmutableSet.of(Architecture.X86_64));
|
||||
/**
|
||||
* @see InstanceType#M2_XLARGE
|
||||
*/
|
||||
public static final EC2Size M2_XLARGE = new EC2Size(InstanceType.M2_XLARGE, 6 /*TODO: 6.5*/, 17510, 420,
|
||||
ImmutableSet.of(Architecture.X86_64));
|
||||
/**
|
||||
* @see InstanceType#M2_2XLARGE
|
||||
*/
|
||||
|
|
|
@ -66,6 +66,17 @@ public enum InstanceType {
|
|||
* </ul>
|
||||
*/
|
||||
M1_XLARGE,
|
||||
/**
|
||||
* High-Memory Extra Large Instance
|
||||
* <ul>
|
||||
* <li>17.1 GB of memory</li>
|
||||
* <li>6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units each)</li>
|
||||
* <li>420 GB of instance storage</li>
|
||||
* <li>64-bit platform</li>
|
||||
* <li>I/O Performance: Moderate</li>
|
||||
* </ul>
|
||||
*/
|
||||
M2_XLARGE,
|
||||
/**
|
||||
* High-Memory Double Extra Large Instance
|
||||
* <ul>
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.aws.ec2.compute;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jclouds.aws.ec2.compute.domain.EC2Size;
|
||||
import org.jclouds.compute.domain.*;
|
||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
/**
|
||||
* Tests compute service specifically to EC2.
|
||||
*
|
||||
* These tests are designed to verify the local
|
||||
* functionality of jclouds, rather than the interaction
|
||||
* with Amazon Web Services.
|
||||
*
|
||||
* @see EC2ComputeServiceLiveTest
|
||||
*
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
public class EC2ComputeServiceTest {
|
||||
|
||||
/**
|
||||
* Verifies that {@link TemplateBuilderImpl} would
|
||||
* choose the correct size of the instance, based on
|
||||
* {@link org.jclouds.compute.domain.Size} from {@link EC2Size}.
|
||||
*
|
||||
* Expected size: m2.xlarge
|
||||
*
|
||||
* @throws Exception if non-test-related exception arises
|
||||
*/
|
||||
@Test
|
||||
public void testTemplateChoiceForInstanceBySizeId() throws Exception {
|
||||
|
||||
//create an instance of TemplateBuilderImpl
|
||||
Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null, true);
|
||||
Image image = new ImageImpl("ami-image", "image", "us-east-1", new URI("http"),
|
||||
Maps.<String,String>newHashMap(), "description", "1.0",
|
||||
null, "ubuntu", Architecture.X86_64);
|
||||
|
||||
TemplateBuilderImpl templateBuilder =
|
||||
new TemplateBuilderImpl(ImmutableMap.of("us-east-1", location),
|
||||
ImmutableMap.of("ami-image", image),
|
||||
ImmutableMap.of("m2.xlarge", EC2Size.M2_XLARGE,
|
||||
"m2.2xlarge", EC2Size.M2_2XLARGE,
|
||||
"m2.4xlarge", EC2Size.M2_4XLARGE),
|
||||
location);
|
||||
|
||||
//find the matching template
|
||||
Template template = templateBuilder.
|
||||
architecture(Architecture.X86_64).sizeId("m2.xlarge").
|
||||
locationId("us-east-1").
|
||||
build();
|
||||
|
||||
//assert the template is correct
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assert EC2Size.M2_XLARGE.equals(template.getSize()) :
|
||||
format("Incorrect image determined by the template. Expected: %s. Found: %s.",
|
||||
"m2.xlarge", String.valueOf(template.getSize()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies that {@link TemplateBuilderImpl} would
|
||||
* choose the correct size of the instance, based on
|
||||
* physical attributes (# of cores, ram, etc).
|
||||
* Expected size: m2.xlarge
|
||||
*
|
||||
* @throws Exception if non-test-related exception arises
|
||||
*/
|
||||
@Test
|
||||
public void testTemplateChoiceForInstanceByAttributes() throws Exception {
|
||||
|
||||
//create an instance of TemplateBuilderImpl
|
||||
Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null, true);
|
||||
Image image = new ImageImpl("ami-image", "image", "us-east-1", new URI("http"),
|
||||
Maps.<String,String>newHashMap(), "description", "1.0",
|
||||
null, "ubuntu", Architecture.X86_64);
|
||||
|
||||
TemplateBuilderImpl templateBuilder =
|
||||
new TemplateBuilderImpl(ImmutableMap.of("us-east-1", location),
|
||||
ImmutableMap.of("ami-image", image),
|
||||
Maps.uniqueIndex(ImmutableSet.of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE,
|
||||
EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE, EC2Size.M2_XLARGE,
|
||||
EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE), indexer()),
|
||||
location);
|
||||
|
||||
//find the matching template
|
||||
Template template = templateBuilder.
|
||||
architecture(Architecture.X86_64).
|
||||
minRam(17510).minCores(6).smallest().
|
||||
locationId("us-east-1").
|
||||
build();
|
||||
|
||||
//assert the template is correct
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assert EC2Size.M2_XLARGE.equals(template.getSize()) :
|
||||
format("Incorrect image determined by the template. Expected: %s. Found: %s.",
|
||||
"m2.xlarge", String.valueOf(template.getSize()));
|
||||
}
|
||||
|
||||
|
||||
Function<ComputeMetadata, String> indexer() {
|
||||
return new Function<ComputeMetadata, String>() {
|
||||
@Override
|
||||
public String apply(ComputeMetadata from) {
|
||||
return from.getId();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue