Patterns for Python integration tests (e.g. w/ Postgres database) #21933
Replies: 1 comment
-
This is a massive amount of work and I would imagine it is probably outside of the scope of Pants core. In my organization we use a separate tool for what you are describing, lets call them integration tests. I think there are opportunities for integrating these different kinds of tools, but they can be used in harmony together today. For instance I would use garden to set up the testing environment and then pants inside the container to run the tests and it can then efficiently only run tests for the effected modules. On the other hand we might use Pants to tell Garden which integration test jobs need rerun from doing a dependency analysis, via a Pants plugin. Hope some of my experience helped. |
Beta Was this translation helpful? Give feedback.
-
I have some Django applications I am looking to onboard to a monorepo that uses Pants. These applications depend on Postgres-specific database features, e.g. triggers, and so tests require a running Postgres database (vs. just using SQLite). Ideally these tests could run within Pants/hermetically - i.e. without having to run something like
docker-compose
locally before runningpants test ::
(and equivalent in GitHub workflows/CI) to make a Postgres database available.Does this seem generally possible? Is there any official stance on support (or planned support) for patterns like this? My first thought was that Pants has support for running Docker images, and for running Python tests, so maybe a plugin would work. The idea would be to have something like:
with the complications being that:
python_tests
targets requiringdocker_services
(e.g. if I have twopython_tests
targets, both requiring a Postgres database, we might need two databases running in parallel).Any guidance or suggestions on how to support these types of integration tests would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions