mirror of https://github.com/apache/jclouds.git
added test to aws for unknown instance type
This commit is contained in:
parent
e94ee94cd4
commit
2b918d5827
|
@ -83,7 +83,7 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
DateService dateService = new SimpleDateFormatDateService();
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyWithEBSWhenBootIsInstanceStoreAndAvailabilityZoneNotFound() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
|
@ -129,9 +129,12 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
expect(instance.getInstanceType()).andReturn(InstanceType.M1_SMALL).atLeastOnce();
|
||||
expect(instance.getEbsBlockDevices()).andReturn(
|
||||
ImmutableMap.<String, EbsBlockDevice> of("/dev/sdg", new EbsBlockDevice("vol-1f20d376",
|
||||
Attachment.Status.ATTACHED, dateService.iso8601DateParse("2009-12-11T16:32:46.000Z"), false),
|
||||
"/dev/sdj", new EbsBlockDevice("vol-c0eb78aa", Attachment.Status.ATTACHED, dateService
|
||||
ImmutableMap.<String, EbsBlockDevice> of(
|
||||
"/dev/sdg",
|
||||
new EbsBlockDevice("vol-1f20d376", Attachment.Status.ATTACHED, dateService
|
||||
.iso8601DateParse("2009-12-11T16:32:46.000Z"), false),
|
||||
"/dev/sdj",
|
||||
new EbsBlockDevice("vol-c0eb78aa", Attachment.Status.ATTACHED, dateService
|
||||
.iso8601DateParse("2010-06-17T10:43:28.000Z"), false)));
|
||||
expect(instance.getRootDeviceType()).andReturn(RootDeviceType.INSTANCE_STORE);
|
||||
expect(instance.getRootDeviceName()).andReturn(null).atLeastOnce();
|
||||
|
@ -157,8 +160,8 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
assertEquals(metadata.getHardware().getProviderId(), "m1.small");
|
||||
assertEquals(metadata.getHardware().getProcessors(), ImmutableList.<Processor> of(new Processor(1.0, 1.0)));
|
||||
assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
assertEquals(metadata.getHardware().getVolumes(), ImmutableList.<Volume> of(new VolumeImpl(null,
|
||||
Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
assertEquals(metadata.getHardware().getVolumes(),
|
||||
ImmutableList.<Volume> of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false),//
|
||||
new VolumeImpl("vol-1f20d376", Volume.Type.SAN, null, "/dev/sdg", false, true),//
|
||||
new VolumeImpl("vol-c0eb78aa", Volume.Type.SAN, null, "/dev/sdj", false, true)));
|
||||
|
@ -175,9 +178,9 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyForEucalyptusWhereNullAvailabilityZoneIpAddressNoGroups() throws UnknownHostException {
|
||||
public void testApplyForNovaWhereNullAvailabilityZoneIpAddressNoGroups() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
AMIClient amiClient = createMock(AMIClient.class);
|
||||
expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce();
|
||||
|
@ -243,8 +246,8 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
assertEquals(metadata.getHardware().getProviderId(), "m1.small");
|
||||
assertEquals(metadata.getHardware().getProcessors(), ImmutableList.<Processor> of(new Processor(1.0, 1.0)));
|
||||
assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
assertEquals(metadata.getHardware().getVolumes(), ImmutableList.<Volume> of(new VolumeImpl(null,
|
||||
Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
assertEquals(metadata.getHardware().getVolumes(),
|
||||
ImmutableList.<Volume> of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false)));
|
||||
|
||||
assertEquals(metadata.getCredentials(), new Credentials("user", null));
|
||||
|
@ -259,10 +262,84 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyForEucalyptusWhereImageNotFound() throws UnknownHostException {
|
||||
public void testApplyWhereUnknownInstanceType() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
AMIClient amiClient = createMock(AMIClient.class);
|
||||
expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce();
|
||||
Map<RegionAndName, KeyPair> credentialsMap = createMock(Map.class);
|
||||
ConcurrentMap<RegionAndName, org.jclouds.compute.domain.Image> imageMap = createMock(ConcurrentMap.class);
|
||||
Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
.<Hardware> of(EC2Hardware.M1_SMALL));
|
||||
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class);
|
||||
RunningInstance instance = createMock(RunningInstance.class);
|
||||
Image image = createMock(Image.class);
|
||||
|
||||
expect(instance.getId()).andReturn("i-3d640055").atLeastOnce();
|
||||
expect(instance.getGroupIds()).andReturn(ImmutableSet.<String> of()).atLeastOnce();
|
||||
expect(instance.getKeyName()).andReturn("nebulatanimislam").atLeastOnce();
|
||||
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
||||
|
||||
Location region = new LocationImpl(LocationScope.REGION, "us-east-1", "description", null);
|
||||
Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
.<Location> of(region));
|
||||
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||
|
||||
expect(instance.getIpAddress()).andReturn(null);
|
||||
expect(instance.getPrivateIpAddress()).andReturn("10.202.117.241");
|
||||
|
||||
expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce();
|
||||
|
||||
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
|
||||
|
||||
expect(instance.getImageId()).andReturn("ami-1515f07c").atLeastOnce();
|
||||
expect(imageMap.get(new RegionAndName(Region.US_EAST_1, "ami-1515f07c"))).andReturn(jcImage);
|
||||
|
||||
expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("ami-1515f07c"))).andReturn(
|
||||
(Set) ImmutableSet.<Image> of(image));
|
||||
|
||||
expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass"));
|
||||
|
||||
expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "nebulatanimislam"))).andReturn(null);
|
||||
|
||||
expect(instance.getAvailabilityZone()).andReturn(null).atLeastOnce();
|
||||
|
||||
expect(instance.getInstanceType()).andReturn("hhttpp").atLeastOnce();
|
||||
|
||||
replay(imageMap);
|
||||
replay(client);
|
||||
replay(amiClient);
|
||||
replay(credentialsMap);
|
||||
replay(credentialProvider);
|
||||
replay(instance);
|
||||
replay(jcImage);
|
||||
|
||||
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(client, credentialsMap,
|
||||
credentialProvider, imageMap, locations, hardwares);
|
||||
|
||||
NodeMetadata metadata = parser.apply(instance);
|
||||
|
||||
assertEquals(metadata.getTag(), "NOTAG-i-3d640055");
|
||||
assertEquals(metadata.getLocation(), region);
|
||||
assertEquals(metadata.getImageId(), "us-east-1/ami-1515f07c");
|
||||
assertEquals(metadata.getHardware(), null);
|
||||
|
||||
assertEquals(metadata.getCredentials(), new Credentials("user", null));
|
||||
|
||||
verify(imageMap);
|
||||
verify(jcImage);
|
||||
verify(client);
|
||||
verify(amiClient);
|
||||
verify(credentialsMap);
|
||||
verify(credentialProvider);
|
||||
verify(instance);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyForNovaWhereImageNotFound() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
AMIClient amiClient = createMock(AMIClient.class);
|
||||
expect(client.getAMIServices()).andReturn(amiClient).atLeastOnce();
|
||||
|
@ -298,7 +375,6 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
expect(credentialProvider.execute(null)).andReturn(new Credentials("root", null));
|
||||
|
||||
|
||||
expect(credentialsMap.get(new RegionAndName(Region.US_EAST_1, "nebulatanimislam"))).andReturn(null);
|
||||
|
||||
expect(instance.getAvailabilityZone()).andReturn(null).atLeastOnce();
|
||||
|
@ -328,8 +404,8 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
assertEquals(metadata.getHardware().getProviderId(), "m1.small");
|
||||
assertEquals(metadata.getHardware().getProcessors(), ImmutableList.<Processor> of(new Processor(1.0, 1.0)));
|
||||
assertEquals(metadata.getHardware().getRam(), 1740);
|
||||
assertEquals(metadata.getHardware().getVolumes(), ImmutableList.<Volume> of(new VolumeImpl(null,
|
||||
Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
assertEquals(metadata.getHardware().getVolumes(),
|
||||
ImmutableList.<Volume> of(new VolumeImpl(null, Volume.Type.LOCAL, 10.0f, "/dev/sda1", true, false),//
|
||||
new VolumeImpl(null, Volume.Type.LOCAL, 150.0f, "/dev/sda2", false, false)));
|
||||
|
||||
assertEquals(metadata.getCredentials(), new Credentials("root", null));
|
||||
|
@ -658,7 +734,7 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
verify(instance);
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyWithKeyPairCreatesTagOfParsedSecurityGroupAndCredentialsBasedOnIt() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
|
@ -732,7 +808,7 @@ public class RunningInstanceToNodeMetadataTest {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void testApplyWithTwoSecurityGroups() throws UnknownHostException {
|
||||
EC2Client client = createMock(EC2Client.class);
|
||||
|
|
Loading…
Reference in New Issue