Skip to content

Commit

Permalink
test/verify: tweak pytest-xdist behaviour
Browse files Browse the repository at this point in the history
pytest-xdist sends large chunks of tasks to the workers to reduce
latency, but since our tasks are long, this isn't helpful. It also means
that we can end up with a large string of very slow tests on one worker.
Disable it, if possible.

pytest-dev/pytest-xdist#855
  • Loading branch information
allisonkarlitskaya authored and martinpitt committed Jun 17, 2023
1 parent 4ebb9b3 commit 6f2710a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/verify/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ def is_nondestructive(item: pytest.Item) -> bool:

# put the destructive tests last under the assumption that they're slower
items.sort(key=is_nondestructive, reverse=True)


@pytest.hookimpl
def pytest_configure(config: pytest.Config) -> None:
"""Tweaks test distribution for long-running tasks
pytest-xdist sends large chunks of tasks to the workers to reduce
latency, but since our tasks are long, this isn't helpful. It also
means that we can end up with a large string of very slow tests on
one worker. Disable it, if possible.
https://github.com/pytest-dev/pytest-xdist/issues/855
"""
try:
# If parallel enabled and maxschedchunk not otherwise given...
if config.option.numprocesses and config.option.maxschedchunk is None:
config.option.maxschedchunk = 1
except AttributeError:
pass # no pytest-xdist plugin installed, or plugin is too old

0 comments on commit 6f2710a

Please sign in to comment.