Files
floci/compatibility-tests
Jackson Price e75b15809f fix(autoscaling): honor launch configuration metadata options (#5964)
* fix(autoscaling): honor launch configuration metadata options

CreateLaunchConfiguration ignored MetadataOptions, so
DescribeLaunchConfigurations never returned them and every instance
launched from the configuration got EC2's defaults, HttpTokens=optional
included.

- The Query handler and the AWS::AutoScaling::LaunchConfiguration
  provisioner read the structure, validate it as EC2 does
  (ValidationError for a value outside the allowed set or range) and
  store it. CloudFormation resolves Fn::If and AWS::NoValue inside it.
- DescribeLaunchConfigurations returns the structure with defaults for
  the members left out, and omits it when it was never given.
- The reconciler passes it to every launch, instance refresh
  replacements included.
- Auto Scaling launches from a launch template, directly or through a
  mixed instances policy, and CreateFleet forward the template's
  metadata options, which they dropped before.

Split out of #5671 at review.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): clean up after the launch configuration metadata tests

The metadata tests now delete the groups, launch configurations and
stacks they create, so later reconcileAll calls in the shared test
application stop reconciling leaked groups. They build their
Authorization headers with EnforcementFixtures.auth, and the case that
expects no MetadataOptions first checks that the launch configuration
was found.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(autoscaling): word metadata option errors as Auto Scaling does

CreateLaunchConfiguration refused bad MetadataOptions with EC2's
InvalidParameterValue text under a ValidationError code. It now answers
with Auto Scaling's model-validation text, for example "1 validation
error detected: Value '65' at 'metadataOptions.httpPutResponseHopLimit'
failed to satisfy constraint: Member must have value less than or equal
to 64", and reports every invalid member of the structure in one
error, "N validation errors detected: ...; ...". EC2's validator is no
longer shared.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): refuse list or object launch configuration metadata members

A MetadataOptions member given as a list or an object, such as
HttpTokens: [required], read as an empty string and so as absent: the
launch configuration was created with that member at its default,
HttpTokens=optional included. Such a member now fails the resource with
ValidationError, as the whole structure already does when it is not an
object.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): cover every metadata member in the combined error

The test that sends several invalid MetadataOptions members now makes
all three invalid, so the position of HttpEndpoint in the combined
ValidationError is checked, and confirms that no launch configuration
was created.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): report metadata type errors as CloudFormation does

A launch configuration MetadataOptions block or member of the wrong
JSON type failed with wording Floci made up, such as "HttpTokens must
be a string.". It now fails with CloudFormation's schema type error, as
the S3 and DynamoDB provisioners already report it, for example "Model
validation failed (#/MetadataOptions/HttpTokens: expected type: String,
found: JSONArray)". A value of the right type that Auto Scaling rejects
keeps Auto Scaling's ValidationError.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): report an oversized metadata hop limit as out of range

A whole-number HttpPutResponseHopLimit too large for an int, such as
2147483648, failed with the contradictory "expected type: Integer,
found: Integer". It is an integer outside 1 to 64, so it now fails with
the same Auto Scaling ValidationError text as 65 or 0, with the value
as written.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): count an oversized hop limit with the other metadata errors

An oversized CloudFormation HttpPutResponseHopLimit was refused before
the other MetadataOptions members were checked, so an invalid
HttpTokens beside it went unreported, and the value was echoed as
written, "+002147483648" included. Auto Scaling now builds the whole
error from the options and the hop limit as a BigInteger, so the
oversized value is counted with every other violation and printed as
a plain number.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(autoscaling): build metadata option errors through SmithyValidationErrors

The launch configuration MetadataOptions validator assembled its "N
validation errors detected" message by hand. It now uses
SmithyValidationErrors, which main adopted for Auto Scaling's other
checks. The error code and text are unchanged.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): read launch configuration metadata through CfnPropertyTypes

The MetadataOptions reader had its own type check and answered every
wrongly typed value with the handler's "Model validation failed"
message. It now reads the block through CfnPropertyTypes, as the Events
and Lambda provisioners do:

- a value of the wrong type fails template validation first, for
  example "Property [HttpTokens] expected type: String, found:
  JSONArray", and a hop limit of 4.5 is "found: Float";
- a hop limit beyond 32 bits fails the handler's model validation,
  before Auto Scaling's own check runs;
- a number or a boolean given for a string member arrives at Auto
  Scaling as its text, as CloudFormation converts it, and fails its
  enum check there.

The hand-written type helpers go away.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(autoscaling): fold the metadata options error back into its validator

The public metadataOptionsError took the hop limit as a BigInteger so
that CloudFormation could report a value beyond 32 bits through it.
CloudFormation now refuses such a value in model validation, before
Auto Scaling, so the helper goes back to a private validator over the
Integer field. The error code and text are unchanged.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): delete the launch template the metadata test creates

Ec2LaunchTemplateMetadataOptionsIntegrationTest never deleted its
launch template, and its cleanup began only after the fleet or group
had launched, so an earlier failure left everything behind. Everything
after the template is created now runs in the try block, and the
finally block removes the group or the instance and then the template,
ignoring the status so a test's own failure is kept.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): check template metadata options before a CreateFleet dry run

