Files
floci/docker/run-docker-tests.sh
T
Hector Ventura fb546d54c4 fix(docker): enable TLS and sync docker test runner with compatibility workflow (#1714)
* fix(docker): enable TLS and sync docker test runner with compatibility workflow

The local docker compose stack ran without FLOCI_TLS_ENABLED and the EC2 mock,
and run-docker-tests.sh lacked the hot-reload bind mount, so the node TLS/WSS
suites and the Java Lambda hot-reload test failed locally while passing in CI.
Mirror the compatibility workflow's configuration so local runs exercise the
same setup.

* fix: remove FLOCI_SERVICES_EC2_MOCK from docker-compose

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-07-03 01:10:06 -05:00

88 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
set -e
# 1. Start Floci
echo "=== Starting Floci with docker-compose ==="
docker compose up -d --build
# Wait for healthy
echo "Waiting for Floci to be healthy..."
# Portable wait without 'timeout' command
MAX_RETRIES=60
COUNT=0
until curl -sf http://localhost:4566/_floci/health >/dev/null 2>&1; do
if [ $COUNT -ge $MAX_RETRIES ]; then
echo "Floci failed to become healthy in time"
exit 1
fi
sleep 1
COUNT=$((COUNT + 1))
echo -n "."
done
echo " Floci is up!"
# 2. Network setup (Floci uses floci_default from compose)
NETWORK="floci_default"
DOCKER_GID=$(stat -c '%g' /var/run/docker.sock 2>/dev/null || stat -f '%g' /var/run/docker.sock)
# Floci's embedded DNS server resolves *.floci → Floci's IP.
# Passing --dns <floci-ip> to test containers lets the S3 virtual-host client
# send to <bucket>.floci:4566 which Floci DNS resolves correctly. Without this,
# Docker's built-in DNS only resolves the exact service name "floci", not
# wildcard subdomains like my-bucket.floci.
FLOCI_CONTAINER=$(docker compose ps -q floci 2>/dev/null | head -1)
FLOCI_IP=$(docker inspect -f "{{.NetworkSettings.Networks.${NETWORK}.IPAddress}}" "$FLOCI_CONTAINER" 2>/dev/null || true)
# 3. Test suites
SUITES=(
"sdk-test-python"
"sdk-test-node"
"sdk-test-java"
"sdk-test-go"
"sdk-test-awscli"
"compat-cdk"
"compat-terraform"
"compat-opentofu"
)
# results dir
mkdir -p test-results
for suite in "${SUITES[@]}"; do
echo "=== Running $suite in Docker ==="
IMAGE_NAME="compat-$suite"
# Build
docker build -q -t "$IMAGE_NAME" "compatibility-tests/$suite"
# Build DNS args: if we resolved Floci's IP, inject it as the DNS server so
# wildcard subdomains like <bucket>.floci resolve inside test containers.
DNS_ARGS=()
if [ -n "$FLOCI_IP" ]; then
DNS_ARGS=(--dns "$FLOCI_IP")
fi
# Per-suite extra args, mirroring .github/workflows/compatibility.yml.
# sdk-test-java's Lambda hot-reload test needs a host directory that the Docker
# daemon can bind-mount into the hot-reload Lambda container.
EXTRA_ARGS=()
if [ "$suite" = "sdk-test-java" ]; then
mkdir -p /tmp/floci-hot-reload
EXTRA_ARGS=(-v /tmp/floci-hot-reload:/tmp/floci-hot-reload -e HOT_RELOAD_BASE_DIR=/tmp/floci-hot-reload)
fi
# Run
docker run --rm --network "$NETWORK" \
"${DNS_ARGS[@]}" \
-e FLOCI_ENDPOINT=http://floci:4566 \
-e FLOCI_S3_VHOST_ENDPOINT=http://floci:4566 \
-v "$(pwd)/test-results:/results" \
-v /var/run/docker.sock:/var/run/docker.sock \
--group-add "$DOCKER_GID" \
"${EXTRA_ARGS[@]}" \
"$IMAGE_NAME" || echo "Test suite $suite failed"
done
echo "=== All Docker tests completed ==="