-
Notifications
You must be signed in to change notification settings - Fork 79
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
enable parallel tests with pytest-xdist and pytest-split #2874
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2874 +/- ##
==========================================
- Coverage 76.98% 76.97% -0.02%
==========================================
Files 112 112
Lines 11975 11977 +2
==========================================
Hits 9219 9219
- Misses 2756 2758 +2 ☔ View full report in Codecov by Sentry. |
5a6f484
to
c2831f8
Compare
@0xbe7a Thoughts about this? |
There seems to be something wrong with the coverage. Converting to draft. |
The tests used to break in general with this which is why I turned it off. It's a good idea to try again. |
Pytest split is really cool! The mongodb tests happen against a test instance in a docker container in the GitHub runner, so that should work fine. |
We'll need to adjust the required tests for this pr. I will do that once we merge it. |
112cff5
to
8cc1d01
Compare
Note: I am wildly pushing here to evaluate different approaches. I just found out that running |
Okay, so here is a summary of what I found out:
In the diff of this PR (or here, you find my analysis of the runners we already use in this project. From the analysis, I figure out that a splitting the tests across 4 runners is too much. Requesting more runners than available does lead to test times to double, which we should avoid.
It is possible to combine Other approaches for speeding up test times could include:
|
98533c2
to
f320339
Compare
squash! split tests with pytest-split
4fd5e8a
to
a4dc76a
Compare
Open issues:
|
My opinion is that we should not let the perfect be the enemy of the good and we should go ahead. Are there tests not being run now and that is causing the coverage decrease? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking through this, and I think we should do the test timings files like the coverage ones.
Specifically,
- We upload the test durations as artifacts
- download all of them at once with a glob like we do the for the coverage files
- combine them with jq
- update the cache
For the cache, instead of a delete and then save, which might cause a race condition for another job, we can use a key with say the branch name or github ref in it. Then we can restore adaptive using restore keys and save new caches easily when there is a miss.
Enabling pytest-xdist (which is already in the list of our dependencies) brings down test time from 12 minutes to around 8:30, which saves us 3:30 min per test run.
For the model tests, test runtime is roughly equal but I still enabled it for consistency.
As you can see in the commit history, I also evaluated using pytest-split for splitting tests across multiple GitHub Runners but
could not see a significant performance gain because of the overhead involved with building the Docker container. I found a naive approach (building the Docker container 4 times in parallel) that brings us down another minute to 7:20, saving 40 % wait time in total.Are there any tests on the MongoDB that could break with this? @beckermr