question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run Pytest tests in parallel

See original GitHub issue

https://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.

  1. 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)
  2. poetry add -D pytest-xdist==1.*
  3. poetry run pytest -n 20
  4. 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:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
WillDaSilvacommented, Sep 3, 2022

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.

0reactions
WillDaSilvacommented, Sep 1, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found