A launch template stores its metadata options unchecked, as AWS does,
so they fail at launch. CreateFleet forwards them to the launch since
this branch, but a dry run returned DryRunOperation before any launch
ran, saying a fleet would succeed that then fails with
InvalidParameterValue. CreateFleet now checks every launch's metadata
options with the rest of its pre-launch checks, as RunInstances does
before honoring DryRun.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): pin the Query answer for a hop limit beyond 32 bits

CreateLaunchConfiguration with MetadataOptions.HttpPutResponseHopLimit=
2147483648 answers MalformedInput, as for any value that is not a
32-bit integer: the awsQuery protocol binds the member before model
validation runs. A row now covers it beside the non-numeric case.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 09:42:58 -04:00
..

floci-compatibility-tests

Compatibility test suite for Floci — a local AWS emulator.

Verifies that standard AWS tooling (SDKs, CDK, OpenTofu/Terraform) works correctly against the emulator without modification. Tests run against a live Floci instance and use real AWS SDK clients — no mocks.

Quick Start

# Install just (task runner)
# macOS: brew install just
# Linux: cargo install just

# Copy and configure environment
cp env.example .env

# Install dependencies
just setup

# Run all tests
just test-all

# Run specific SDK tests
just test-python
just test-typescript
just test-awscli

Test Runners

Module Language Test Framework Command
sdk-test-python Python 3 pytest just test-python
sdk-test-node TypeScript vitest just test-typescript
sdk-test-awscli Bash / AWS CLI bats-core just test-awscli
sdk-test-java Java 17 JUnit 5 just test-java
sdk-test-go Go 1.24 go test just test-go

IaC Compatibility

Module Tool Command
compat-cdk AWS CDK v2 ./run.sh
compat-opentofu OpenTofu ./run.sh
compat-terraform Terraform ./run.sh

The Terraform suite uses the standard hashicorp/aws provider against Floci's local endpoint. It validates init, validate, plan, apply, resource reads, and destroy without creating resources in a real AWS account. See the Terraform with Floci guide for a copy-paste setup.

Prerequisites

  • Floci running on http://localhost:4566 (or set FLOCI_ENDPOINT)
  • Docker — required for Lambda invocation tests
  • just — task runner for orchestration

Per-module requirements:

Module Requirements
sdk-test-python Python 3.9+, pip
sdk-test-node Node.js 20+, npm, vitest
sdk-test-awscli AWS CLI v2, bash, jq
sdk-test-java Java 17+, Maven
sdk-test-go Go 1.24+
compat-cdk Node.js 20+, npm, Python 3, bats-core

Setup

# Setup all SDKs
just setup

# Setup individual SDKs
just setup-python      # pip install -r requirements.txt
just setup-typescript  # npm install
just setup-awscli      # Clone bats-core, bats-support, bats-assert

The boto3 and botocore versions in sdk-test-python/requirements.txt pin the test clients, not the AWS models used to generate Floci's vendored data. For model audits and data regeneration, use the pin in tools/aws/requirements.txt at the repository root and check the selected model source. See Botocore pin of record for the distinction and the generators' data-source precedence.

Running Tests

All SDKs

just test-all

Individual SDKs

# Python (pytest)
just test-python

# TypeScript (vitest)
just test-typescript

# AWS CLI (bats-core)
just test-awscli

IaC tools

The Terraform, OpenTofu, and CDK suites aren't part of just test-all — run them individually by name:

# Terraform
compat-terraform/run.sh

# OpenTofu
compat-opentofu/run.sh

# AWS CDK
compat-cdk/run.sh

Bats-based suites keep their normal console output and also write JUnit XML reports:

  • sdk-test-awscli/test-results/junit.xml
  • compat-cdk/test-results/junit.xml
  • compat-terraform/test-results/junit-<bats file>.xml
  • compat-opentofu/test-results/junit-<bats file>.xml

The Terraform and OpenTofu suites run each test/*.bats file in its own process concurrently, so they write one report per file rather than a single junit.xml. Every consumer globs the directory, so nothing downstream changes. Set BATS_PARALLEL_FILES=0 to run the files one at a time when isolating a failure. Each file also runs under a BATS_FILE_TIMEOUT (default 12m): a fixture that hangs fails under its own name with its TAP output ending at the stuck test, and the reports of the files that finished are still published, instead of the whole job dying at the workflow's 20 minute limit with nothing reported.

Configuration

All modules read from environment variables (see .env.example):

FLOCI_ENDPOINT=http://localhost:4566
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION=us-east-1

Running with Docker

Each module includes a Dockerfile for isolated execution:

# Python
docker build -t floci-sdk-python sdk-test-python/
docker run --rm --network host floci-sdk-python pytest

# TypeScript
docker build -t floci-sdk-node sdk-test-node/
docker run --rm --network host floci-sdk-node npm test

On macOS/Windows, use host.docker.internal instead of localhost:

docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python pytest

Exit Codes

All test runners exit 0 on full pass and non-zero if any test fails — suitable for CI pipelines.