From c9d3969c129ce17714623f14498502560861514c Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 24 Apr 2026 13:45:16 -0500 Subject: [PATCH] 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. --- Jenkinsfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 36a752e5..27996f26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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