Skip to content
New issue

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

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

Already on GitHub? # to your account

Speed up tests with pytest-xdist #1289

Closed
simonw opened this issue Apr 3, 2021 · 3 comments · Fixed by #1290
Closed

Speed up tests with pytest-xdist #1289

simonw opened this issue Apr 3, 2021 · 3 comments · Fixed by #1290

Comments

@simonw
Copy link
Owner

simonw commented Apr 3, 2021

I think I can get this working for almost every test, then use the pattern in pytest-dev/pytest-xdist#385 (comment) to opt specific tests out of being run in parallel.

@simonw
Copy link
Owner Author

simonw commented Apr 3, 2021

On my Mac pytest-xdist ran the test suite (minus two tests) in 59s, as opposed to 2m23s without xdist.

@simonw
Copy link
Owner Author

simonw commented Apr 3, 2021

Looks like -n auto only detected two cores on GitHub Actions: https://github.com/simonw/datasette/runs/2257597137?check_suite_focus=true

============================= test session starts ==============================
platform linux -- Python 3.7.10, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
SQLite: 3.31.1
rootdir: /home/runner/work/datasette/datasette, configfile: pytest.ini
plugins: xdist-2.2.1, timeout-1.4.2, forked-1.3.0, asyncio-0.14.0
gw0 I / gw1 I
gw0 [878] / gw1 [878]

@simonw
Copy link
Owner Author

simonw commented Apr 3, 2021

https://github.com/simonw/datasette/actions/runs/713207828 ran with pytest-xdist in 4m22s:

Run_tests_in_CI_using_pytest-xdist__refs__1289_·_simonw_datasette_d63fc61

Here's the test suite running on regular pytest in 5m13s:

©_2017-2021_·_simonw_datasette_59ef4a2

Not a huge speed-up because there are only 2 available cores in the GitHub Actions environment, but still worthwhile - especially since this lets people run in parallel on their own laptops.

simonw added a commit that referenced this issue Apr 3, 2021
* Run tests in CI using pytest-xdist
* Documentation for pytest-xdist

Closes #1289
simonw added a commit that referenced this issue May 23, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant