mirror of https://github.com/apache/jclouds.git
Fix DigitalOcean DropletApiLiveTest
This commit is contained in:
parent
6f7e4b92b0
commit
a0f659faed
|
@ -38,7 +38,7 @@
|
|||
<test.digitalocean2.api-version>2</test.digitalocean2.api-version>
|
||||
<test.digitalocean2.identity>FIXME</test.digitalocean2.identity>
|
||||
<test.digitalocean2.credential>FIXME</test.digitalocean2.credential>
|
||||
<test.digitalocean2.template>osFamily=UBUNTU,os64Bit=true,osVersionMatches=14.*</test.digitalocean2.template>
|
||||
<test.digitalocean2.template>osFamily=UBUNTU,os64Bit=true,osVersionMatches=16.*</test.digitalocean2.template>
|
||||
<jclouds.osgi.export>org.jclouds.digitalocean2*;version="${project.version}"</jclouds.osgi.export>
|
||||
<jclouds.osgi.import>
|
||||
org.jclouds.compute.internal;version="${project.version}",
|
||||
|
|
|
@ -68,7 +68,7 @@ public class DigitalOcean2ApiMetadata extends BaseHttpApiMetadata<DigitalOcean2A
|
|||
properties.put(AUDIENCE, "https://cloud.digitalocean.com/v1/oauth/token");
|
||||
properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString());
|
||||
properties.put(PROPERTY_SESSION_INTERVAL, 3600);
|
||||
properties.put(TEMPLATE, "osFamily=UBUNTU,os64Bit=true,osVersionMatches=14.*");
|
||||
properties.put(TEMPLATE, "osFamily=UBUNTU,os64Bit=true,osVersionMatches=16.*");
|
||||
properties.put(POLL_INITIAL_PERIOD, 5000);
|
||||
properties.put(POLL_MAX_PERIOD, 20000);
|
||||
// Node operations in DigitalOcean can be quite slow. Use a 5 minutes
|
||||
|
|
|
@ -37,11 +37,15 @@ public abstract class Image {
|
|||
public abstract boolean isPublic();
|
||||
public abstract List<String> regions();
|
||||
public abstract Date createdAt();
|
||||
public abstract float minDiskSize();
|
||||
public abstract float sizeGBs();
|
||||
|
||||
@SerializedNames({ "id", "name", "type", "distribution", "slug", "public", "regions", "created_at" })
|
||||
@SerializedNames({ "id", "name", "type", "distribution", "slug", "public", "regions", "created_at", "min_disk_size",
|
||||
"size_gigabytes" })
|
||||
public static Image create(int id, String name, String type, String distribution, String slug, boolean isPublic,
|
||||
List<String> regions, Date createdAt) {
|
||||
return new AutoValue_Image(id, name, type, distribution, slug, isPublic, copyOf(regions), createdAt);
|
||||
List<String> regions, Date createdAt, float minDiskSize, float sizeGBs) {
|
||||
return new AutoValue_Image(id, name, type, distribution, slug, isPublic, copyOf(regions), createdAt, minDiskSize,
|
||||
sizeGBs);
|
||||
}
|
||||
|
||||
Image() {}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class DigitalOcean2TemplateBuilderLiveTest extends BaseTemplateBuilderLiv
|
|||
@Override
|
||||
public void testDefaultTemplateBuilder() throws IOException {
|
||||
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||
assert defaultTemplate.getImage().getOperatingSystem().getVersion().startsWith("14.") : defaultTemplate
|
||||
assert defaultTemplate.getImage().getOperatingSystem().getVersion().startsWith("16.") : defaultTemplate
|
||||
.getImage().getOperatingSystem().getVersion();
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class DropletToNodeMetadataTest {
|
|||
@BeforeMethod
|
||||
public void setup() {
|
||||
image = org.jclouds.digitalocean2.domain.Image.create(1, "14.04 x64",
|
||||
"distribution", "Ubuntu", "ubuntu-1404-x86", true, ImmutableList.of("sfo1"), new Date());
|
||||
"distribution", "Ubuntu", "ubuntu-1404-x86", true, ImmutableList.of("sfo1"), new Date(), 20, 20);
|
||||
region = Region.create("sfo1", "San Francisco 1", ImmutableList.of("2gb"), true, ImmutableList.<String> of());
|
||||
|
||||
images = ImmutableSet.of(new ImageBuilder()
|
||||
|
@ -146,7 +146,7 @@ public class DropletToNodeMetadataTest {
|
|||
public void testConvertDropletOldImage() throws ParseException {
|
||||
// Use an image id that is not in the list of images
|
||||
org.jclouds.digitalocean2.domain.Image image = org.jclouds.digitalocean2.domain.Image.create(2, "14.04 x64",
|
||||
"distribution", "Ubuntu", "ubuntu2-1404-x86", true, ImmutableList.of("sfo1"), new Date());
|
||||
"distribution", "Ubuntu", "ubuntu2-1404-x86", true, ImmutableList.of("sfo1"), new Date(), 20, 20);
|
||||
|
||||
Droplet droplet = Droplet.create(
|
||||
1,
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ImageInRegionToImageTest {
|
|||
@Test
|
||||
public void testConvertImage() {
|
||||
Image image = Image.create(1, "14.04 x64", "distribution", "Ubuntu", "ubuntu-1404-x86", true,
|
||||
ImmutableList.of("sfo1", "lon1"), new Date());
|
||||
ImmutableList.of("sfo1", "lon1"), new Date(), 20, 20);
|
||||
org.jclouds.compute.domain.Image expected = new ImageBuilder()
|
||||
.id("lon1/ubuntu-1404-x86") // Location scoped images have the location encoded in the id
|
||||
.providerId("1")
|
||||
|
|
|
@ -57,8 +57,8 @@ public class DropletApiLiveTest extends BaseDigitalOcean2ApiLiveTest {
|
|||
@BeforeClass
|
||||
public void setupDroplet() {
|
||||
region = firstAvailableRegion();
|
||||
size = cheapestSizeInRegion(region);
|
||||
image = ubuntuImageInRegion(region);
|
||||
size = cheapestSizeInRegionForImage(region, image);
|
||||
|
||||
Map<String, String> keyPair = SshKeys.generate();
|
||||
key = api.keyApi().create(prefix + "-droplet-livetest", keyPair.get("public"));
|
||||
|
|
|
@ -104,11 +104,11 @@ public class BaseDigitalOcean2ApiLiveTest extends BaseApiLiveTest<DigitalOcean2A
|
|||
}).get();
|
||||
}
|
||||
|
||||
protected Size cheapestSizeInRegion(final Region region) {
|
||||
protected Size cheapestSizeInRegionForImage(final Region region, final Image image) {
|
||||
return sizesByPrice().min(api.sizeApi().list().concat().filter(new Predicate<Size>() {
|
||||
@Override
|
||||
public boolean apply(Size input) {
|
||||
return input.available() && input.regions().contains(region.slug());
|
||||
return input.available() && input.regions().contains(region.slug()) && input.disk() >= image.minDiskSize();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue