mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ec2): add volumeId to BlockDeviceMapping and disableApiStop/disableApiTermination to DescribeInstanceAttribute (#1028)
Fixes Terraform provider crash when creating aws_instance against floci. Changes: - Add rootVolumeId field to Instance model - Create root EBS volume (gp3) with VolumeAttachment on instance launch - Include volumeId in blockDeviceMapping XML response (null-safe) - Delete root volume on instance termination (deleteOnTermination behavior) - Use inst.getRootDeviceName() for volume attachment device name - Add disableApiStop/disableApiTermination model fields and DescribeInstanceAttribute support (with comment documenting known limitation that ModifyInstanceAttribute does not yet wire these) - Add integration tests for blockDeviceMapping volumeId, DescribeVolumes in-use state, DescribeInstanceAttribute, and volume cleanup on terminate Ref: floci-io/floci#871
This commit is contained in:
1 parent
55a90e8299
commit
ad02786b8a
4 files changed
+161
-7
No files matched your search
@@ -38,6 +38,7 @@ class Ec2IntegrationTest {
|
||||
private static String allocationId;
|
||||
private static String associationId;
|
||||
private static String volumeId;
|
||||
private static String rootVolumeId;
|
||||
private static String networkInterfaceId;
|
||||
|
||||
// =========================================================================
|
||||
@@ -648,6 +649,85 @@ class Ec2IntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(82)
|
||||
void describeInstancesBlockDeviceMappingHasVolumeId() {
|
||||
given()
|
||||
.formParam("Action", "DescribeInstances")
|
||||
.formParam("InstanceId.1", instanceId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.deviceName",
|
||||
equalTo("/dev/xvda"))
|
||||
.body("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.ebs.volumeId",
|
||||
startsWith("vol-"))
|
||||
.body("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.ebs.status",
|
||||
equalTo("attached"))
|
||||
.body("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.ebs.deleteOnTermination",
|
||||
equalTo("true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(83)
|
||||
void rootVolumeAppearsInDescribeVolumes() {
|
||||
// Extract the root volume ID from DescribeInstances
|
||||
String rootVolId = given()
|
||||
.formParam("Action", "DescribeInstances")
|
||||
.formParam("InstanceId.1", instanceId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.extract().path("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.ebs.volumeId");
|
||||
|
||||
// Verify it exists in DescribeVolumes with state=in-use
|
||||
given()
|
||||
.formParam("Action", "DescribeVolumes")
|
||||
.formParam("VolumeId.1", rootVolId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeVolumesResponse.volumeSet.item.volumeId", equalTo(rootVolId))
|
||||
.body("DescribeVolumesResponse.volumeSet.item.status", equalTo("in-use"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(84)
|
||||
void describeInstanceAttributeDisableApiStop() {
|
||||
given()
|
||||
.formParam("Action", "DescribeInstanceAttribute")
|
||||
.formParam("InstanceId", instanceId)
|
||||
.formParam("Attribute", "disableApiStop")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeInstanceAttributeResponse.instanceId", equalTo(instanceId))
|
||||
.body("DescribeInstanceAttributeResponse.disableApiStop.value", equalTo("false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(85)
|
||||
void describeInstanceAttributeDisableApiTermination() {
|
||||
given()
|
||||
.formParam("Action", "DescribeInstanceAttribute")
|
||||
.formParam("InstanceId", instanceId)
|
||||
.formParam("Attribute", "disableApiTermination")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeInstanceAttributeResponse.instanceId", equalTo(instanceId))
|
||||
.body("DescribeInstanceAttributeResponse.disableApiTermination.value", equalTo("false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(86)
|
||||
void describeInstancesByFilter() {
|
||||
given()
|
||||
.formParam("Action", "DescribeInstances")
|
||||
@@ -663,7 +743,7 @@ class Ec2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(83)
|
||||
@Order(87)
|
||||
void describeInstanceStatus() {
|
||||
given()
|
||||
.formParam("Action", "DescribeInstanceStatus")
|
||||
@@ -678,7 +758,7 @@ class Ec2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(84)
|
||||
@Order(88)
|
||||
void associateAddressToInstance() {
|
||||
associationId = given()
|
||||
.formParam("Action", "AssociateAddress")
|
||||
@@ -694,7 +774,7 @@ class Ec2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(85)
|
||||
@Order(89)
|
||||
void stopInstance() {
|
||||
given()
|
||||
.formParam("Action", "StopInstances")
|
||||
@@ -709,7 +789,7 @@ class Ec2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(86)
|
||||
@Order(89)
|
||||
void startInstance() {
|
||||
given()
|
||||
.formParam("Action", "StartInstances")
|
||||
@@ -724,7 +804,7 @@ class Ec2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(87)
|
||||
@Order(89)
|
||||
void rebootInstance() {
|
||||
given()
|
||||
.formParam("Action", "RebootInstances")
|
||||
@@ -1340,6 +1420,16 @@ class Ec2IntegrationTest {
|
||||
@Test
|
||||
@Order(100)
|
||||
void terminateInstance() {
|
||||
// Capture root volume ID before termination
|
||||
rootVolumeId = given()
|
||||
.formParam("Action", "DescribeInstances")
|
||||
.formParam("InstanceId.1", instanceId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.extract().path("DescribeInstancesResponse.reservationSet.item.instancesSet.item.blockDeviceMapping.item.ebs.volumeId");
|
||||
|
||||
given()
|
||||
.formParam("Action", "TerminateInstances")
|
||||
.formParam("InstanceId.1", instanceId)
|
||||
@@ -1352,6 +1442,20 @@ class Ec2IntegrationTest {
|
||||
.body("TerminateInstancesResponse.instancesSet.item.currentState.name", equalTo("shutting-down"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(100)
|
||||
void rootVolumeDeletedAfterTermination() {
|
||||
given()
|
||||
.formParam("Action", "DescribeVolumes")
|
||||
.formParam("VolumeId.1", rootVolumeId)
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidVolume.NotFound"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(101)
|
||||
void disassociateAddress() {
|
||||
|
||||
Reference in new issue
Block a user