fix: make procrastinate integration tests runnable in CI#48
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the procrastinate integration tests added in #46 actually run.
CI infra
postgres:16service container tointegration_tests.yml. Without it, both procrastinate tests failed on every push to main withpsycopg_pool.PoolTimeout.PROCRASTINATE_DSNexplicitly on the test step (matches the test default, but self-documents the dependency).Test fixture fix
test_procrastinate.pytoPsycopgConnector(async).SyncPsycopgConnectorcan defer jobs and apply schema, butrun_workercallsopen_async()and raisesSyncConnectorConfigurationErroron sync connectors. Async connectors work in both sync and async contexts per procrastinate's docs._fetch_job_argsopens its own syncpsycopg.connect()instead of borrowing the app's now-async pool.Lockfile
uv.lockentry fortaskbadger 2.1.0a1that should have ridden along with chore: prep 2.1.0a1 alpha release with procrastinate support #47.Test plan
uv run pytest integration_tests/test_procrastinate.py -vsagainst a Postgres reachable atPROCRASTINATE_DSNruns both tests green