Files
floci/compatibility-tests/compat-cdk/test/test_helper/common-setup.bash
T
Kenshin Okinaka ba843013ec chore(compat): align pinned SDK versions across the Python, Java, and CDK suites (#2253)
* chore(compat): align pinned SDK versions across the Python, Java, and CDK suites

Bump the exact-pinned SDK versions to a common recent baseline so the suites no longer
span a wide release window:

- sdk-test-python: boto3 / botocore 1.37.1 -> 1.43.69
- sdk-test-java: AWS SDK for Java v2 2.44.14 -> 2.52.0
- compat-cdk: aws-cdk-lib 2.171.1 -> 2.264.0, aws-cdk 2.171.1 -> 2.1135.1,
  aws-cdk-local ^2.0.0 -> ^3.0.4

Bumping boto3/botocore also restores the current SES v2 model (97 -> 112 operations,
including the Tenant and ReputationEntity families).

The aws-cdk 2.1000+ CLI (decoupled from the library version line) publishes template
assets to S3 using virtual-hosted-style URLs and needs aws-cdk-local v3. Pointing
AWS_ENDPOINT_URL_S3 at Floci's virtual-hosted domain (http://s3.localhost.floci.io:4566)
makes the SDK build <bucket>.s3.localhost.floci.io, which resolves via public DNS locally
and via Floci's embedded DNS (already injected with --dns in the compat workflow) inside
the Docker network, instead of the unresolvable <bucket>.floci.

The Go, Node, AWS CLI, Terraform, and OpenTofu suites float to the latest by design and
are left unchanged.

* chore(compat): let AWS_ENDPOINT_URL_S3 be overridden in the compat-cdk helper

Use a ${:-default} fallback like the other endpoint/region variables in
common-setup.bash so a caller or CI can point the CDK S3 virtual-host endpoint
elsewhere (e.g. a non-4566 port), instead of hard-coding it.
2026-08-16 22:40:20 -05:00

50 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# Common setup for CDK bats tests
CDK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
# Load bats helpers - support both local and Docker environments
if [[ -d "${CDK_DIR}/../lib/bats-support" ]]; then
load "${CDK_DIR}/../lib/bats-support/load"
load "${CDK_DIR}/../lib/bats-assert/load"
elif [[ -d "${CDK_DIR}/lib/bats-support" ]]; then
load "${CDK_DIR}/lib/bats-support/load"
load "${CDK_DIR}/lib/bats-assert/load"
elif [[ -n "${BATS_LIB_PATH:-}" ]]; then
load "${BATS_LIB_PATH}/bats-support/load"
load "${BATS_LIB_PATH}/bats-assert/load"
else
echo "Error: Cannot find bats-support/bats-assert libraries" >&2
exit 1
fi
# Shared test helpers kept local to this module so Docker and local runs behave the same.
export FLOCI_ENDPOINT="${FLOCI_ENDPOINT:-http://localhost:4566}"
export AWS_DEFAULT_REGION="${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 AWS_ENDPOINT_URL="$FLOCI_ENDPOINT"
# aws-cdk-local v3 requires AWS_ENDPOINT_URL_S3; use Floci's virtual-hosted S3 domain so
# <bucket>.s3.localhost.floci.io resolves (public DNS locally; Floci's embedded DNS in Docker).
export AWS_ENDPOINT_URL_S3="${AWS_ENDPOINT_URL_S3:-http://s3.localhost.floci.io:4566}"
aws_cmd() {
aws --endpoint-url "$FLOCI_ENDPOINT" --region "$AWS_DEFAULT_REGION" --output json "$@"
}
json_get() {
local json="$1"
local path="$2"
echo "$json" | jq -r "$path" 2>/dev/null || echo ""
}
# CDK-specific environment
export LOCALSTACK_HOSTNAME="${LOCALSTACK_HOSTNAME:-localhost}"
export EDGE_PORT="${EDGE_PORT:-4566}"
# Override endpoint for Docker networking if needed
if [ "$LOCALSTACK_HOSTNAME" = "floci" ]; then
export FLOCI_ENDPOINT="http://floci:4566"
export AWS_ENDPOINT_URL="http://floci:4566"
fi