microsoft / AzureTRE

An accelerator to help organizations build Trusted Research Environments on Azure.
https://microsoft.github.io/AzureTRE
MIT License
182 stars 139 forks source link

Session fixtures don't have effect with pytest-xdist #2868

Open tanya-borisova opened 1 year ago

tanya-borisova commented 1 year ago

In https://github.com/microsoft/AzureTRE/issues/2839 , I created session fixtures to create a set of workspaces for testing, Unfortunately, they don't work with pytest-xdist which I used to parallelise tests in https://github.com/microsoft/AzureTRE/issues/2840 (they still work but not as session-scoped, and get executed once per testing thread).

Find a different way to pre-create test workspaces, or a workaround for session scope fixtures for pytest, or abandon the idea of re-using test workspaces.

tanya-borisova commented 1 year ago

One option would be to move to NOSE framework for our e2e tests: https://nose.readthedocs.io/en/latest/plugins/multiprocess.html

tanya-borisova commented 1 year ago

Or there is a documented file-based approach of doing this with pytest (although it is a little hacky perhaps): https://pytest-xdist.readthedocs.io/en/latest/how-to.html#making-session-scoped-fixtures-execute-only-once

tamirkamara commented 1 year ago

NOSE isn't maintained anymore and it's not clear if nose2 has the capability we need for shared fixtures.

tanya-borisova commented 1 year ago

@tamirkamara the approach I went for is what pytest describe in their documentation: https://pytest-xdist.readthedocs.io/en/latest/how-to.html#making-session-scoped-fixtures-execute-only-once

tamirkamara commented 1 year ago

So you did it already @tanya-borisova? Where? Does it handle the tear down well?

tanya-borisova commented 1 year ago

I had a branch with this work that never made it to PR stage, it was only half-done. I didn't get to implementing tear down