Skip to content

fix: make procrastinate integration tests runnable in CI#48

Merged
snopoke merged 4 commits into
mainfrom
sk/ci-postgres-for-procrastinate
May 26, 2026
Merged

fix: make procrastinate integration tests runnable in CI#48
snopoke merged 4 commits into
mainfrom
sk/ci-postgres-for-procrastinate

Conversation

@snopoke
Copy link
Copy Markdown
Collaborator

@snopoke snopoke commented May 26, 2026

Summary

Makes the procrastinate integration tests added in #46 actually run.

CI infra

  • Adds a postgres:16 service container to integration_tests.yml. Without it, both procrastinate tests failed on every push to main with psycopg_pool.PoolTimeout.
  • Sets PROCRASTINATE_DSN explicitly on the test step (matches the test default, but self-documents the dependency).

Test fixture fix

  • Switches test_procrastinate.py to PsycopgConnector (async). SyncPsycopgConnector can defer jobs and apply schema, but run_worker calls open_async() and raises SyncConnectorConfigurationError on sync connectors. Async connectors work in both sync and async contexts per procrastinate's docs.
  • _fetch_job_args opens its own sync psycopg.connect() instead of borrowing the app's now-async pool.

Lockfile

Test plan

  • Integration Tests workflow run on merge passes (it triggers on push to main, so we'll see it post-merge)
  • Confirm locally: uv run pytest integration_tests/test_procrastinate.py -vs against a Postgres reachable at PROCRASTINATE_DSN runs both tests green

snopoke and others added 2 commits May 26, 2026 12:12
The integration_tests.yml workflow only provisioned Redis (for Celery),
so the procrastinate tests added in #46 failed on every push to main
with `psycopg_pool.PoolTimeout`. Adds a postgres:16 service container
matching the DSN the tests default to, and sets PROCRASTINATE_DSN
explicitly so the test config is self-documenting.

Also picks up the uv.lock entry for taskbadger 2.1.0a1 that should
have ridden along with #47.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SyncPsycopgConnector can defer and apply schema, but run_worker calls
open_async() under the hood and raises SyncConnectorConfigurationError
on sync connectors. Switching to PsycopgConnector — which docs say works
in both sync and async contexts — keeps the fixture sync-friendly while
making the worker happy.

Also moves _fetch_job_args off the app's connector pool (now async) and
opens its own psycopg connection for the read.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@snopoke snopoke changed the title ci: add postgres service for procrastinate integration tests fix: make procrastinate integration tests runnable in CI May 26, 2026
snopoke and others added 2 commits May 26, 2026 12:36
session-scope broke when run_worker's open_async() tore down the sync
sub-connector PsycopgConnector creates lazily for sync defer(). The
outer `with app.open():` didn't reopen it for the next test, so test 2's
defer hit AppNotOpen. Function-scoped + idempotent apply_schema is the
simplest reliable shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
apply_schema is NOT idempotent — procrastinate's schema.sql uses bare
CREATE TYPE/CREATE TABLE, so re-running blows up with DuplicateObject
on the second invocation (whether across tests in one run or across
runs against a persistent DB).

Split into two fixtures: a session-scoped _schema that does a one-time
existence check + conditional apply, and the existing function-scoped
app that opens/closes a fresh App per test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@snopoke snopoke merged commit 053ff36 into main May 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant