beyond_dev acumula estado que no tiene que ver con el código —módulos desinstalados, compañías demo sobrantes, impuestos editados a mano— y seis tests fallaban ahí por motivos que nadie causó. Una línea base que no es cero deja de ser señal: nadie lee "6 failed" dos veces. La suite pasa a correr sobre una base creada desde cero en cada corrida y borrada al terminar. beyond_dev queda para mirar pantallas. Tres cosas que el script hace y que a mano se olvidan: --with-demo, porque en Odoo 19 los datos demo están apagados por defecto en bases nuevas y beyond_dev solo los tiene por haberse creado desde el gestor; --test-tags, porque --test-enable a secas arrastra los ~3700 tests del core, muchos tours que no pasan sin navegador; y puertos propios, porque el servidor de desarrollo ocupa el 8069 y sin eso la corrida muere antes del primer test. Crear una base nueva no toca el entorno: no cambia credenciales, ni configuración, ni servicios, ni beyond_dev. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
84 lines
3.5 KiB
Bash
Executable File
84 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Beyond test suite, on a throwaway database.
|
|
#
|
|
# WHY A CLEAN DATABASE. beyond_dev accumulates state that has nothing to do
|
|
# with the code: uninstalled modules, leftover demo companies, taxes edited by
|
|
# hand. Six tests failed there for reasons none of us caused, and a baseline
|
|
# that is not zero stops being a signal — nobody reads "6 failed" twice.
|
|
# The suite now runs against a database created from scratch on every run, so
|
|
# a failure means the code, always.
|
|
#
|
|
# beyond_dev is for looking at screens; this is for knowing whether it works.
|
|
#
|
|
# The database is dropped at the end, including when a test fails. Keep it for
|
|
# a post mortem with: ./scripts/pruebas.sh --conservar
|
|
#
|
|
# Uso:
|
|
# ./scripts/pruebas.sh # los seis módulos
|
|
# ./scripts/pruebas.sh beyond_base # solo uno (y sus dependencias)
|
|
# ./scripts/pruebas.sh --conservar # no borra la base al terminar
|
|
set -euo pipefail
|
|
|
|
DB="${BEYOND_TEST_DB:-beyond_test}"
|
|
MODULOS="beyond_base,beyond_branch,beyond_customer,beyond_product_capture,beyond_attendance_qr,beyond_pos_theme"
|
|
CONSERVAR=0
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--conservar) CONSERVAR=1 ;;
|
|
--*) echo "Opción desconocida: $arg" >&2; exit 2 ;;
|
|
*) MODULOS="$arg" ;;
|
|
esac
|
|
done
|
|
|
|
# Ports of their own: the dev server holds 8069 and the HttpCase tests need to
|
|
# bind something. Without this the whole run dies with "Address already in use"
|
|
# before a single test starts.
|
|
PUERTO="${BEYOND_TEST_PORT:-8169}"
|
|
PUERTO_GEVENT="${BEYOND_TEST_GEVENT_PORT:-8172}"
|
|
|
|
limpiar() {
|
|
if [ "$CONSERVAR" -eq 1 ]; then
|
|
echo "[*] La base $DB se conserva (--conservar)."
|
|
return
|
|
fi
|
|
echo "[*] Borrando la base de pruebas $DB..."
|
|
# --force: Odoo leaves its connection pool open for a moment after
|
|
# --stop-after-init and plain dropdb refuses while anyone is attached.
|
|
docker compose exec -T db dropdb -U odoo --if-exists --force "$DB" || true
|
|
}
|
|
trap limpiar EXIT
|
|
|
|
echo "[*] Creando la base de pruebas $DB desde cero..."
|
|
docker compose exec -T db dropdb -U odoo --if-exists --force "$DB"
|
|
docker compose exec -T db createdb -U odoo -O odoo "$DB"
|
|
|
|
# Only OUR tests. --test-enable alone runs every installed module's suite,
|
|
# which here means ~3700 core tests, many of them browser tours that cannot
|
|
# pass without chromium in the container. Their noise is exactly what this
|
|
# script exists to remove.
|
|
ETIQUETAS="$(echo "$MODULOS" | tr ',' '\n' | sed 's|^|/|' | paste -sd, -)"
|
|
|
|
echo "[*] Instalando $MODULOS con datos demo y corriendo su suite..."
|
|
# -i and not -u: the point is a fresh install.
|
|
#
|
|
# --with-demo is REQUIRED, not decoration: in Odoo 19 demo data is off by
|
|
# default for new databases ("--without-demo ... (default)"), and beyond_dev
|
|
# only has it because it was created through the database manager with the box
|
|
# ticked. Without this flag there are no demo branches and the tests that look
|
|
# one up fail on an empty search. The demo data is also part of what has to
|
|
# keep working (CLAUDE.md, "demostrarlo en 2 minutos").
|
|
docker compose exec -T odoo odoo \
|
|
-d "$DB" -i "$MODULOS" --with-demo \
|
|
--test-enable --test-tags="$ETIQUETAS" --stop-after-init \
|
|
--http-port="$PUERTO" --gevent-port="$PUERTO_GEVENT" \
|
|
2>&1 | tee /tmp/beyond_pruebas.log | grep -E \
|
|
"(FAIL|ERROR): Test|Traceback|tests\.stats|failed, .* error|Modules loaded" || true
|
|
|
|
echo
|
|
if grep -qE "[1-9][0-9]* failed|[1-9][0-9]* error\(s\)" /tmp/beyond_pruebas.log; then
|
|
echo "[X] La suite NO está en verde. Registro completo: /tmp/beyond_pruebas.log"
|
|
exit 1
|
|
fi
|
|
echo "[OK] Suite en verde sobre base limpia."
|