Fix DigitalOcean DropletApiLiveTest

This commit is contained in:
Ignasi Barrera 2017-11-28 11:58:51 +01:00
parent 6f7e4b92b0
commit a0f659faed
No known key found for this signature in database
GPG Key ID: 3D5414A0D959B94F
8 changed files with 16 additions and 12 deletions

View File

@ -38,7 +38,7 @@
<test.digitalocean2.api-version>2</test.digitalocean2.api-version> <test.digitalocean2.api-version>2</test.digitalocean2.api-version>
<test.digitalocean2.identity>FIXME</test.digitalocean2.identity> <test.digitalocean2.identity>FIXME</test.digitalocean2.identity>
<test.digitalocean2.credential>FIXME</test.digitalocean2.credential> <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.export>org.jclouds.digitalocean2*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import> <jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}", org.jclouds.compute.internal;version="${project.version}",

View File

@ -68,7 +68,7 @@ public class DigitalOcean2ApiMetadata extends BaseHttpApiMetadata<DigitalOcean2A
properties.put(AUDIENCE, "https://cloud.digitalocean.com/v1/oauth/token"); properties.put(AUDIENCE, "https://cloud.digitalocean.com/v1/oauth/token");
properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString()); properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString());
properties.put(PROPERTY_SESSION_INTERVAL, 3600); 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_INITIAL_PERIOD, 5000);
properties.put(POLL_MAX_PERIOD, 20000); properties.put(POLL_MAX_PERIOD, 20000);
// Node operations in DigitalOcean can be quite slow. Use a 5 minutes // Node operations in DigitalOcean can be quite slow. Use a 5 minutes

View File

@ -37,11 +37,15 @@ public abstract class Image {
public abstract boolean isPublic(); public abstract boolean isPublic();
public abstract List<String> regions(); public abstract List<String> regions();
public abstract Date createdAt(); 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, public static Image create(int id, String name, String type, String distribution, String slug, boolean isPublic,
List<String> regions, Date createdAt) { List<String> regions, Date createdAt, float minDiskSize, float sizeGBs) {
return new AutoValue_Image(id, name, type, distribution, slug, isPublic, copyOf(regions), createdAt); return new AutoValue_Image(id, name, type, distribution, slug, isPublic, copyOf(regions), createdAt, minDiskSize,
sizeGBs);
} }
Image() {} Image() {}

View File

@ -40,7 +40,7 @@ public class DigitalOcean2TemplateBuilderLiveTest extends BaseTemplateBuilderLiv
@Override @Override
public void testDefaultTemplateBuilder() throws IOException { public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = view.getComputeService().templateBuilder().build(); 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(); .getImage().getOperatingSystem().getVersion();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);

View File

@ -79,7 +79,7 @@ public class DropletToNodeMetadataTest {
@BeforeMethod @BeforeMethod
public void setup() { public void setup() {
image = org.jclouds.digitalocean2.domain.Image.create(1, "14.04 x64", 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()); region = Region.create("sfo1", "San Francisco 1", ImmutableList.of("2gb"), true, ImmutableList.<String> of());
images = ImmutableSet.of(new ImageBuilder() images = ImmutableSet.of(new ImageBuilder()
@ -146,7 +146,7 @@ public class DropletToNodeMetadataTest {
public void testConvertDropletOldImage() throws ParseException { public void testConvertDropletOldImage() throws ParseException {
// Use an image id that is not in the list of images // 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", 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( Droplet droplet = Droplet.create(
1, 1,

View File

@ -75,7 +75,7 @@ public class ImageInRegionToImageTest {
@Test @Test
public void testConvertImage() { public void testConvertImage() {
Image image = Image.create(1, "14.04 x64", "distribution", "Ubuntu", "ubuntu-1404-x86", true, 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() org.jclouds.compute.domain.Image expected = new ImageBuilder()
.id("lon1/ubuntu-1404-x86") // Location scoped images have the location encoded in the id .id("lon1/ubuntu-1404-x86") // Location scoped images have the location encoded in the id
.providerId("1") .providerId("1")

View File

@ -57,8 +57,8 @@ public class DropletApiLiveTest extends BaseDigitalOcean2ApiLiveTest {
@BeforeClass @BeforeClass
public void setupDroplet() { public void setupDroplet() {
region = firstAvailableRegion(); region = firstAvailableRegion();
size = cheapestSizeInRegion(region);
image = ubuntuImageInRegion(region); image = ubuntuImageInRegion(region);
size = cheapestSizeInRegionForImage(region, image);
Map<String, String> keyPair = SshKeys.generate(); Map<String, String> keyPair = SshKeys.generate();
key = api.keyApi().create(prefix + "-droplet-livetest", keyPair.get("public")); key = api.keyApi().create(prefix + "-droplet-livetest", keyPair.get("public"));

View File

@ -104,11 +104,11 @@ public class BaseDigitalOcean2ApiLiveTest extends BaseApiLiveTest<DigitalOcean2A
}).get(); }).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>() { return sizesByPrice().min(api.sizeApi().list().concat().filter(new Predicate<Size>() {
@Override @Override
public boolean apply(Size input) { 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();
} }
})); }));
} }