Files
feedc0de ea50a260fa
Validate, publish, and deploy Brave Sync / validate (push) Failing after 15s
Validate, publish, and deploy Brave Sync / image (push) Skipped
Validate, publish, and deploy Brave Sync / chart (push) Skipped
Validate, publish, and deploy Brave Sync / deploy (push) Skipped
Initial commit with the existing deployment files
2026-10-09 11:39:38 +02:00

78 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
image=${1:?usage: smoke-test.sh IMAGE}
authfile=$(mktemp)
rendered=$(mktemp)
printf '{"auths":{}}' > "${authfile}"
export REGISTRY_AUTH_FILE="${authfile}"
unique="brave-sync-smoke-$$"
network="${unique}"
volume="${unique}-data"
db="${unique}-db"
cache="${unique}-cache"
server="${unique}-server"
helm template brave-sync "${project_dir}" --namespace brave-sync > "${rendered}"
image_from_template() {
local template=$1
awk -v source="# Source: brave-sync/templates/${template}.yaml" \
'$0 == source {section=1; next} /^# Source:/ {section=0} section && /^[[:space:]]+image:/ {gsub(/"/, "", $2); print $2; exit}' \
"${rendered}"
}
db_image=$(image_from_template dynamodb)
cli_image=$(image_from_template sync)
cache_image=$(image_from_template valkey)
[[ -n "${db_image}" && -n "${cli_image}" && -n "${cache_image}" ]]
cleanup() {
podman rm -f "${server}" "${cache}" "${db}" >/dev/null 2>&1 || true
podman volume rm "${volume}" >/dev/null 2>&1 || true
podman network rm "${network}" >/dev/null 2>&1 || true
rm -f -- "${authfile}" "${rendered}"
}
trap cleanup EXIT
podman network create "${network}" >/dev/null
podman volume create "${volume}" >/dev/null
podman run -d --name "${db}" --network "${network}" -v "${volume}:/data" "${db_image}" \
-jar DynamoDBLocal.jar -sharedDb -dbPath /data >/dev/null
podman run -d --name "${cache}" --network "${network}" "${cache_image}" \
--save '' --appendonly no >/dev/null
export AWS_ACCESS_KEY_ID=GOSYNC AWS_SECRET_ACCESS_KEY=GOSYNC AWS_REGION=us-west-2
for attempt in {1..30}; do
if podman run --rm --network "${network}" \
-e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_REGION \
"${cli_image}" dynamodb list-tables --endpoint-url "http://${db}:8000" >/dev/null 2>&1; then
break
fi
[[ "${attempt}" == 30 ]] && { echo "DynamoDB did not start" >&2; exit 1; }
sleep 2
done
podman run --rm --network "${network}" \
-e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_REGION \
-v "${project_dir}/schema/table.json:/schema/table.json:ro" \
"${cli_image}" dynamodb create-table --cli-input-json file:///schema/table.json \
--endpoint-url "http://${db}:8000" >/dev/null
podman run -d --name "${server}" --network "${network}" \
-e ENV=local -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_REGION \
-e AWS_ENDPOINT="http://${db}:8000" -e TABLE_NAME=client-entity-dev \
-e REDIS_URL="${cache}:6379" "${image}" >/dev/null
for attempt in {1..30}; do
if podman run --rm --network "${network}" docker.io/curlimages/curl:8.16.0 \
--silent --fail "http://${server}:8295/health-check" >/dev/null 2>&1; then
break
fi
[[ "${attempt}" == 30 ]] && { podman logs "${server}"; exit 1; }
sleep 2
done
status=$(podman run --rm --network "${network}" docker.io/curlimages/curl:8.16.0 \
--silent --output /dev/null --write-out '%{http_code}' \
--request POST "http://${server}:8295/v2/command/")
[[ "${status}" == 401 || "${status}" == 400 ]] || {
echo "Unexpected unauthenticated command status: ${status}" >&2
exit 1
}
echo "Live Sync endpoint smoke test passed"