mirror of https://github.com/apache/jclouds.git
additional test for EU create snapshot
This commit is contained in:
parent
9e8b4756c2
commit
238fbceaaa
|
@ -38,6 +38,10 @@ import com.google.common.collect.ImmutableSet;
|
|||
*/
|
||||
public class Volume implements Comparable<Volume> {
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromVolume(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the
|
||||
* instance is shut down.
|
||||
|
@ -147,6 +151,12 @@ public class Volume implements Comparable<Volume> {
|
|||
public Volume build() {
|
||||
return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, attachments);
|
||||
}
|
||||
|
||||
public Builder fromVolume(Volume in) {
|
||||
return region(in.region).id(in.id).size(in.size).snapshotId(in.snapshotId)
|
||||
.availabilityZone(in.availabilityZone).status(in.status).createTime(in.createTime)
|
||||
.attachments(in.attachments);
|
||||
}
|
||||
}
|
||||
|
||||
private final String region;
|
||||
|
|
|
@ -35,6 +35,15 @@ import com.google.common.collect.ImmutableMap.Builder;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "EC2ElasticBlockStoreClientExpectTest")
|
||||
public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ExpectTest<EC2Client> {
|
||||
Volume creating = Volume.builder()
|
||||
.id("vol-2a21e543")
|
||||
.status(Volume.Status.CREATING)
|
||||
.availabilityZone("us-east-1a")
|
||||
.region("us-east-1")
|
||||
.id("vol-2a21e543")
|
||||
.size(1)
|
||||
.createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"))
|
||||
.build();
|
||||
|
||||
public void testCreateVolumeInAvailabilityZone() {
|
||||
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
|
||||
|
@ -51,18 +60,31 @@ public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ExpectTest<EC2C
|
|||
.payload(payloadFromResource("/created_volume.xml")).build());
|
||||
|
||||
ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
|
||||
Volume expected = Volume
|
||||
.builder()
|
||||
.id("vol-2a21e543")
|
||||
.status(Volume.Status.CREATING)
|
||||
.availabilityZone("us-east-1a")
|
||||
.region("us-east-1")
|
||||
.id("vol-2a21e543")
|
||||
.size(1)
|
||||
.createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"))
|
||||
.build();
|
||||
|
||||
assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), expected);
|
||||
assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), creating);
|
||||
}
|
||||
|
||||
public void testCreateVolumeFromSnapshotInAvailabilityZoneEuSetsCorrectEndpoint() {
|
||||
String region = "eu-west-1";
|
||||
|
||||
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
|
||||
builder.put(describeRegionsRequest, describeRegionsResponse);
|
||||
builder.putAll(describeAvailabilityZonesRequestResponse);
|
||||
builder.put(
|
||||
formSigner.filter(HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://ec2." + region + ".amazonaws.com/")
|
||||
.addHeader("Host", "ec2." + region + ".amazonaws.com")
|
||||
.addFormParam("Action", "CreateVolume")
|
||||
.addFormParam("AvailabilityZone", "eu-west-1a")
|
||||
.addFormParam("Size", "1")
|
||||
.addFormParam("SnapshotId", "snap-8b7ffbdd").build()),
|
||||
HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.payload(payloadFromResource("/created_volume.xml")).build());
|
||||
|
||||
ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
|
||||
|
||||
assertEquals(client.createVolumeFromSnapshotInAvailabilityZone(region + "a", 1, "snap-8b7ffbdd"), creating.toBuilder().region(region).build());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue