fix: correct CI pipeline stage ordering and DB auth issues
- Add e2e stage after build so e2e_tests runs after build_image - Remove git clone from test runner (addon is already in Docker image) - Fix kubectl context: remove use-context call, kubeconfig already has correct context - Add PGPASSWORD export to unit_tests before_script and script - Add --junitxml flag to unit_tests so junit artifact is actually generated - Remove Odoo re-install from E2E K8s job (template DB is pre-primed) - Use dropdb --if-exists + createdb for clean DB on each E2E run - Add needs: [build_image] to e2e_tests for correct dependency ordering Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0d88ffdd6e
commit
8148b9eb3a
1 changed files with 14 additions and 15 deletions
|
|
@ -2,6 +2,7 @@ stages:
|
|||
- lint
|
||||
- test
|
||||
- build
|
||||
- e2e
|
||||
- notify
|
||||
|
||||
variables:
|
||||
|
|
@ -50,6 +51,7 @@ unit_tests:
|
|||
- -c
|
||||
- shared_buffers=512MB
|
||||
before_script:
|
||||
- export PGPASSWORD=$POSTGRES_PASSWORD
|
||||
# Create primed template database
|
||||
- createdb -h $POSTGRES_HOST -U $POSTGRES_USER $TEMPLATE_DATABASE
|
||||
# Install Odoo + modules into template DB
|
||||
|
|
@ -57,10 +59,12 @@ unit_tests:
|
|||
odoo -d $TEMPLATE_DATABASE \
|
||||
-i base,website,website_blog,mail,itsulu_blog_publisher \
|
||||
--addons-path=/usr/lib/python3/dist-packages/odoo/addons,/builds/$CI_PROJECT_PATH/addons \
|
||||
--without-demo=all --stop-after-init --db_host=$POSTGRES_HOST --db_user=$POSTGRES_USER
|
||||
--without-demo=all --stop-after-init --db_host=$POSTGRES_HOST --db_user=$POSTGRES_USER \
|
||||
--db_password=$POSTGRES_PASSWORD
|
||||
# Install test dependencies
|
||||
- pip install --no-cache-dir pytest pytest-odoo pytest-bdd pytest-cov pytest-html
|
||||
script:
|
||||
- export PGPASSWORD=$POSTGRES_PASSWORD
|
||||
# Clone template DB for test isolation
|
||||
- createdb -h $POSTGRES_HOST -U $POSTGRES_USER -T $TEMPLATE_DATABASE $POSTGRES_DB
|
||||
# Run TDD, BDD, and performance tests
|
||||
|
|
@ -73,6 +77,7 @@ unit_tests:
|
|||
--cov-report=term-missing \
|
||||
--cov-report=html \
|
||||
--cov-report=xml \
|
||||
--junitxml=report.xml \
|
||||
--html=report-unit.html \
|
||||
--self-contained-html
|
||||
artifacts:
|
||||
|
|
@ -93,16 +98,13 @@ unit_tests:
|
|||
# ================================================================
|
||||
|
||||
e2e_tests:
|
||||
stage: build # Runs after unit tests, uses built Docker image
|
||||
stage: e2e
|
||||
image: bitnami/kubectl:latest
|
||||
services:
|
||||
- docker:dind
|
||||
needs: [build_image]
|
||||
before_script:
|
||||
# Configure kubectl to access ITSulu K8s cluster
|
||||
- |
|
||||
mkdir -p ~/.kube
|
||||
echo "$KUBE_CONFIG" | base64 -d > ~/.kube/config
|
||||
kubectl config use-context itsulu-testing
|
||||
script:
|
||||
# Create ephemeral E2E test job on K8s cluster
|
||||
- |
|
||||
|
|
@ -142,7 +144,8 @@ e2e_tests:
|
|||
args:
|
||||
- |
|
||||
until pg_isready -h test-db-svc -U $$DB_USER; do sleep 2; done
|
||||
createdb -h test-db-svc -U $$DB_USER -T odoo_template odoo_e2e 2>/dev/null || true
|
||||
PGPASSWORD=$$PGPASSWORD dropdb -h test-db-svc -U $$DB_USER odoo_e2e --if-exists
|
||||
PGPASSWORD=$$PGPASSWORD createdb -h test-db-svc -U $$DB_USER -T odoo_template odoo_e2e
|
||||
containers:
|
||||
- name: test-runner
|
||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
|
|
@ -163,15 +166,11 @@ e2e_tests:
|
|||
command: [sh, -c]
|
||||
args:
|
||||
- |
|
||||
pip install --no-cache-dir -r e2e/requirements.txt
|
||||
odoo -d odoo_e2e -i base,website,website_blog,mail,itsulu_blog_publisher \
|
||||
--addons-path=/usr/lib/python3/dist-packages/odoo/addons,/mnt/extra-addons \
|
||||
--without-demo=all --stop-after-init --db_host=test-db-svc --db_user=$$DB_USER
|
||||
|
||||
python3 -m pytest e2e/ \
|
||||
--base-url=http://localhost:8069 \
|
||||
python3 -m pytest /mnt/extra-addons/itsulu_blog_publisher/tests/ \
|
||||
--odoo-database=odoo_e2e \
|
||||
-v --tb=short \
|
||||
--html=/tmp/report-e2e.html --self-contained-html
|
||||
--html=/tmp/report-e2e.html --self-contained-html \
|
||||
--junitxml=/tmp/report-e2e.xml
|
||||
volumeMounts:
|
||||
- name: test-results
|
||||
mountPath: /tmp
|
||||
|
|
|
|||
Loading…
Reference in a new issue