mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 23:59:27 -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.
28 lines
1.0 KiB
Bash
Executable File
28 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Runs the Terraform compatibility suite against a Floci already listening on
|
|
# FLOCI_ENDPOINT. Delegates to run-bats-in-container.sh, the same entrypoint the
|
|
# Docker image uses, so a local run and a CI run execute identical logic.
|
|
|
|
export AWS_REGION=us-east-1
|
|
export AWS_DEFAULT_REGION=us-east-1
|
|
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-test}"
|
|
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-test}"
|
|
export FLOCI_ENDPOINT="${FLOCI_ENDPOINT:-http://localhost:4566}"
|
|
export AWS_ENDPOINT_URL="$FLOCI_ENDPOINT"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
if [ ! -d "$REPO_ROOT/lib/bats-core" ]; then
|
|
echo "Error: bats-core not found. Run 'just setup-bats' first."
|
|
exit 1
|
|
fi
|
|
|
|
# BATS_JUNIT_XML used to name a single file; the suite now writes one report per
|
|
# bats file, so the variable names the directory they land in.
|
|
export RESULTS_DIR="${RESULTS_DIR:-$SCRIPT_DIR/test-results}"
|
|
|
|
exec "$SCRIPT_DIR/run-bats-in-container.sh"
|