Enhance Jenkinsfile for E2E testing with PostgreSQL and Alembic migrations

- Added steps to ensure PostgreSQL service is ready before running Alembic migrations, improving the reliability of the E2E testing process.
- Implemented error handling for PostgreSQL readiness and Alembic upgrade commands to provide better feedback during CI runs.
This commit is contained in:
2026-04-24 13:45:16 -05:00
parent 4892053e7a
commit c9d3969c12

31
Jenkinsfile vendored
View File

@@ -239,6 +239,37 @@ pipeline {
echo "--- logs: celery_beat ---"
docker logs --tail 200 celery_beat 2>&1 || true
}
# Postgresql (app) + Alembic antes del resto: evita 10+ min "Waiting" mientras el lifespan
# migra y frontend/celery esperan service_healthy. El start de backend hará "upgrade" idempotente.
echo "== E2E: Postgres (app) + migraciones Antes del resto =="
if ! e2e_compose build backend; then
e2e_compose_fail_logs
exit 1
fi
if ! e2e_compose up -d postgres-a76; then
e2e_compose_fail_logs
exit 1
fi
_pg=0
while [ "$_pg" -lt 90 ]; do
if e2e_compose exec -T postgres-a76 pg_isready -U postgres -d anexo76_core 2>/dev/null; then
echo "E2E: Postgres (anexo76_core) acepta conexiones"
break
fi
_pg=$((_pg + 1))
sleep 2
done
if ! e2e_compose exec -T postgres-a76 pg_isready -U postgres -d anexo76_core 2>/dev/null; then
echo "ERROR: timeout esperando a postgres-a76"
e2e_compose_fail_logs
exit 1
fi
if ! e2e_compose run --rm --no-deps --entrypoint "" backend sh -c "set -eux; cd /app; alembic upgrade head"; then
echo "ERROR: falló alembic upgrade head (job previo al stack completo)"
e2e_compose_fail_logs
exit 1
fi
echo "== E2E: stack completo =="
if ! e2e_compose up -d --build; then
e2e_compose_fail_logs
exit 1