Skip to content

Add xdist and parallel test execution for Python non-integration tests#61

Open
iloveitaly wants to merge 2 commits intomasterfrom
jules-xdist-support-13717195786142027270
Open

Add xdist and parallel test execution for Python non-integration tests#61
iloveitaly wants to merge 2 commits intomasterfrom
jules-xdist-support-13717195786142027270

Conversation

@iloveitaly
Copy link
Copy Markdown
Owner

I have added pytest-xdist to the project to run python non-integration tests in parallel. The changes configure each test worker to have its own unique PostgreSQL database and Redis database index to avoid collisions. The master test process handles test setup logic like truncating the seed database and cloning it for each worker.


PR created automatically by Jules for task 13717195786142027270 started by @iloveitaly

- Add `pytest-xdist` to dev dependencies.
- Update `just/python.just` to run non-integration tests with `-n auto`.
- Modify `tests/conftest.py` to:
  - Extract worker ID and uniquely assign DB / Redis URLs per worker early.
  - Intercept test session start, allowing only the master process to run global seed/cleanup.
  - Master process drops and recreates worker DBs using `CREATE DATABASE ... WITH TEMPLATE ...` avoiding collisions or migration state leakage.
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Extract all xdist setup, environment variable configuration, and database cloning routines into `tests/concurrent_tests.py` to keep `conftest.py` lean.
- Generate intuitive worker database names prefixed with `pytest_worker_` and the exact worker id.
- Use `sqlalchemy.engine.make_url()` natively for safer database URL parsing and manipulation without resorting to manual string parsing or inadvertently stripping secrets.
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