mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 23:00:59 -05:00
* feat(firehose): return ExtendedS3DestinationDescription and support UpdateDestination The Terraform/Pulumi provider creates delivery streams with ExtendedS3DestinationConfiguration and reads ExtendedS3DestinationDescription back after create; Floci parsed the config lossily and only ever emitted S3DestinationDescription, breaking the provider read. Store the full config (RoleARN, ErrorOutputPrefix, CompressionFormat, EncryptionConfiguration), emit it under both wire keys like real AWS, add the required output members (VersionId, DeliveryStreamType, HasMoreDestinations, DestinationId), and implement UpdateDestination with version checking. Refs #1043 * fix(firehose): reject empty destination updates and guard version parse * fix(firehose): reject partial BufferingHints instead of absorbing defaults AWS requires SizeInMBs and IntervalInSeconds to be specified together (firehose service-2.json: "if you specify a value for it, you must also specify a value for IntervalInSeconds, and vice versa"). The primitive fields with initializers made a partial payload indistinguishable from a full one, silently persisting a default over an existing value. Members are now null-honest boxed Integers, create and update reject one-sided hints with the declared InvalidArgumentException before any mutation, and defaults apply only when the whole object is absent.
214 lines
7.2 KiB
Bash
214 lines
7.2 KiB
Bash
#!/usr/bin/env bats
|
|
# Terraform Compatibility Tests for floci
|
|
|
|
setup_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
cd "$TF_DIR"
|
|
|
|
echo "# === Terraform Compatibility Test ===" >&3
|
|
echo "# Endpoint: $FLOCI_ENDPOINT" >&3
|
|
|
|
# Clean any previous state
|
|
rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true
|
|
|
|
echo "# --- Setup: state bucket & lock table ---" >&3
|
|
create_state_backend
|
|
generate_backend_config
|
|
|
|
echo "# --- terraform init ---" >&3
|
|
run terraform init -backend-config=/tmp/floci-backend.hcl \
|
|
-var="endpoint=${FLOCI_ENDPOINT}" -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'
|
|
|
|
cd "$TF_DIR"
|
|
|
|
echo "# --- terraform destroy ---" >&3
|
|
terraform destroy -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color || true
|
|
}
|
|
|
|
setup() {
|
|
load 'test_helper/common-setup'
|
|
}
|
|
|
|
# --- Spot Checks ---
|
|
|
|
@test "Terraform: S3 bucket created" {
|
|
run aws_cmd s3api head-bucket --bucket floci-compat-app
|
|
assert_success
|
|
}
|
|
|
|
@test "Terraform: SQS queue created" {
|
|
run aws_cmd sqs get-queue-url --queue-name floci-compat-jobs
|
|
assert_success
|
|
assert_output --partial "QueueUrl"
|
|
}
|
|
|
|
@test "Terraform: SNS topic created" {
|
|
run aws_cmd sns list-topics
|
|
assert_success
|
|
assert_output --partial "floci-compat-events"
|
|
}
|
|
|
|
@test "Terraform: DynamoDB table created" {
|
|
run aws_cmd dynamodb describe-table --table-name floci-compat-items
|
|
assert_success
|
|
assert_output --partial "ACTIVE"
|
|
}
|
|
|
|
@test "Terraform: SSM parameter created" {
|
|
run aws_cmd ssm get-parameter --name /floci-compat/db-url
|
|
assert_success
|
|
assert_output --partial "jdbc:"
|
|
}
|
|
|
|
@test "Terraform: Secrets Manager secret created" {
|
|
run aws_cmd secretsmanager describe-secret --secret-id "floci-compat/db-creds"
|
|
assert_success
|
|
assert_output --partial "floci-compat"
|
|
}
|
|
|
|
@test "Terraform: RDS DB instance created and available" {
|
|
run aws_cmd rds describe-db-instances --db-instance-identifier floci-compat-db
|
|
assert_success
|
|
assert_output --partial "floci-compat-db"
|
|
assert_output --partial "available"
|
|
}
|
|
|
|
@test "Terraform: CloudWatch alarm created with tags" {
|
|
run aws_cmd cloudwatch describe-alarms --alarm-names floci-compat-cpu-alarm
|
|
assert_success
|
|
assert_output --partial "floci-compat-cpu-alarm"
|
|
|
|
ALARM_ARN=$(aws_cmd cloudwatch describe-alarms --alarm-names floci-compat-cpu-alarm \
|
|
--query 'MetricAlarms[0].AlarmArn' --output text)
|
|
run aws_cmd cloudwatch list-tags-for-resource --resource-arn "$ALARM_ARN"
|
|
assert_success
|
|
assert_output --partial "compat-test"
|
|
}
|
|
|
|
@test "Terraform: VPC created with custom DNS settings" {
|
|
run aws_cmd ec2 describe-vpcs \
|
|
--filters "Name=tag:Name,Values=floci-compat-vpc"
|
|
assert_success
|
|
assert_output --partial "floci-compat-vpc"
|
|
assert_output --partial "10.0.0.0/16"
|
|
}
|
|
|
|
@test "Terraform: VPC enableDnsSupport persisted as false" {
|
|
VPC_ID=$(aws_cmd ec2 describe-vpcs \
|
|
--filters "Name=tag:Name,Values=floci-compat-vpc" \
|
|
--query 'Vpcs[0].VpcId' --output text)
|
|
run aws_cmd ec2 describe-vpc-attribute \
|
|
--vpc-id "$VPC_ID" --attribute enableDnsSupport
|
|
assert_success
|
|
assert_output --partial '"Value": false'
|
|
}
|
|
|
|
@test "Terraform: VPC enableDnsHostnames persisted as false" {
|
|
VPC_ID=$(aws_cmd ec2 describe-vpcs \
|
|
--filters "Name=tag:Name,Values=floci-compat-vpc" \
|
|
--query 'Vpcs[0].VpcId' --output text)
|
|
run aws_cmd ec2 describe-vpc-attribute \
|
|
--vpc-id "$VPC_ID" --attribute enableDnsHostnames
|
|
assert_success
|
|
assert_output --partial '"Value": false'
|
|
}
|
|
|
|
@test "Terraform: Route53 hosted zone created" {
|
|
ZONE_ID=$(aws_cmd route53 list-hosted-zones \
|
|
--query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
|
|
--output text | sed 's|/hostedzone/||')
|
|
[ -n "$ZONE_ID" ]
|
|
run aws_cmd route53 get-hosted-zone --id "$ZONE_ID"
|
|
assert_success
|
|
assert_output --partial "floci-compat.internal"
|
|
}
|
|
|
|
@test "Terraform: Route53 A record created" {
|
|
ZONE_ID=$(aws_cmd route53 list-hosted-zones \
|
|
--query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
|
|
--output text | sed 's|/hostedzone/||')
|
|
run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
|
|
assert_success
|
|
assert_output --partial "app.floci-compat.internal"
|
|
assert_output --partial "10.0.1.10"
|
|
}
|
|
|
|
@test "Terraform: Route53 zone has auto-created SOA and NS records" {
|
|
ZONE_ID=$(aws_cmd route53 list-hosted-zones \
|
|
--query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
|
|
--output text | sed 's|/hostedzone/||')
|
|
run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
|
|
assert_success
|
|
assert_output --partial '"SOA"'
|
|
assert_output --partial '"NS"'
|
|
}
|
|
|
|
@test "Terraform: Route53 health check created" {
|
|
HEALTH_CHECK_ID=$(aws_cmd route53 list-health-checks \
|
|
--query "HealthChecks[?HealthCheckConfig.FullyQualifiedDomainName=='app.floci-compat.internal'].Id | [0]" \
|
|
--output text)
|
|
[ -n "$HEALTH_CHECK_ID" ]
|
|
run aws_cmd route53 get-health-check --health-check-id "$HEALTH_CHECK_ID"
|
|
assert_success
|
|
assert_output --partial "app.floci-compat.internal"
|
|
assert_output --partial "HTTP"
|
|
}
|
|
|
|
@test "Terraform: Route53 zone tags persisted" {
|
|
ZONE_ID=$(aws_cmd route53 list-hosted-zones \
|
|
--query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
|
|
--output text | sed 's|/hostedzone/||')
|
|
run aws_cmd route53 list-tags-for-resource \
|
|
--resource-type hostedzone --resource-id "$ZONE_ID"
|
|
assert_success
|
|
assert_output --partial "compat-test"
|
|
}
|
|
|
|
@test "Terraform: Cognito user pool client created without optional blocks" {
|
|
POOL_ID=$(aws_cmd cognito-idp list-user-pools --max-results 10 \
|
|
--query "UserPools[?Name=='floci-compat-pool'].Id | [0]" --output text)
|
|
[ -n "$POOL_ID" ]
|
|
run aws_cmd cognito-idp list-user-pool-clients --user-pool-id "$POOL_ID" \
|
|
--query "UserPoolClients[?ClientName=='floci-compat-pool-client'].ClientId | [0]" --output text
|
|
assert_success
|
|
[ -n "$output" ]
|
|
[ "$output" != "None" ]
|
|
}
|
|
|
|
@test "Terraform: Firehose extended_s3 delivery stream created with correct config" {
|
|
run aws_cmd firehose describe-delivery-stream --delivery-stream-name floci-compat-firehose \
|
|
--query "DeliveryStreamDescription.Destinations[0].ExtendedS3DestinationDescription.CompressionFormat" --output text
|
|
assert_success
|
|
assert_output "GZIP"
|
|
}
|