Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in random order on nodes #229

Closed
timj opened this issue Sep 2, 2017 · 4 comments
Closed

Run tests in random order on nodes #229

timj opened this issue Sep 2, 2017 · 4 comments

Comments

@timj
Copy link
Contributor

timj commented Sep 2, 2017

Sorry if this has been covered elsewhere or is obvious, but I would like to be able to run our test suite with the tests running in a random order where the order is controlled by a random seed to allow reproducibility. At the moment I can do that with pytest-random-order or pytest-randomly but as soon as I use -n everything gets confused because it seems the randomization messes with the test to node allocation and the subprocesses complain that they have been scheduled the same tests or that tests are missing.

Is there any way the xdist scheduler can play nicely with pytest-random-order or any way to control the ordering in xdist itself?

My motivation for this is that we are finding that some of the tests are sensitive to test execution order and fail if run first or on their own.

@RonnyPfannschmidt
Copy link
Member

currently this is not possible at all - based on the work in the loadscope sheduler it should be possible to randomize better

the main problem is, that xdist is incompatible with worker side collection reordering and the same plug-ins cant nicely put it in place for the schedulers

redshiftzero added a commit to redshiftzero/securedrop-client that referenced this issue Oct 16, 2019
running test suite in parallel before we get too far

we should also monitor pytest-dev/pytest-xdist#229
because right now one cannot run tests in random order as well as
run in parallel
redshiftzero added a commit to redshiftzero/securedrop-client that referenced this issue Oct 16, 2019
running test suite in parallel before we get too far

we should also monitor pytest-dev/pytest-xdist#229
because right now one cannot run tests in random order as well as
run in parallel
redshiftzero added a commit to redshiftzero/securedrop-client that referenced this issue Oct 21, 2019
running test suite in parallel before we get too far

we should also monitor pytest-dev/pytest-xdist#229
because right now one cannot run tests in random order as well as
run in parallel

until then, I've added another makefile target that can run the tests
in parallel, and have left that running in CI.
redshiftzero added a commit to redshiftzero/securedrop-client that referenced this issue Oct 21, 2019
running test suite in parallel before we get too far

we should also monitor pytest-dev/pytest-xdist#229
because right now one cannot run tests in random order as well as
run in parallel

until then, I've added another makefile target that can run the tests
in parallel, and have left that running in CI.
redshiftzero added a commit to redshiftzero/securedrop-client that referenced this issue Oct 21, 2019
running test suite in parallel before we get too far

we should also monitor pytest-dev/pytest-xdist#229
because right now one cannot run tests in random order as well as
run in parallel

until then, I've added another makefile target that can run the tests
in parallel, and have left that running in CI.
@ssbarnea
Copy link
Member

ssbarnea commented Oct 9, 2023

I would be quite curious to find out if someone found a way to randomize test order while running xdist as from time to time I endup facing testing issues related to parallel runs that are hard to reproduce.

@nicoddemus
Copy link
Member

I understand https://pypi.org/project/pytest-randomly/ supports xdist?

@nicoddemus
Copy link
Member

Yes, looking at the code seems like pytest-randomly does support xdist properly:

https://github.com/pytest-dev/pytest-randomly/blob/f646c188bb70660d74b81388094bfd038f5650f9/src/pytest_randomly/__init__.py#L127-L147

Closing this then. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants