mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
* 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.
129 lines
3.9 KiB
Makefile
129 lines
3.9 KiB
Makefile
# SDK Compatibility Tests - Task Runner Configuration
|
|
# Run `just` to see available commands
|
|
|
|
set export
|
|
set dotenv-load
|
|
|
|
# Environment defaults
|
|
FLOCI_ENDPOINT := env('FLOCI_ENDPOINT', 'http://localhost:4566')
|
|
AWS_ACCESS_KEY_ID := env('AWS_ACCESS_KEY_ID', 'test')
|
|
AWS_SECRET_ACCESS_KEY := env('AWS_SECRET_ACCESS_KEY', 'test')
|
|
AWS_DEFAULT_REGION := env('AWS_DEFAULT_REGION', 'us-east-1')
|
|
|
|
# Default recipe - list all available commands
|
|
default:
|
|
@just --list
|
|
|
|
# Run all SDK tests sequentially (continues on failure)
|
|
test-all:
|
|
#!/usr/bin/env bash
|
|
set +e
|
|
failed=0
|
|
for suite in python typescript awscli java go; do
|
|
echo "=== Running $suite tests ==="
|
|
just test-$suite || failed=1
|
|
done
|
|
exit $failed
|
|
|
|
# Run Python SDK tests (JUnit XML output)
|
|
[working-directory: 'sdk-test-python']
|
|
test-python:
|
|
pytest tests/ --junit-xml=test-results/junit.xml
|
|
|
|
# Run TypeScript SDK tests (JUnit XML output via vitest junit reporter)
|
|
[working-directory: 'sdk-test-node']
|
|
test-typescript:
|
|
npm test
|
|
|
|
# Run AWS CLI tests (JUnit XML output via bats)
|
|
test-awscli:
|
|
./lib/run-bats-with-junit.sh sdk-test-awscli/test/ sdk-test-awscli/test-results/junit.xml
|
|
|
|
# Run Java SDK tests (JUnit XML output via Maven Surefire)
|
|
[working-directory: 'sdk-test-java']
|
|
test-java:
|
|
mvn test -q
|
|
|
|
# Run Go SDK tests (JUnit XML output via gotestsum)
|
|
[working-directory: 'sdk-test-go']
|
|
test-go:
|
|
gotestsum --junitfile test-results.xml ./tests/...
|
|
|
|
# Install all test dependencies
|
|
setup: setup-python setup-typescript setup-awscli setup-java setup-go
|
|
|
|
# Install Python test dependencies
|
|
[working-directory: 'sdk-test-python']
|
|
setup-python:
|
|
pip install -r requirements.txt
|
|
|
|
# Install TypeScript test dependencies
|
|
[working-directory: 'sdk-test-node']
|
|
setup-typescript:
|
|
npm install
|
|
|
|
# Install Java test dependencies
|
|
[working-directory: 'sdk-test-java']
|
|
setup-java:
|
|
mvn dependency:resolve -q
|
|
|
|
# Install Go test dependencies
|
|
[working-directory: 'sdk-test-go']
|
|
setup-go:
|
|
go mod download
|
|
go install gotest.tools/gotestsum@latest
|
|
|
|
# Install AWS CLI test dependencies (uses shared bats from repo root)
|
|
setup-awscli: setup-bats
|
|
@echo "AWS CLI test dependencies ready (using shared bats)"
|
|
|
|
# Install bats-core and helpers for compat tests
|
|
setup-bats:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
mkdir -p lib
|
|
if [ ! -d "lib/bats-core" ]; then
|
|
echo "Cloning bats-core..."
|
|
git clone --depth 1 https://github.com/bats-core/bats-core.git lib/bats-core
|
|
fi
|
|
if [ ! -d "lib/bats-support" ]; then
|
|
echo "Cloning bats-support..."
|
|
git clone --depth 1 https://github.com/bats-core/bats-support.git lib/bats-support
|
|
fi
|
|
if [ ! -d "lib/bats-assert" ]; then
|
|
echo "Cloning bats-assert..."
|
|
git clone --depth 1 https://github.com/bats-core/bats-assert.git lib/bats-assert
|
|
fi
|
|
echo "Bats dependencies installed!"
|
|
|
|
# Run CDK compatibility tests (JUnit XML output via bats)
|
|
test-cdk:
|
|
./lib/run-bats-with-junit.sh compat-cdk/test/ compat-cdk/test-results/junit.xml
|
|
|
|
# Run Terraform compatibility tests (one JUnit XML per bats file, files run concurrently)
|
|
test-terraform:
|
|
./compat-terraform/run.sh
|
|
|
|
# Run OpenTofu compatibility tests (one JUnit XML per bats file, files run concurrently)
|
|
test-opentofu:
|
|
./compat-opentofu/run.sh
|
|
|
|
# Run all IaC compatibility tests (continues on failure)
|
|
test-compat:
|
|
#!/usr/bin/env bash
|
|
set +e
|
|
failed=0
|
|
for suite in cdk terraform opentofu; do
|
|
echo "=== Running $suite tests ==="
|
|
just test-$suite || failed=1
|
|
done
|
|
exit $failed
|
|
|
|
# Remove build artifacts and dependencies
|
|
clean:
|
|
rm -rf sdk-test-python/__pycache__ sdk-test-python/.pytest_cache sdk-test-python/test-results
|
|
rm -rf sdk-test-node/node_modules sdk-test-node/dist sdk-test-node/test-results
|
|
rm -rf sdk-test-java/target
|
|
rm -rf sdk-test-go/test-results.xml
|
|
rm -rf lib/bats-core lib/bats-support lib/bats-assert
|