Files
floci/compatibility-tests
Hector Ventura b3465ec94b ci(compat): run the Terraform and OpenTofu bats files concurrently (#3282)
* ci(compat): run the Terraform and OpenTofu bats files concurrently

compat-terraform is the slowest leg of the compatibility workflow and the job
that ends it: its test step is flat at 13m18s to 13m32s across recent runs, while
every other leg finishes several minutes earlier. The six bats files ran as a
single `bats test/` process, so they executed one after another even though each
is an independent root module with its own state and identifiers.

Their cost is dominated by the AWS provider's own waiters rather than by floci:
Neptune and ElastiCache sleep 30s before the first poll on create and delete, and
RDS sleeps 60s. Nothing can shorten those, only overlap them.

Each test/*.bats file now runs in its own process, reaped with wait, writing one
junit-<file>.xml. bats' own --jobs needs GNU parallel or rush, neither of which is
in the image, so the files are forked directly. Output is collected per file and
replayed in a fixed order, because six interleaved streams are unreadable.
BATS_PARALLEL_FILES=0 restores sequential execution for isolating a failure. Both
run.sh wrappers and the justfile recipes delegate to the same runner, so a local
run and a CI run execute identical logic.

The provider plugin cache is warmed once before forking: every fixture deletes its
lock file in setup_file and the AWS provider unpacks to 770 MB, so six concurrent
inits would otherwise pull about 4.6 GB. The warm-up is sequential because that
cache is safe for concurrent readers but not writers, and a failure there is
logged and tolerated rather than fatal.

Also adds the .dockerignore both suites were missing. Each directory can hold a
local .terraform/ of several hundred megabytes plus stray state, none of which
exists in a CI checkout, so image builds were copying roughly 1.4 GB of host state
and behaving differently from CI.

Measured locally on the same image, all 84 tests passing either way: sequential
1130s, concurrent 260s.

* ci(compat): clear stale JUnit reports before running the suites

The runner created the results directory but never cleared it, and the per-file
reports do not replace everything an earlier run could have left: a renamed or
removed bats file keeps its old XML, and so does a run that stops before writing
all of them. Every consumer globs the directory, so those linger in the summary.

CI never saw this, since it starts from a fresh checkout with an empty
test-results. Locally the directory persists in the working tree, and the case is
already live: both suites still hold the single junit.xml the previous sequential
runner wrote, which the junit-<file>.xml names could never overwrite. A local run
mixed months-old results into the current ones, including in the timing numbers
this change was measured with.

Raised by the review on this PR.

* fix(compat): stop the report cleanup reaching other suites' results

The cleanup added in the previous commit globbed junit*.xml, which is wrong
wherever the results directory is shared. docker/run-docker-tests.sh mounts one
test-results directory for all eight suites and runs them in order, so the glob
deleted compat-terraform's six reports when compat-opentofu started, and both
suites deleted the junit.xml that sdk-test-awscli and compat-cdk had already
written. It destroyed results rather than tidying them.

The deletion now names the reports this run is about to write, taken from the
bats files already enumerated above it, so it cannot reach a filename this suite
does not own. That keeps the reason the cleanup exists, a run that stops before
rewriting every report leaving the survivors behind, without the reach.

One case is deliberately given up: a report whose bats file was renamed or
removed is no longer cleared, because nothing in the current run names it. A
lingering stale report is cosmetic; deleting another suite's results is not.

Raised by the review on this PR.
2026-09-09 09:44:38 -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+

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

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.

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.