Files
Anthias/docker-compose.test.yml
Viktor Petersson 5b6e0a4adc fix(test): give the test-stack celery worker the test environment (#3013)
* fix(test): give the test-stack celery worker the test environment

The anthias-celery service in docker-compose.test.yml lacked
ENVIRONMENT=test and ANTHIAS_TEST_DB_PATH, so the worker's settings
took the production branch.

- Worker read the empty /data/.anthias/anthias.db instead of the
  test DB, failing every dispatched task with "no such table: assets"
- Worker picked up the default production Sentry DSN, leaking
  test-run errors into the production project tagged as production
- Share the environment block between anthias-test and anthias-celery
  via a YAML anchor so the two cannot drift again

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(integration): assert video normalisation's terminal state

With the celery worker now on the correct test DB, the upload test
raced the worker: it asserted the transient placeholder duration and
is_processing=True, which the (newly working) normalisation pipeline
overwrites moments later.

- Wait for is_processing to clear instead of racing the worker
- Assert the probed duration (5 s) and the codec-gate rejection
  (no DEVICE_TYPE in the test container means an empty HW-decode set)
- The wait doubles as a regression guard for the worker reading the
  wrong DB: that failure mode leaves the row stuck on processing

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: fix comment typo (ffprobe'd) from Copilot review

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 14:39:30 +02:00

68 lines
2.6 KiB
YAML

# vim: ft=yaml.docker-compose
services:
anthias-test:
# Both anthias-test and anthias-celery declare the same image tag
# AND the same build block. Compose deduplicates the build by
# image tag, so the image is produced once; ghcr layer cache
# (configured by ``tools.image_builder`` via the Dockerfile's
# ``# syntax`` line + ``--mount=type=cache`` and the buildx
# invocation in ci) is hit by both service builds. Sharing the
# ``build:`` block also keeps either service from triggering a
# registry pull for the local-only ``anthias-test:dev`` tag.
image: anthias-test:dev
build: &test_build
context: .
dockerfile: docker/Dockerfile.test
# Shared with anthias-celery via the anchor: the worker MUST see
# the same ENVIRONMENT/ANTHIAS_TEST_DB_PATH as the server. Without
# ENVIRONMENT=test, settings.py takes the production branch on the
# worker — it reads the (empty) /data/.anthias/anthias.db instead
# of the test DB ("no such table: assets" on every task) and, with
# no DSN override, ships those errors to the production Sentry
# project tagged environment=production.
environment: &test_env
- HOME=/data
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- ENVIRONMENT=test
# Pin the test DB to the writable volume mount on /data so CI
# keeps its historic location. Local runs (no override) fall back
# to a repo-local path inside BASE_DIR — see
# src/anthias_server/django_project/settings.py.
- ANTHIAS_TEST_DB_PATH=/data/.anthias/test.db
stdin_open: true
tty: true
volumes:
- .:/usr/src/app
- anthias-data:/data
anthias-celery:
# Same image as anthias-test (test image is a superset of server:
# same base apt + venv + bun + chromium for playwright); only the CMD
# differs. Sharing the ``build:`` anchor lets compose route this
# service through the ghcr layer cache too instead of attempting
# a Docker Hub pull on the local-only ``anthias-test:dev`` tag.
image: anthias-test:dev
build: *test_build
command: >
celery -A anthias_server.celery_tasks.celery worker -B -n worker@anthias
--loglevel=info --scheduler celery.beat.Scheduler
depends_on:
anthias-test:
condition: service_started
redis:
condition: service_started
environment: *test_env
restart: always
volumes:
- .:/usr/src/app
- anthias-data:/data
redis:
image: mirror.gcr.io/library/redis:alpine
volumes:
anthias-data:
redis-data: