Skip to content

pytest-xdist scheduler that runs some tests on dedicated workers. can significantly improve runtime by running long tests on separate workers.

License

Notifications You must be signed in to change notification settings

andgineer/xdist-scheduling-exclusive

Repository files navigation

Build Status Coverage

xdist-scheduling-exclusive

A pytest-xdist scheduler for running specific tests on dedicated workers.

Features

  • Improves test runtime by assigning slow tests to separate workers
  • Includes custom reporting in conftest.py to show test scheduling details

Installation

pip install xdist-scheduling-exclusive pytest-xdist

Usage

To integrate with your pytest setup, update conftest.py as follows:

from xdist_scheduling_exclusive import ExclusiveLoadScopeScheduling

def pytest_xdist_make_scheduler(config, log):
    """xdist-pytest hook to set scheduler."""
    return ExclusiveLoadScopeScheduling(config, log)

Create an exclusive tests file exclusive_tests.txt in tests/resources/.

You can identify slow tests using pytest's --durations option which sorts tests by execution time. Remember to remove execution times from the file - it should contain only test node IDs. See the example in this project's tests/resources/exclusive_tests.txt.

Placing the slowest tests in exclusive_tests.txt will give you the most benefit.

Available Schedulers:

  • ExclusiveLoadScheduling: Schedules tests from exclusive_tests.txt first on dedicated nodes.
  • ExclusiveLoadFileScheduling: Places tests from exclusive_tests.txt into unique scopes. Other tests are grouped as in --dist loadfile: tests from the same file run on the same node.
  • ExclusiveLoadScopeScheduling: Schedules tests from exclusive_tests.txt first on dedicated nodes. Other tests are grouped as in --dist loadscope: tests from the same file run on the same node.

Development

Activate the development environment:

. ./activate.sh

To see how tests were scheduled:

python -m pytest -n 4 --xdist-report -s

View available scripts:

make help

Coverage report

About

pytest-xdist scheduler that runs some tests on dedicated workers. can significantly improve runtime by running long tests on separate workers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •