pytest-odoo icon indicating copy to clipboard operation
pytest-odoo copied to clipboard

How to use with pytest-xdist?

Open dz0 opened this issue 1 year ago • 1 comments

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?

dz0 avatar May 10 '23 05:05 dz0

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.

yvaucher avatar Dec 15 '23 09:12 yvaucher