Run Pytest tests in parallel
See original GitHub issuehttps://meltano.slack.com/archives/CKHP6G5V4/p1653508630941889
Looks like pytest doesn’t take 45 minutes, not sure why I though it was taking that long before? Maybe on gitlab CI updated the title to reflect that it takes ~5-10 minutes to run pytest today.
- Be sure https://github.com/meltano/meltano/pull/6155/files#diff-65c008e1065903299dfa0da25e1f18d0f87f387867ccbbf2b0888eb138bdb255L242 is implemented (This uses a seperate folder for each Test in your temp directory instead of the same folder over and over again)
poetry add -D pytest-xdist==1.*
poetry run pytest -n 20
- Watch tests run extremely quickly
There’s still a large number of failures here as some tests depend on the other I believe? Not exactly sure what causes the failures, but it’s clear they weren’t all designed with parallel testing in mind. The gain is big enough it may be worth the time to figure out what causes the failures.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Pytest - Run Tests in Parallel - Tutorialspoint
By default, pytest runs tests in sequential order. In a real scenario, a test suite will have a number of test files and...
Read more >pytest run tests parallel - python - Stack Overflow
I run my tests using pytest -v -s . The result is that my tests are running sequentially, which takes a lot of...
Read more >pytest-parallel - PyPI
This plugin makes it possible to run tests quickly using multiprocessing (parallelism) and multithreading (concurrency). Why? pytest-xdist is great to run tests ......
Read more >Test Parallelization Using Python and Pytest
Test parallelization is the process of distributing test load across multiple processors, then running the tests all at one time.
Read more >Part 2: PyTest - Run your test with Markers and In Parallel Mode
In this video, I have explained how to run your test cases in groups using markers and run test cases in parallel mode....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good timing on the public beta for large GitHub runners: https://github.blog/changelog/2022-09-01-github-actions-larger-runners-are-now-in-public-beta/
I’ve added Meltano to the waitlist to be permitted to use them.
Seems like the larger runners also come with more memory, which we’ll need for running many tests in parallel. Particularly for the MSSQL tests, which create a very heavy Java process for each Pytest worker. The memory conveniently scales at the same rate as the processor cores.
We may want to upgrade our CI runners. They currently have 2 cores, but with more our CI pipelines would be far faster once we’re running the Python tests in parallel. GitHub charges linearly per-core for their CI runners, so as an example, if we want to use runners with 16 cores, it would cost us 8 times as much to execute the Python tests per CI minute, but my guess is that the tests would probably execute ~6 times faster. Seems like a worthwhile tradeoff.
https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners