-
Notifications
You must be signed in to change notification settings - Fork 233
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
What's the reason for ensuring 2 tests per node? #876
Comments
Because of the pytest_runtest_protocol hook: either the hook is called with an item as So each node needs to keep 2 tests around, because if more tests come, it can continue calling the hook passing This is requirement is historical, I was not even a pytest maintainer when it was designed. @RonnyPfannschmidt might have some other insights. |
Setupstate cache retaining needs nextitem |
@nicoddemus @RonnyPfannschmidt Thanks for the context. So how does the other case work given this constraint then https://github.com/pytest-dev/pytest-xdist/blob/master/src/xdist/scheduler/load.py#L257? |
First of all,
To reuse session/class fixtures from the previous test as much as possible. IMO this comment explains it: https://github.com/pytest-dev/pytest-xdist/blob/master/src/xdist/scheduler/load.py#L266 Yes, you can do round-robin always. Round-robin distribution isn't optimal even in the "less than two tests per node" case. I kept existing code only because this corner case didn't look too important for me.
It's a separate question, but the answer is the same: to avoid unnecessary fixture setup/teardown. 67f80b7#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdbaR7
|
@amezin Is that because the tests in |
Not only by module. Pytest sorts tests, taking parametrization into account:
Not enough context. Are we talking about some specific test suite? How many tests, how many nodes? |
If the default scheduler doesn't work well for you, try |
For cases like running a single test file with ~20 parallelizable tests that each takes 10+ mins to finish, it seems like round robin is the more ideal solution. But the discussion in #812 seems to suggest round robin is almost never a good choice. I agree that when there are way more tests than nodes, which is probably the most common case, round robin prob wouldn't help much at all. |
From arguably subjective experience I arrived at the opinion that for fanning out pytest tests, round Robin is never right |
@PrincipalsOffice so. Initially, you've created the issue about the comment not being good enough. Do you believe it's still the case? If you just want to discuss scheduling algorithms - I think, Discussions is a more appropriate place |
https://github.com/pytest-dev/pytest-xdist/blob/master/src/xdist/scheduler/load.py#L266
The comment doesn't seem to explain why we can't always do round robin.
The text was updated successfully, but these errors were encountered: