feat: добавить Image Gateway с кешем Souin
- добавлена сборка Caddy с Souin, Otter и NutsDB - добавлена конфигурация dev, prod и test Docker Compose - настроено кеширование через Otter L1 и NutsDB L2 - добавлены e2e-тесты Bun для кеша, restart и purge - добавлена документация по запуску, API кеша и тестам
This commit is contained in:
46
scripts/test-e2e.sh
Executable file
46
scripts/test-e2e.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
project_name="${COMPOSE_PROJECT_NAME:-image-gateway-test-${CI_JOB_ID:-${GITHUB_RUN_ID:-local}}}"
|
||||
compose=(docker compose -p "${project_name}" -f docker-compose.test.yml)
|
||||
|
||||
cleanup() {
|
||||
status=$?
|
||||
|
||||
if [ "${status}" -ne 0 ]; then
|
||||
"${compose[@]}" logs --no-color || true
|
||||
fi
|
||||
|
||||
"${compose[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
|
||||
exit "${status}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
"${compose[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
|
||||
"${compose[@]}" up -d --build caddy imgproxy fixture
|
||||
|
||||
"${compose[@]}" run --rm tester bun test tests/e2e/cache-prime.test.js
|
||||
|
||||
"${compose[@]}" restart caddy
|
||||
"${compose[@]}" run --rm tester bun test tests/e2e/cache-persistence.test.js
|
||||
|
||||
"${compose[@]}" run --rm tester bun test tests/e2e/cache-purge.test.js
|
||||
|
||||
logs=$("${compose[@]}" logs --no-color caddy)
|
||||
|
||||
case "${logs}" in
|
||||
*"default storage that is not optimized"*)
|
||||
printf '%s\n' "Caddy logs contain Souin default storage warning"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${logs}" in
|
||||
*"NUTS-INSERTION-ERROR"*)
|
||||
printf '%s\n' "Caddy logs contain NUTS-INSERTION-ERROR"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
printf '%s\n' "E2E cache tests passed"
|
||||
Reference in New Issue
Block a user