Refactor Jenkinsfile and wait-for-jenkins-stack.sh for improved E2E testing

- Removed the wait-for-jenkins-stack.sh script from the Jenkinsfile, integrating its functionality directly into the Jenkins pipeline for better clarity and efficiency.
- Enhanced the wait logic for backend and frontend services, implementing a reusable function in the script to streamline the waiting process and improve error handling.
- Updated comments to clarify the purpose and behavior of the changes, ensuring better understanding of the E2E testing setup.
This commit is contained in:
2026-04-24 16:13:30 -05:00
parent fe51c508d1
commit 797b1fcbdb
2 changed files with 67 additions and 31 deletions

39
Jenkinsfile vendored
View File

@@ -280,11 +280,10 @@ pipeline {
exit 1
fi
bash "$WORKSPACE/scripts/wait-for-jenkins-stack.sh"
# Playwright con docker cp (no -v): el workspace del agente Jenkins puede
# no ser visible al docker daemon. `--network host` conecta al host del
# daemon donde compose publica 5173/8000.
# daemon, donde compose publica 5173/8000 (el agente Jenkins NO ve esos
# puertos; por eso el wait corre dentro de este contenedor, no en el shell).
PW_CONTAINER="anexo76-e2e-pw-${BUILD_NUMBER}"
docker rm -f "$PW_CONTAINER" >/dev/null 2>&1 || true
docker run -d --name "$PW_CONTAINER" --network host \
@@ -296,9 +295,43 @@ pipeline {
docker exec "$PW_CONTAINER" mkdir -p /workspace
docker cp "$WORKSPACE/." "$PW_CONTAINER:/workspace"
# Wait + tests E2E en el mismo container (que sí tiene red host).
# BACKEND_MAX_SEC=900 acomoda el start_period=600s del backend healthcheck
# + margen para Alembic en DB vacía.
if ! docker exec -w /workspace/frontend "$PW_CONTAINER" bash -lc '
set -euxo pipefail
test -f package.json
echo "== wait: backend http://127.0.0.1:8000/api/health =="
i=0
until curl -fsS --connect-timeout 3 --max-time 5 http://127.0.0.1:8000/api/health >/dev/null 2>&1; do
i=$((i + 5))
if [ "$i" -ge 900 ]; then
echo "ERROR: timeout esperando backend (900s)"
exit 1
fi
if [ $((i % 30)) -eq 0 ]; then
echo " ...esperando backend (${i}/900s)"
fi
sleep 5
done
echo "== backend listo tras ${i}s =="
echo "== wait: frontend http://127.0.0.1:5173/ =="
i=0
until curl -fsS --connect-timeout 3 --max-time 5 http://127.0.0.1:5173/ >/dev/null 2>&1; do
i=$((i + 5))
if [ "$i" -ge 300 ]; then
echo "ERROR: timeout esperando frontend (300s)"
exit 1
fi
if [ $((i % 30)) -eq 0 ]; then
echo " ...esperando frontend (${i}/300s)"
fi
sleep 5
done
echo "== frontend listo tras ${i}s =="
corepack enable
pnpm install --frozen-lockfile
pnpm run i18n:compile