camptocamp / pytest-odoo

pytest plugin to run Odoo tests
GNU Affero General Public License v3.0
67 stars 41 forks source link

How to use with pytest-xdist? #58

Open dz0 opened 1 year ago

dz0 commented 1 year ago

Hi,

I'd like to use it with pytest-xdist, but get Deadlocks because of simultaneus updates.

As I have my fresh DB (with demo data) ready before calling pytest --
I could automatically copy it for each worker (example like here) .

I can get each worker like this and use it for separate DB naming.

But how then pass those separate db-names to pytest-odoo separate processes?

yvaucher commented 7 months ago

IIUC pytest-xdist will dispatch all tests randomly to workers. Which could be an issue with database transactions.

It would require to make pytest-xdist know about SavepointCase and SingleTransactionCase. As it needs to be aware of when the savepoint and rollback, making it impossible in somecase to parallelize fully a test suite.

For SavepointCase (which nowadays is the default), it would most likely require to distribute the tests to the CPUs after the setupClass is done.

For SingleTransactionCase, it needs to be sequential.