mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 22:37:55 -05:00
* feat(ec2): add partial DescribeNetworkInterfaces (phases 1-3) Wire DescribeNetworkInterfaces into the EC2 query handler with ENI data derived from running instances. Covers: - Empty response skeleton - Basic ENI mapping (networkInterfaceId, subnetId, vpcId, groupSet, attachment) - Full field coverage (privateIpAddressesSet, EIP association, tagSet, availabilityZone, interfaceType, attachTime, deleteOnTermination) Remaining: filter support, pagination, error handling, Terraform compat validation (phases 4-6 for #1031). * feat(ec2): add filter support for DescribeNetworkInterfaces (phase 4) Support these filter keys: network-interface-id, subnet-id, vpc-id, group-id, status, private-ip-address, description, owner-id, mac-address, private-dns-name, tag:<key>, tag-key. Filters use AND semantics. No-match filters return HTTP 200 with empty networkInterfaceSet. * feat(ec2): add pagination and error handling for DescribeNetworkInterfaces (phases 5-6) - Add NetworkInterfaceListResult record for paginated responses - Implement offset-based MaxResults/NextToken pagination - Add Base64 token encode/decode for pagination cursor - Validate MaxResults range (5-1000) and MaxResults+NetworkInterfaceId conflict - Conditionally emit nextToken in XML response (only when truncated) - Add InvalidNetworkInterfaceID.NotFound for non-existent IDs - Add InvalidNetworkInterfaceID.Malformed for IDs not starting with 'eni-' - Track found IDs via HashSet for accurate NotFound detection * test(ec2): add DescribeNetworkInterfaces pagination, error, and multipage tests - 5 pagination validation tests (MaxResults range, param conflict, invalid token) - 1 pagination success test (MaxResults > available ENIs, no nextToken emitted) - 2 error handling tests (InvalidNetworkInterfaceID.NotFound and .Malformed) - 1 self-contained multipage pagination test (launches 5 extra instances, verifies MaxResults=5 truncation, NextToken continuation, final page cleanup) - All 87 Ec2IntegrationTest tests pass * test(ec2): add SDK and Terraform compat tests for DescribeNetworkInterfaces - Add Ec2NetworkInterfacePaginationTest with 4 scenarios: all 6 ENIs without pagination, MaxResults=5 truncation, NextToken continuation (no overlap between pages), and token re-use stability - Add eni_destroy.bats Terraform compat test verifying destroy succeeds on VPC+subnet+SG now that DescribeNetworkInterfaces is implemented - Add minimal Terraform config (VPC 10.0.0.0/16, subnet, SG) for ENI test * fix(ec2): align DescribeNetworkInterfaces MaxResults errors * test(terraform): make ENI destroy compat test runnable
117 lines
3.6 KiB
Bash
117 lines
3.6 KiB
Bash
#!/usr/bin/env bats
|
|
# ENI Destroy Compatibility Test
|
|
#
|
|
# Reproduces https://github.com/floci-io/floci/issues/1031
|
|
# Terraform destroy succeeds on VPC+subnet+SG because
|
|
# DescribeNetworkInterfaces is now implemented.
|
|
#
|
|
# This test verifies that terraform destroy on a VPC with
|
|
# subnets and security groups completes without error.
|
|
# DescribeNetworkInterfaces returns an empty ENI list when
|
|
# no instances exist, unblocking the destroy workflow.
|
|
#
|
|
# FIX VERIFIED: DescribeNetworkInterfaces implemented,
|
|
# Test now PASSES. (Previously returned UnsupportedOperation.)
|
|
|
|
setup_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
# Override TF_DIR to the minimal eni-destroy terraform config
|
|
ENI_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/eni-destroy-tf" && pwd)"
|
|
cd "$ENI_TF_DIR"
|
|
|
|
echo "# === ENI Destroy Test ===" >&3
|
|
echo "# Endpoint: $FLOCI_ENDPOINT" >&3
|
|
echo "# Config: $ENI_TF_DIR" >&3
|
|
|
|
# Clean any previous state
|
|
rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true
|
|
|
|
echo "# --- terraform init ---" >&3
|
|
run terraform init -input=false -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform init failed: $output" >&3
|
|
return 1
|
|
fi
|
|
|
|
echo "# --- terraform validate ---" >&3
|
|
run terraform validate -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform validate failed: $output" >&3
|
|
return 1
|
|
fi
|
|
|
|
echo "# --- terraform plan ---" >&3
|
|
run terraform plan -var="endpoint=${FLOCI_ENDPOINT}" -input=false -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform plan failed: $output" >&3
|
|
return 1
|
|
fi
|
|
|
|
echo "# --- terraform apply ---" >&3
|
|
run terraform apply -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform apply failed: $output" >&3
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
teardown_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
ENI_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/eni-destroy-tf" && pwd)"
|
|
cd "$ENI_TF_DIR"
|
|
|
|
# Clean up terraform state after test
|
|
rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true
|
|
}
|
|
|
|
setup() {
|
|
load 'test_helper/common-setup'
|
|
ENI_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/eni-destroy-tf" && pwd)"
|
|
}
|
|
|
|
# --- Spot checks: resources were created ---
|
|
|
|
@test "ENI Destroy: VPC was created" {
|
|
run aws_cmd ec2 describe-vpcs \
|
|
--filters "Name=tag:Name,Values=floci-eni-destroy-vpc"
|
|
assert_success
|
|
assert_output --partial "floci-eni-destroy-vpc"
|
|
assert_output --partial "10.0.0.0/16"
|
|
}
|
|
|
|
@test "ENI Destroy: Subnet was created" {
|
|
run terraform -chdir="$ENI_TF_DIR" state show aws_subnet.test
|
|
assert_success
|
|
assert_output --partial "10.0.1.0/24"
|
|
}
|
|
|
|
@test "ENI Destroy: Security Group was created" {
|
|
run aws_cmd ec2 describe-security-groups \
|
|
--group-names "floci-eni-destroy-sg"
|
|
assert_success
|
|
assert_output --partial "floci-eni-destroy-sg"
|
|
}
|
|
|
|
# --- The critical assertion: terraform destroy must succeed ---
|
|
#
|
|
# Terraform destroy on a VPC with subnets/SGs calls
|
|
# DescribeNetworkInterfaces to check for ENIs. With no
|
|
# instances running, the response is an empty set,
|
|
# allowing the destroy to proceed cleanly.
|
|
|
|
@test "ENI Destroy: terraform destroy succeeds" {
|
|
cd "$ENI_TF_DIR"
|
|
|
|
echo "# --- terraform destroy ---" >&3
|
|
run terraform destroy -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color
|
|
|
|
assert_success
|
|
|
|
# Verify resources are actually gone
|
|
run aws_cmd ec2 describe-vpcs \
|
|
--filters "Name=tag:Name,Values=floci-eni-destroy-vpc"
|
|
assert_output --partial '"Vpcs": []' # empty result = VPC deleted
|
|
}
|